Quickstart

[ ]:
from mqt.qao import Constraints, ObjectiveFunction, Problem, Solver, Variables

Declare the variables of the problem

[ ]:
var = Variables()
a = var.add_binary_variable("a")
b = var.add_discrete_variable("b", [-1, 1, 3])
c = var.add_continuous_variable("c", -2, 2, 0.25)

Declare the objective functions

[ ]:
obj_func = ObjectiveFunction()
obj_func.add_objective_function(a + b * c + c**2)

Declare the constraints

[ ]:
cst = Constraints()
cst.add_constraint("b + c >= 2", variable_precision=True)

Declaration of the problem

[ ]:
prb = Problem()
prb.create_problem(var, cst, obj_func)

Solve with Simulated Annealing

[ ]:
solution = Solver().solve_simulated_annealing(prb)