Airplane landing problem
Brief description
We consider a single plane’s landing runway. Given a set of planes with given target landing time, the objective is to minimize the total weighted deviation from the target landing time for each plane.
There are costs associated with landing either earlier or later than the target landing time for each plane.
Each plane has to land within its predetermined time window. For each pair of planes, there is an additional constraint to enforce that the separation time between those planes is larger than a given number.
CFN model
We create N variables, one for each plane, with domain value equal to all their possible landing time.
Binary hard cost functions express separation times between pairs of planes. Unary soft cost functions represent the weighted deviation for each plane.
Data
Original data files can be download from the cost function library airland. Their format is described here. You can try a small example airland1.txt
with optimum value equal to 700.
Python model solver
The following code uses the pytoulbar2 module to generate the cost function network and solve it (e.g. “python3 airland.py airland1.txt”).
import sys
import pytoulbar2
f = open(sys.argv[1], 'r').readlines()
tokens = []
for l in f:
tokens += l.split()
pos = 0
def token():
global pos, tokens
if (pos == len(tokens)):
return None
s = tokens[pos]
pos += 1
return int(float(s))
N = token()
token() # skip freeze time
LT = []
PC = []
ST = []
for i in range(N):
token() # skip appearance time
# Times per plane: {earliest landing time, target landing time, latest landing time}
LT.append([token(), token(), token()])
# Penalty cost per unit of time per plane:
# [for landing before target, after target]
PC.append([token(), token()])
# Separation time required after i lands before j can land
ST.append([token() for j in range(N)])
top = 99999
Problem = pytoulbar2.CFN(top)
for i in range(N):
Problem.AddVariable('x' + str(i), range(LT[i][0],LT[i][2]+1))
for i in range(N):
ListCost = []
for a in range(LT[i][0], LT[i][2]+1):
if a < LT[i][1]:
ListCost.append(PC[i][0]*(LT[i][1] - a))
else:
ListCost.append(PC[i][1]*(a - LT[i][1]))
Problem.AddFunction([i], ListCost)
for i in range(N):
for j in range(i+1,N):
Constraint = []
for a in range(LT[i][0], LT[i][2]+1):
for b in range(LT[j][0], LT[j][2]+1):
if a+ST[i][j]>b and b+ST[j][i]>a:
Constraint.append(top)
else:
Constraint.append(0)
Problem.AddFunction([i, j],Constraint)
#Problem.Dump('airplane.cfn')
Problem.NoPreprocessing()
Problem.Solve(showSolutions = 3)