7.4 Integer Optimization¶
An optimization problem where one or more of the variables are constrained to integer values is called a (mixed) integer optimization problem. MOSEK supports integer variables in combination with linear and conic quadratic problems. See the previous tutorials for an introduction to how to model these types of problems.
7.4.1 Example MILO1¶
We use the example
to demonstrate how to set up and solve a problem with integer variables. It has the structure of a linear optimization problem (see Sec. 7.1 (Linear Optimization)) except for integrality constraints on the variables. Therefore, only the specification of the integer constraints requires something new compared to the linear optimization problem discussed previously.
First, the integrality constraints are imposed by modifying any existing domain with
x = M.variable('x', 2, Domain.integral(Domain.greaterThan(0.0)))
Next, the example demonstrates how to set various useful parameters of the mixed-integer optimizer. See Sec. 13 (The Optimizer for Mixed-integer Problems) for details.
# Set max solution time M.setSolverParam('mioMaxTime', 60.0) # Set max relative gap (to its default value) M.setSolverParam('mioTolRelGap', 1e-4) # Set max absolute gap (to its default value) M.setSolverParam('mioTolAbsGap', 0.0)
The complete source for the example is listed in Listing 6.
7.4.2 Specifying an initial solution¶
Solution time of can often be reduced by providing an initial solution for the solver. It is not necessary to specify the whole solution. By setting the
mioConstructSol parameter to
"on" and inputting values for the integer variables only, MOSEK will be forced to compute the remaining continuous variable values. If the specified integer solution is infeasible or incomplete, MOSEK will simply ignore it.
We concentrate on a simple example below.
We initialize the mixed-integer optimizer with a feasible starting point \((x_0,x_1,x_2,x_3)=(0,2,0,0)\) using the method
init_sol = [0.0, 2.0, 0.0, 0.0] x.setLevel(init_sol)
The complete code is not very different from the first example and is available for download as
mioinitsol.py. For more details about this process see Sec. 13 (The Optimizer for Mixed-integer Problems). An more advanced application of
Variable.setLevel is presented in the case study on Multiprocessor scheduling.