Bay reservation for flights

2019-08-30 16:48发布

问题:

I'm developing a algorithm to reserve bays for flights in a given airport. I have modeled this problem as follows,

I have set of flights:

flight_names = ['MI428', 'UL867', 'QR664', 'TK730', 'UL303']

Here each flight is associated with airplane type and each bay has compatibility list of airplanes that the bay only can reserve for. So that is my first constraint. It can be listed as below.

bay_compat = {'MI428': ['A1', 'A2', 'B1'], 'UL867': ['B1', 'B2'], 'QR664': ['A2', 'B1', 'B2'], 'TK730': ['C1', 'A1'],
              'UL303': ['B2', 'C1']}

Note: In above set, for ease of understanding I directly mapped flight id with compatibility list, rather than mapping through airplane type which corresponds to flight.

My second constraint is 'arrival time' and 'departure time' for flights. Each flight has arrival time and departure time so that within that time interval plane corresponding to that flight will stayed at assigned bay. Example data structure which I used for representing this as follows,

time_constraints = {'MI428':(1,3) , 'UL867':(4,7), 'QR664':(8,9), 'TK730':(15,16), 'UL303':(16,17)}

In above tuple list, first number is arrival time and second is departure time.

So my final goal is to develop a program which can assign bays for given flight names with corresponding constraint data as mentioned in the description. In other words, I need to assign bay for each flight such that I will not get any conflict on a bay and without violating bay compatibility constraints. Can anyone suggest me a way to implement this python??