Exemplo n.º 1
0
def handle_arrive(event):
    
    global vars, hubs

    aircraft = event.sender
    
    # Temporarily use one model for everything
    model = copy.deepcopy(config.model)
    
    # Also calculate the direct distance
    segment = Segment(aircraft.origin, aircraft.destination)
    direct = segment.get_length()
    #direct = 3193 #temp overwrite for validation
    p('validate', 'Distance direct for %s is %dNM' % (
        aircraft, direct
    ))
    p('validate', 'Getting the benchmark fuel')
    vars['distance_direct'] += direct
    vars['fuel_direct'] += get_fuel_burned_during_cruise(direct, model)
    p('validate', 'OK, we have the benchmark fuel now')
    
    hub = aircraft.hub
    assert hub in config.hubs
    
    # Sometimes (especially with very low Z and high L) aircraft are excluded
    # from formation flight due to the origin being within the lock area.
    if hasattr(aircraft, 'is_excluded') and aircraft.is_excluded:
        vars['distance_solo'] += direct
        vars['fuel_actual'] += get_fuel_burned_during_cruise(direct, model)
        return

    #key = 'flight_count_%s' % hub
    #if key not in vars:
    #    vars[key] = 0
    #vars[key] = vars[key] + 1

    # Aircraft always fly solo to the hub
    segment = Segment(aircraft.origin, hub)
    origin_to_hub = segment.get_length()
    p('Distance origin_to_hub for %s is %dNM' % (
        aircraft,
        origin_to_hub
    ))
    vars['distance_solo'] += origin_to_hub
    
    # If in formation
    if hasattr(aircraft, 'formation'):
        
        segment = Segment(hub, aircraft.hookoff_point)
        hub_to_hookoff = segment.get_length()
        p('Distance hub_to_hookoff for %s is %dNM' % (
            aircraft,
            hub_to_hookoff
        ))
        
        vars['distance_formation'] += hub_to_hookoff

        segment = Segment(aircraft.hookoff_point, aircraft.destination)
        hookoff_to_destination = segment.get_length()
        p('Distance hookoff_to_destination for %s is %dNM' % (
            aircraft,
            hookoff_to_destination
        ))
        vars['distance_solo'] += hookoff_to_destination

        # Collect all hub delays
        # The calibration aircraft was never delayed
        if hasattr(aircraft, 'hub_delay'):
            vars['hub_delay_sum'] = vars['hub_delay_sum'] +\
                aircraft.hub_delay
            
        if aircraft.incurs_benefits:
            discount = config.alpha
        else:
            discount = 0

        p('validate', 'Discount = %s for %s' % (discount, aircraft))
        
        fuel_formation = formationburn(
            int(origin_to_hub),
            int(hub_to_hookoff),
            int(hookoff_to_destination),
            model = model,
            discount = discount
        )
        
        p('validate', 'Fuel burn formation = %d for %s' % (
            fuel_formation, aircraft
        ))

        vars['fuel_actual'] += fuel_formation
    # If fully solo
    else:

        p('validate', 'Discount = false for %s' % (aircraft))

        segment = Segment(hub, aircraft.destination)
        hub_to_destination = segment.get_length()
        p('Distance hub_to_destination for %s is %dNM' % (
            aircraft,
            hub_to_destination
        ))
        vars['distance_solo'] += hub_to_destination
        
        fuel_solo = get_fuel_burned_during_cruise(
            origin_to_hub + hub_to_destination,
            model = model,
        )

        p('validate', 'Fuel burn solo = %d for %s' % (
            fuel_solo, aircraft
        ))

        vars['fuel_actual'] += fuel_solo
Exemplo n.º 2
0
def handle_arrive(event):

    global vars, hubs

    aircraft = event.sender

    # Temporarily use one model for everything
    model = copy.deepcopy(config.model)

    # Also calculate the direct distance
    segment = Segment(aircraft.origin, aircraft.destination)
    direct = segment.get_length()
    #direct = 3193 #temp overwrite for validation
    p('validate', 'Distance direct for %s is %dNM' % (aircraft, direct))
    p('validate', 'Getting the benchmark fuel')
    vars['distance_direct'] += direct
    vars['fuel_direct'] += get_fuel_burned_during_cruise(direct, model)
    p('validate', 'OK, we have the benchmark fuel now')

    hub = aircraft.hub
    assert hub in config.hubs

    # Sometimes (especially with very low Z and high L) aircraft are excluded
    # from formation flight due to the origin being within the lock area.
    if hasattr(aircraft, 'is_excluded') and aircraft.is_excluded:
        vars['distance_solo'] += direct
        vars['fuel_actual'] += get_fuel_burned_during_cruise(direct, model)
        return

    #key = 'flight_count_%s' % hub
    #if key not in vars:
    #    vars[key] = 0
    #vars[key] = vars[key] + 1

    # Aircraft always fly solo to the hub
    segment = Segment(aircraft.origin, hub)
    origin_to_hub = segment.get_length()
    p('Distance origin_to_hub for %s is %dNM' % (aircraft, origin_to_hub))
    vars['distance_solo'] += origin_to_hub

    # If in formation
    if hasattr(aircraft, 'formation'):

        segment = Segment(hub, aircraft.hookoff_point)
        hub_to_hookoff = segment.get_length()
        p('Distance hub_to_hookoff for %s is %dNM' %
          (aircraft, hub_to_hookoff))

        vars['distance_formation'] += hub_to_hookoff

        segment = Segment(aircraft.hookoff_point, aircraft.destination)
        hookoff_to_destination = segment.get_length()
        p('Distance hookoff_to_destination for %s is %dNM' %
          (aircraft, hookoff_to_destination))
        vars['distance_solo'] += hookoff_to_destination

        # Collect all hub delays
        # The calibration aircraft was never delayed
        if hasattr(aircraft, 'hub_delay'):
            vars['hub_delay_sum'] = vars['hub_delay_sum'] +\
                aircraft.hub_delay

        if aircraft.incurs_benefits:
            discount = config.alpha
        else:
            discount = 0

        p('validate', 'Discount = %s for %s' % (discount, aircraft))

        fuel_formation = formationburn(int(origin_to_hub),
                                       int(hub_to_hookoff),
                                       int(hookoff_to_destination),
                                       model=model,
                                       discount=discount)

        p('validate',
          'Fuel burn formation = %d for %s' % (fuel_formation, aircraft))

        vars['fuel_actual'] += fuel_formation
    # If fully solo
    else:

        p('validate', 'Discount = false for %s' % (aircraft))

        segment = Segment(hub, aircraft.destination)
        hub_to_destination = segment.get_length()
        p('Distance hub_to_destination for %s is %dNM' %
          (aircraft, hub_to_destination))
        vars['distance_solo'] += hub_to_destination

        fuel_solo = get_fuel_burned_during_cruise(
            origin_to_hub + hub_to_destination,
            model=model,
        )

        p('validate', 'Fuel burn solo = %d for %s' % (fuel_solo, aircraft))

        vars['fuel_actual'] += fuel_solo
Exemplo n.º 3
0
vars['origin_to_hub']          = 242
vars['origin_to_destination']  = 3193
vars['hookoff_to_destination'] = 0

vars['hub_to_hookoff']         = (
    vars['origin_to_destination'] -
    vars['origin_to_hub'] -
    vars['hookoff_to_destination']
)

vars['fuel_benchmark']         = 0
vars['fuel_formation']         = 0

p('validate', 'Getting the benchmark fuel')
vars['fuel_benchmark'] = vars['formation_size'] *\
    get_fuel_burned_during_cruise(vars['origin_to_destination'], model)
p('validate', 'OK, we have the benchmark fuel now')

incurs_benefit = False

for i in range(0, vars['formation_size']):
    
    model = copy.deepcopy(model)

    if incurs_benefit is True:
        discount = .13
    else:
        discount = 0
    
    vars['fuel_formation'] += (
        formationburn(
Exemplo n.º 4
0
vars['formation_size'] = 6
vars['origin_to_hub'] = 242
vars['origin_to_destination'] = 3193
vars['hookoff_to_destination'] = 0

vars['hub_to_hookoff'] = (vars['origin_to_destination'] -
                          vars['origin_to_hub'] -
                          vars['hookoff_to_destination'])

vars['fuel_benchmark'] = 0
vars['fuel_formation'] = 0

p('validate', 'Getting the benchmark fuel')
vars['fuel_benchmark'] = vars['formation_size'] *\
    get_fuel_burned_during_cruise(vars['origin_to_destination'], model)
p('validate', 'OK, we have the benchmark fuel now')

incurs_benefit = False

for i in range(0, vars['formation_size']):

    model = copy.deepcopy(model)

    if incurs_benefit is True:
        discount = .13
    else:
        discount = 0

    vars['fuel_formation'] += (formationburn(vars['origin_to_hub'],
                                             vars['hub_to_hookoff'],