Exemple #1
0
def check_aircraft_model(filepath, newfilename):
    data = excel_reader.read_from_schedule(filepath)
    aircraft_data = excel_reader.read_from_aircraft('./data/Aircrafts.xlsx')
    for line in data:
        for aircraft in aircraft_data:
            if line.plane_tail_number == aircraft.tail_number and line.plane_type != aircraft.type_number:
                line.plane_type = aircraft.type_number
                print('error detected.')
    excel_writer.write_schedule(data, newfilename)
Exemple #2
0
                route_arr[j - 1].delay_time)
            if wait_time < minimum_idle_time():
                tmp_delay = minimum_idle_time() - wait_time
                route_arr[j].delay_time += tmp_delay
                total_delay += tmp_delay
                arr = tail_num_2_total_delayed_airlines_count.get(tail_num, [])
                arr.append(route_arr[j])
                tail_num_2_total_delayed_airlines_count[tail_num] = arr

    # Step 3,现在对于每一个受到连带影响的航班,对于所有其他飞机,寻求替代可能性。
    for arr in tail_num_2_total_delayed_airlines_count.values():
        second_affected_airline = arr[0]
        tail_num = second_affected_airline.plane_tail_number
        for airline in first_delay_airline_set:
            if airline.plane_tail_number == tail_num:
                land_time = airline.arrive_time_stamp + airline.delay_time
                land_port = airline.arrive_airport
                # now we need to find the other aircrafts at land_port at land_time, that is free to fly.
                for key_tail_num in Map.keys():
                    if not tail_num == key_tail_num:
                        route_arr = Map.get(key_tail_num)
                        for route_arr_airline in route_arr:
                            if route_arr_airline.arrive_airport == land_port and route_arr_airline.arrive_time_stamp < land_time:
                                try_swap_routes(arr, route_arr, airline,
                                                route_arr_airline)
                                break
                break
    import excel_writer as writer_tool
    writer_tool.write_schedule(schedule, 'solution2.xls')
    print('task success.')
    # for time in range(start_time, end_time, 600):
    # solve_current_situation(time, schedule, air_crafts)
    count = 0
    total_delay = 0
    for tmp in schedule:
        if tmp.arrive_airport == 'OVS' and is_time_ovs_closed(
                tmp.arrive_time_stamp) or tmp.depart_airport == 'OVS' and is_time_ovs_closed(tmp.depart_time_stamp):
            total_delay += delay_airline(schedule, tmp)
            count += 1
            continue
    print(count)
    # print('total delay ', total_delay)


    total_delay += solve_maintainence_balance(schedule)
    # print('total delay ', total_delay)


    depart_set, arrive_set = solve_max_capacity_problem(schedule)
    # print(depart_set)
    # print(arrive_set)
    excel_writer.write_schedule(schedule)

    sum = 0
    for line in schedule:
        sum += line.delay_time

    print(sum)