3
$\begingroup$

I have a MILP model with continuous variables ($y_{ij}$) and binaries ($x_{ij}$). I am using Java and cplex 12.8 for implementation.

Is there a way by which - using the Java-cplex API - I would be able to write only one model that can be solved first with the binary $x_{ij}$'s and then for the continuous variables ($0 \leq x_{ij} \leq 1$)? I want to see the gap between LP-R and MIP on the fly - and don't want to build two different LP and MILP models.

$\endgroup$
2
$\begingroup$

The type of a variable cannot be changed. However, it can be overwritten for a particular model by adding an IloConversion object, which allows you to specify new types for variables within that model. When ILOG CPLEX finds a conversion object in the active model, it uses the variable types specified in the conversion object instead of the original type specified for the optimization. For example in a model containing:

IloNumVar x = cplex.numVar(0.0, 1.0);   
cplex.add(cplex.conversion(x, IloNumVarType.Int));
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.