コード例 #1
0
def single_run():
    
    sim.init()
    aircraft_handlers.init()
    formation_handlers.init()
    statistics.init()
    #plot.init()
    
    # Construct flight list
    planes = generators.get_via_stdin()
    #planes = generators.get_manual()
    
    if len(planes) > 0:

        # Find hubs
        config.hubs = builders.build_hubs(planes, config.count_hubs, config.Z)
    
        # Allocate hubs to flights
        allocators.allocate(planes, config.hubs)
        
        for flight in planes:
            sim.events.append(sim.Event('aircraft-init', flight, 0))
        
    sim.run()

    sink.push(statistics.vars)
    debug.print_dictionary(statistics.vars)
コード例 #2
0
ファイル: run.py プロジェクト: mauzeh/formation-flight
def execute():
    
    print 'init sink %s' % config.sink_dir
    
    sink.init(config.sink_dir)

    for hub in config.hubs:
        
        print 'Progress: %d of %d iterations' % (
            config.hubs.index(hub)+1,
            len(config.hubs)
        )

        sim.init()
        aircraft_handlers.init()
        formation_handlers.init()
        statistics.init()
        
        # Construct flight list
        planes = generators.get_via_stdin()
        
        # Allocate hubs to flights
        for flight in planes:

            # Assign hub by injecting into route
            flight.route.waypoints = [
                flight.route.waypoints[0],
                hub,
                flight.route.waypoints[1]
            ]
    
            flight.route.init_segments()
        
        for flight in planes:
            sim.events.append(sim.Event('aircraft-init', flight, 0))

        sim.run()
        
        # Prepare data matrix
        d = {
            'hub_lat'                : hub.lat,
            'hub_lon'                : hub.lon,
            'distance_total'         : float(statistics.vars['distance_total']),
            'distance_formation'     : float(statistics.vars['distance_formation']),
            'distance_solo'          : float(statistics.vars['distance_solo']),
            'formation_count'        : float(statistics.vars['formation_count']),
            'formation_success_rate' : float(statistics.vars['formation_success_rate']),
            'alpha_eff'              : float(statistics.vars['alpha_effective']),
            'distance_success_rate'  : float(statistics.vars['distance_success_rate']),
            'avg_formation_size'     : float(statistics.vars['avg_formation_size']),
            'fuel_saved'             : float(statistics.vars['fuel_saved']),
            'distance_penalty'       : float(statistics.vars['distance_penalty']),
        }

        sink.push(d)
        debug.print_dictionary(d)
コード例 #3
0
def execute():

    print 'init sink %s' % config.sink_dir

    sink.init(config.sink_dir)

    for hub in config.hubs:

        print 'Progress: %d of %d iterations' % (config.hubs.index(hub) + 1,
                                                 len(config.hubs))

        sim.init()
        aircraft_handlers.init()
        formation_handlers.init()
        statistics.init()

        # Construct flight list
        planes = generators.get_via_stdin()

        # Allocate hubs to flights
        for flight in planes:

            # Assign hub by injecting into route
            flight.route.waypoints = [
                flight.route.waypoints[0], hub, flight.route.waypoints[1]
            ]

            flight.route.init_segments()

        for flight in planes:
            sim.events.append(sim.Event('aircraft-init', flight, 0))

        sim.run()

        # Prepare data matrix
        d = {
            'hub_lat':
            hub.lat,
            'hub_lon':
            hub.lon,
            'distance_total':
            float(statistics.vars['distance_total']),
            'distance_formation':
            float(statistics.vars['distance_formation']),
            'distance_solo':
            float(statistics.vars['distance_solo']),
            'formation_count':
            float(statistics.vars['formation_count']),
            'formation_success_rate':
            float(statistics.vars['formation_success_rate']),
            'alpha_eff':
            float(statistics.vars['alpha_effective']),
            'distance_success_rate':
            float(statistics.vars['distance_success_rate']),
            'avg_formation_size':
            float(statistics.vars['avg_formation_size']),
            'fuel_saved':
            float(statistics.vars['fuel_saved']),
            'distance_penalty':
            float(statistics.vars['distance_penalty']),
        }

        sink.push(d)
        debug.print_dictionary(d)