6.5 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.
6.5.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. 6.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 using the function
for (int j = 0; j < numvar; ++j) task.putvartype(j, mosek.variabletype.type_int);
Next, the example demonstrates how to set various useful parameters of the mixed-integer optimizer. See Sec. 14 (The Optimizer for Mixed-integer Problems) for details.
/* Set max solution time */ task.putdouparam(mosek.dparam.mio_max_time, 60.0);
The complete source for the example is listed Listing 9. Please note that when
Task.getsolutionslice is called, the integer solution is requested by using
soltype.itg. No dual solution is defined for integer optimization problems.
6.5.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
iparam.mio_construct_sol parameter to
onoffkey.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.
Solution values can be set using
Task.putxxslice and related methods.
// Construct an initial feasible solution from the // values of the integer valuse specified task.putintparam(mosek.iparam.mio_construct_sol, mosek.onoffkey.on.value); // Assign values 0,2,0 to integer variables task.putxxslice(mosek.soltype.itg, 0, 3, intxx);
The complete code is not very different from the first example and is available for download as
mioinitsol.java. For more details about this process see Sec. 14 (The Optimizer for Mixed-integer Problems).