Пример #1
0
    def __init__(self,
                 num_flights=50,
                 num_airlines=5,
                 triples=True,
                 reduction_factor=100,
                 discretisation_size=50,
                 custom_schedule=None,
                 df=None,
                 xp_problem=None):
        scheduleTypes = scheduleMaker.schedule_types(show=False)
        # init variables, schedule and cost function
        if custom_schedule is None and df is None:
            schedule_df = scheduleMaker.df_maker(num_flights,
                                                 num_airlines,
                                                 distribution=scheduleTypes[0])
        else:
            if df is None:
                schedule_df = scheduleMaker.df_maker(custom=custom_schedule)
            else:
                schedule_df = df

        self.reductionFactor = reduction_factor
        self.costFun = CostFuns().costFun["realistic"]
        self.flightTypeDict = CostFuns().flightTypeDict
        self.discretisationSize = discretisation_size

        if xp_problem is None:
            self.xp_problem = xp.problem()
        else:
            self.xp_problem = xp_problem
        with HiddenPrints():
            self.xp_problem.reset()

        # internal optimisation step
        udpp_model_xp = udppModel.UDPPmodel(schedule_df, self.costFun,
                                            self.xp_problem)
        udpp_model_xp.run()

        with HiddenPrints():
            self.xp_problem.reset()

        super().__init__(udpp_model_xp.get_new_df(),
                         self.costFun,
                         triples=triples,
                         xp_problem=self.xp_problem)
        flights = [flight for flight in self.flights]

        for flight in self.flights:
            flights[flight.slot.index] = flight
        self.flights = flights

        self.set_flights_input_net(self.discretisationSize)

        self.offerChecker = checkOffer.OfferChecker(self.scheduleMatrix)
        _, self.matches_vect = self.offerChecker.all_couples_check(
            self.airlines_pairs)
        self.reverseAirDict = dict(
            zip(list(self.airDict.keys()), list(self.airDict.values())))
from NoNegativeBound import nnBound
from Old_RL import old_rl
from ModelStructure.ScheduleMaker import scheduleMaker
from ModelStructure.Costs.costFunctionDict import CostFuns
from ModelStructure.Slot.slot import Slot
from Istop.AirlineAndFlight.istopAirline import IstopAirline
from Istop.AirlineAndFlight.istopFlight import IstopFlight
import numpy as np
import time
import pandas as pd

airline: IstopAirline
flight: IstopFlight

np.random.seed(0)
scheduleTypes = scheduleMaker.schedule_types(show=True)

# init variables, chedule and cost function
num_flights = 3
num_airlines = 4
# schedule_df = scheduleMaker.df_maker(num_flights, num_airlines, distribution=scheduleTypes[0])

schedule_df = scheduleMaker.df_maker(
    custom=[num_flights for _ in range(num_airlines)])
schedule_df.to_csv("custom_" + str(num_airlines) + "_" + str(num_flights) +
                   ".csv")
# schedule_df_1 = pd.read_csv("custom_5_5.csv")
# print(schedule_df["type"]==schedule_df_1["type"])
cost_fun = CostFuns().costFun["realistic"]

# create model
Пример #3
0
from ModelStructure.ScheduleMaker import scheduleMaker
from UDPP.udppModel import UDPPmodel
from ModelStructure.Costs.costFunctionDict import CostFuns
import pandas as pd

final_df: pd.DataFrame

costFun = CostFuns().costFun["step"]

final_df = pd.DataFrame(columns=["instance", "airline", "margins", "priority", "eta", "slot", "new slot"])
scheduleType = scheduleMaker.schedule_types(show=False)

for i in range(5000):
    df = scheduleMaker.df_maker(50, 4, distribution=scheduleType[0])
    udMod = UDPPmodel(df, costFun)
    udMod.run(optimised=True)
    for airline in udMod.airlines:
        for flight in airline.flights:
            to_append = [i, flight.airline, flight.margin, flight.priority, flight.eta, flight.slot.time,
                         flight.newSlot.time]
            a_series = pd.Series(to_append, index=final_df.columns)
            final_df = final_df.append(a_series, ignore_index=True)

    if i % 50 ==0:
        print(i)

# standardisation
for col in final_df.columns[2:-1]:
    final_df[col] = (final_df[col] - final_df[col].mean()) / final_df[col].std()

final_df.to_csv("50_4_increase.csv")