Skip to main content
PREV CLASS NEXT CLASS FRAMES NO FRAMES

 

Class IloOplCplexBasis

IloObject
   |
   +--IloOplCplexBasis

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

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

See the CPLEX documentation for the methods IloCplex::getBasisStatuses and IloCplex::setBasisStatuses, or for CPXgetbasis and CPXcopybasis for details.

Example:
float maxOfx = ...;
dvar float x;

maximize x;
subject to {
  x<=maxOfx;
}
and the following data:
maxOfx=10;
Flow control script:
main {
  var basis= new IloOplCplexBasis();
  var source = new IloOplModelSource("basicmodel.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 ( !basis.getBasis(cplex) ) {
     writeln("warm start preparation failed: ",basis.status);
  } else {
     writeln("warm start preparation succeeded ");
  }
  var opl2 = new IloOplModel(def,cplex);
  var data2= new IloOplDataElements();
  data2.maxOfx=11;
  opl2.addDataSource(data2);
  opl2.generate();

  if ( !basis.setBasis(cplex) ) {
     writeln("warm start ",basis.Nrows,"x",basis.Ncols," failed: ",basis.status);
  } else {
     writeln("warm start ",basis.Nrows,"x",basis.Ncols," succeeded ");
  }

  if (cplex.solve()) {
     writeln("OBJ = " + cplex.getObjValue());
  } else {
     writeln("No solution");
  }

  opl.end();
  opl2.end();
  data.end();
  def.end();
  cplex.end();
  basis.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 currently stored basis.
flow control
Accesses the number of rows in the currently stored basis.
flow control
CPLEX status of last call.
Method Summary
Method Attributes Method Name and Description
flow control
attach(dvars, statuses)
Attaches a variable array to a status array.
flow control
getBasis(cplex)
Accesses this basis information from the given CPLEX instance.
flow control
setBasis(cplex)
Restores the basis information available from the given CPLEX instance.
Methods inherited from class IloObject
end
Constructor Detail
IloOplCplexBasis
IloOplCplexBasis()
Property Detail
Ncols
{int} Ncols
Accesses the number of columns in the currently stored basis.
Available for:
flow control

Nrows
{int} Nrows
Accesses the number of rows in the currently stored basis.
Available for:
flow control

status
{int} status
CPLEX status of last call.
Available for:
flow control
Method Detail
attach
attach(dvars, statuses)
Attaches a variable array to a status 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.
statuses - The array of values to get/set basis statuses.
Available for:
flow control

getBasis
{boolean} getBasis(cplex)
Accesses this basis information from the given CPLEX instance.
Parameters:
cplex - Sets the basis information to this instance of CPLEX.
Returns:
true if successful. The CPLEX return status is available as the property status.
Available for:
flow control

setBasis
setBasis(cplex)
Restores the basis information available from the given CPLEX instance. This utility can restore bases 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.
Parameters:
cplex - Restores this basis information on the given CPLEX instance.
Returns:
true if successful. The CPLEX return status is available as the property status.
Available for:
flow control

©Copyright IBM Corp. 1987-2011.