6.6 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.6.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.2 (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.
The complete source for the example is listed in Listing 11.
Please note that compared to a linear optimization problem with no integer-constrained variables:
prob.ints.subfield is used to specify the indexes of the variables that are integer-constrained.
- The optimal integer solution is returned in the
MOSEK also provides a wrapper for the
intlinprog function found in the MATLAB optimization toolbox. This function solves linear problems wth integer variables; see the reference section for details.
6.6.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
MSK_IPAR_MIO_CONSTRUCT_SOL parameter to
"MSK_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.
function mioinitsol() [r,res] = mosekopt('symbcon'); sc = res.symbcon; clear prob prob.c = [7 10 1 5]; prob.a = sparse([1 1 1 1 ]); prob.blc = -[inf]; prob.buc = [2.5]; prob.blx = [0 0 0 0]; prob.bux = [inf inf inf inf]; prob.ints.sub = [1 2 3]; % Values for the integer variables are specified. prob.sol.int.xx = [0 2 0 0]'; % Tell Mosek to construct a feasible solution from a given integer % value. param.MSK_IPAR_MIO_CONSTRUCT_SOL = sc.MSK_ON; [r,res] = mosekopt('maximize',prob,param); try % Display the optimal solution. res.sol.int.xx' catch fprintf('MSKERROR: Could not get solution') end