Implementation of the solution to the Airbus Quantum Challenge 2020 aircraft loading problem proposed
in Aircraft Loading Optimization -- QUBO models under multiple constraints.
The optimization process can be run on both a simulated annealer and real D-Wave solver.
The current implementation lacks an effective strategy to tune the coefficients so a lot of runs are required.
- Install requirements
pip install -r requirements.txt
- [Optional] Install the D-Wave inspector
dwave install inspector
- [Optional] Create an account at D-Wave Leap
- [Optional] Take your API key then run
dwave config create
- Run
python main.py
Optional steps are required only to use the QPU solvers.
To change the aircraft data create an AircraftData
object and a shear curve. Two functions are provided to create symmetric and asymmetric linear curves.
shear_curve = get_linear_shear_curve(4, 26000)
acft = AircraftData(num_positions=4, payloa_area_length=40, max_payload=8000, shear_curve=shear_curve, min_cg=-0.1, max_cg=0.2)
To change the problem requirements first define the container types and masses as lists.
Each point of the shear curve must correspond to a container position with the center elements representing the central position left and right shears.
cont_types = np.array(['t1', 't1', 't1', 't1', 't1', 't1'])
cont_masses = np.array([2134, 3455, 1866, 1699, 3500, 3332])
Define the penalty functions coefficients as a dict
coefs = {'pl_o': 1.0,
'pl_w': 1.0,
'pl_d': 1.0,
'pl_c': 1.0,
'cl_u': 1.0,
'cl_l': 1.0,
'cl_t': 1.0,
'sl_l': 1.0,
'sl_r': 1.0}
Finally create a new LoadingProblem
and set its coefficients
problem = LoadingProblem(acft, cont_types, cont_masses, 0.1, 120000, -0.05)
problem.coefficients = coefs
Constraints can be enabled or disabled individually
problem.disable_constraints({'sl'})
problem.enable_constraints({'sl'})
By default only the payload constraints are enabled
Two methods are provided to tune the coefficients automatically for a give problem.
problem.coefficients = tune_coefs_average(problem)
This method uses the average values of each penalty BQM
problem.coefficients = tune_coefs_iterative(problem)
This method increases the coefficients iteratively until the penalty and objective functions have the same order of magnitude. The increase step can be customized.
The LoadingProblem
class allows to get the BQM representation of each constraint as well as the total problem to
pass to the solver. For example to create a BQM to pass to the solvers use
bqm = problem.get_bqm()
The plot functions assume feasible solutions so first parse the solver results then remove the unfeasible solutoins. The
plot the top k solutions.
cont_occ_solutions = problem.parse_solution(result)
cont_occ_solutions = problem.filter_solutions(cont_occ_solutions)
plot_top_solutions(problem, cont_occ_solutions, 1)
Plots will be saved in the out
directory.
- Payload constraints
- CG constraints
- Shear constraints
- Improve coefficient tuning. This should increase the ratio of feasible solutions found by the solvers
- Try hybrid solvers