Concert Technology (IloCplex
) programs treat all models as capable of containing integer variables, and thus these variable declarations may be added or deleted at will. When extracting a model with integer variables, it will automatically detect it as a MIP and make the required adjustments to data structures.
However, the other ways of using ILOG CPLEX, the Callable Library and the Interactive Optimizer, require an explicit notion of a Problem Type to distinguish continuous LPs and QPs from MIPs. Techniques to determine the Problem Type with the Callable Library and the Interactive Optimizer are discussed in this topic.
When you enter a problem, ILOG CPLEX determines the Problem Type from the available information. If the problem is read from a file (LP
, MPS
, or SAV
format, for example), or entered interactively, the Problem Type is determined as follows:
However, if you enter a problem with no integer variables, so that its Problem Type is initially lp
or qp
, and you then wish to modify the problem to contain integer variables, this is accomplished by first changing the Problem Type to milp
or miqp
. Conversely, if you have entered an MILP or MIQP model and wish to remove all the integer declarations and thus convert the model to a continuous formulation, you can change the Problem Type to lp
or qp
. Note that deleting each of the integer variable declarations individually still leaves the Problem Type as milp
or miqp
, although in most instances the distinction between this problem and its lp
counterpart is somewhat arbitrary in terms of the steps that will be taken to solve it.
Thus, when using the Interactive Optimizer, you use the command change problem
with one of the following options:
- indicating that you want ILOG CPLEX to treat the problem as an MILP, or MIQP, respectively. This change in Problem Type makes the model ready for declaration of the integer variables via subsequent
change type
commands. If you change the problem to be an MIQP and there are not already quadratic terms in the objective function, an empty quadratic matrix is created, ready for populating via the change qpterm
command.
- indicating that you want all integer declarations removed from the variables in the problem. If you choose the
qp
problem type and there are not already quadratic terms in the objective function, an empty quadratic matrix is created, ready for populating via the change qpterm
command.
From the Callable Library, use the routine CPXchgprobtype
() to change the Problem Type to CPXPROB_MILP
or CPXPROB_MIQP
for the MILP and MIQP case respectively, and then assign integer declarations to the variables through the CPXcopyctype()
function. Conversely, remove all integer declarations from the problem by using CPXchgprobtype()
with Problem Type CPXPROB_LP
or CPXPROB_QP
.
At the end of a MIP optimization, the optimal values for the variables are directly available. However, you may wish to obtain information about the LP or QP associated with this optimal solution, for instance to know the reduced costs for the continuous variables of the problem at this solution. To do this, you will want to change the problem to be of type Fixed, either fixed_milp
or fixed_miqp
for the MILP or MIQP case respectively. The fixed MIP is the continuous problem in which the integer variables are fixed at the values they attained in the best integer solution. After changing the problem type, you can then call any of the continuous optimizers to re-optimize, and then display solution information for the continuous version of the problem. If you then wish to change the problem type back to the associated milp
or miqp
, you can do so without loss of information in the model.
The command change type
adds (or removes) the restriction on a variable that it must be an integer. In the Interactive Optimizer, when you enter the command change type
, the system prompts you to enter the variable that you want to change, and then it prompts you to enter the type (c
for continuous, b
for binary, i
for general integer, s
for semi-continuous, n
for semi-integer).
You can change a variable to binary even if its bounds are not 0 (zero) and 1 (one). However, in such a case, the system issues a warning message at optimization, and the optimization may terminate with a bound violation.
Consequently, in the example that we mentioned (see Sample: Stating a MIP Problem), if we want to make x4 a binary variable, we should first change the bounds on x4 to 0 and 1; then we can safely change its type to binary.
If you change a variable's type to be semi-continuous or semi-integer, be sure to create both a lower bound and an upper bound for it. These variable types specify that at an optimal solution the value for the variable must be either exactly zero or else be between the lower and upper bounds (and further subject to the restriction that the value be an integer, in the case of semi-integer variables).
By the way, a problem may be changed to a mixed integer problem, even if all its variables are continuous.