In OPL You can write
range R = 0..2;
dvar int x[R] in 0..40;
maximize
x[0] + 2 * x[1] + 10 * x[2]
- 0.5 * ( 33 * x[0]^2 + 22 * x[1]^2 + 11 * x[2]^2
- 12 * x[0] * x[1] - 23 *x [1] * x[2] );
subject to {
ct1: - x[0] + x[1] + x[2] <= 20;
ct2: x[0] - 3 * x[1] + x[2] <= 30;
ct3: x[0]^2 + x[1]^2 + x[2]^2 <= 10.0;
}
tuple xSolutionT{
int R;
float value;
};
{xSolutionT} xSolution = {<i0,x[i0]> | i0 in R};
execute{
writeln(xSolution);
}
which you can rewrite with docplex into
from docplex.mp.model import Model
mdl = Model(name='miqcp')
x=[mdl.integer_var(0,40,name="x"+str(i)) for i in range(0,3)]
mdl.add(- x[0] + x[1] + x[2] <= 20)
mdl.add(x[0] - 3 * x[1] + x[2] <= 30)
mdl.add(x[0]**2 + x[1]**2 + x[2]**2 <= 10.0)
mdl.maximize(x[0] + 2 * x[1] + 10 * x[2] - 0.5 * ( 33 * x[0]**2 \
+ 22 * x[1]**2 + 11 * x[2]**2 - 12 * x[0] * x[1] - 23 *x [1] * x[2] ))
mdl.solve()
for i in range(0,3):
print(x[i].name," = ",x[i].solution_value)
add_quadratic_constraints
method. You can chceck them all in docplex documentation $\endgroup$