Originally posted by: SystemAdmin
[prubin said:]
If you are using Concert, you can add an IloConversion object that relaxes your integer variables to floats, solve the model (which is now an LP), then remove the conversion to get back to the original problem. If you have more than one integer variable (or more than one array of integer variables), you'll have to add multiple conversions. For instance (using Java, and skipping the throw/catch stuff):
IloCplex myModel = new IloCplex();
IloIntVar[] x = myModel.intVarArray(...); // general integer variables
IloBoolVar[] y = myModel.boolVarArray(...); // binary variables
IloNumVar[] z = myModel.numVarArray(...); // real variables
// build the model
IloConversion xconv = myModel.conversion(x, IloNumVarType.Float); // relax the general integers
IloConversion yconv = myModel.conversion(y, IloNumVarType.Float); // and the binaries
myModel.add(xconv);
myModel.add(yconv);
myModel.solve(); // solving the LP relaxation
// get the solution and do perverse things with it
myModel.remove(xconv); // unrelax the model
myModel.remove(yconv);
Note that you need to hang onto the conversion objects (by assigning them to variables) so that you can zap them when you're through with the LP relaxation.
In <shudder>C++</shudder>, I think you would use the IloConversion's end() method to get rid of it, although I suspect the remove method would also work.
/Paul
#CPLEXOptimizers#DecisionOptimization