Skip to main content
PREV CLASS NEXT CLASS FRAMES NO FRAMES

 

Class IloOplCplexVectors

IloObject
   |
   +--IloOplCplexVectors

Description:
This is an OPL service class provided to support the CPLEX warm start functionality for mixed integer programming models.

See the Overview for a general presentation of the ILOG Script extensions for OPL.

See the CPLEX documentation for the methods IloCplex::getStart and IloCplex::setStart or for CPXgetmipstart, CPXcopymipstart for details.

Example:
For the following basic model:
int maxOfx = ...;
dvar int x;

maximize x;
subject to {
  x<=maxOfx; 
  }
and the following data:
maxOfx=10;
Flow control script:
main {   
  var vectors= new IloOplCplexVectors();
  var source = new IloOplModelSource("basicmodel2.mod");
  var cplex = new IloCplex();
  var def = new IloOplModelDefinition(source);
  var opl = new IloOplModel(def,cplex);
  var data = new IloOplDataSource("basicmodel.dat");
  opl.addDataSource(data);
  opl.generate();
  if (cplex.solve()) {
     writeln("OBJ = " + cplex.getObjValue());
  } else {
     writeln("No solution");
  }
  if ( !vectors.getStart(cplex) ) {
     writeln("warm start preparation failed: ",vectors.status);
  } else {
     writeln("warm start preparation successful ");
  }
  var opl2 = new IloOplModel(def,cplex);
  var data2= new IloOplDataElements();
  data2.maxOfx=11;
  opl2.addDataSource(data2);
  opl2.generate();
  if ( !vectors.setStart(cplex) ) {
     writeln("warm start ",vectors.Nrows,"x",vectors.Ncols," failed: ",vectors.status);
  } else {
     writeln("warm start ",vectors.Nrows,"x",vectors.Ncols," succeeded ");
  }
  if (cplex.solve()) {
     writeln("OBJ = " + cplex.getObjValue());
  } else {
     writeln("No solution");
  }
  opl.end();
  opl2.end();
  data.end(); 
  def.end(); 
  cplex.end(); 
  vectors.end();
  source.end(); 
}
After execution the Scripting log shows:
 OBJ = 10
 warm start preparation succeeded
 warm start 1x2 succeeded
 OBJ = 11
Iterating properties:
Default behavior.
Index resolution:
Default behavior.
Available for:
flow control

Constructor Summary
Constructor Attributes Constructor Name and Description
 
Property Summary
Field Attributes Field Name and Description
flow control
Accesses the number of columns in the CPLEX matrix from which the warm start information has been taken.
flow control
Accesses the number of rows in the CPLEX matrix from which the vectors have been taken.
flow control
The CPLEX status of the last call.
Method Summary
Method Attributes Method Name and Description
flow control
attach(dvars, values)
Attaches a variable array to a value array.
flow control
clear()
Clears the vector from either all the previous attach commands or the getStart call.
flow control
deleteStart(cplex)
Deletes the MIP start information for the given CPLEX instance.
flow control
getStart(cplex)
Saves the MIP start information for the given CPLEX instance.
flow control
setStart(cplex)
Restores the MIP start information available for the given CPLEX instance.
Methods inherited from class IloObject
end
Constructor Detail
IloOplCplexVectors
IloOplCplexVectors()
Property Detail
Ncols
{int} Ncols
Accesses the number of columns in the CPLEX matrix from which the warm start information has been taken. OPL uses this information when restoring the warm start information.
Available for:
flow control

Nrows
{int} Nrows
Accesses the number of rows in the CPLEX matrix from which the vectors have been taken. OPL uses this information when restoring the warm start information.
Available for:
flow control

status
{int} status
The CPLEX status of the last call.
Available for:
flow control
Method Detail
attach
attach(dvars, values)
Attaches a variable array to a value array. Once attachments exist, only the elements with attachments are taken into account to get/set the basis.
Parameters:
dvars - The array of variables to consider.
values - The array of values to get/set.
Available for:
flow control

clear
{void} clear()
Clears the vector from either all the previous attach commands or the getStart call.
Available for:
flow control

deleteStart
{void} deleteStart(cplex)
Deletes the MIP start information for the given CPLEX instance.
Parameters:
cplex - Saves the MIP start information for this instance of CPLEX.
Available for:
flow control

getStart
{boolean} getStart(cplex)
Saves the MIP start information for the given CPLEX instance.
Parameters:
cplex - Saves the MIP start information for this instance of CPLEX.
Returns:
true if successful. The CPLEX return status is available as the property status.
Available for:
flow control

setStart
setStart(cplex)
Restores the MIP start information available for the given CPLEX instance. This utility can restore MIP start only if the problem of the given CPLEX instance has exactly the same number of rows and columns as the problem it was taken from. In order to set variable values, the function looks up variables by name, so the variables that were used to set values in the vector must have the same names as variables in the cplex object. Depending on the success the function returns with a different value and sets the status field of the invoking instance to a different value:
return valuestatusmeaning
true0All starting information set successfully.
true1219 (CPXERR_NO_NAMES) The variables in cplex have no names, no starting information was set.
true1210 (CPXERR_NAME_NOT_FOUND) At least one variable/value pair could not be set since a variable of that name was not found in cplex. Other variables may have been set correctly.
falseTypically non-zero Something else went wrong.
Parameters:
cplex - Restores the MIP start information available for this instance of CPLEX.
Returns:
true if successful. The CPLEX return status is available as the property status.
Available for:
flow control

©Copyright IBM Corp. 1987-2011.