Skip to main content
PREV CLASS NEXT CLASS FRAMES NO FRAMES

 

Class IloOplModel

IloOplModel

Description:

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

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

maximize x;
subject to {
  x<=maxOfx;
}
and the following data:
  maxOfx=10;
Flow control script:
main {
  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");
  }
  var opl2 = new IloOplModel(def,cplex);
  var data2= new IloOplDataElements();
  data2.maxOfx=11;
  opl2.addDataSource(data2);
  opl2.generate();

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

  opl.end();
  opl2.end();
  data.end();
  def.end();
  cplex.end();
  source.end();
}
Iterating properties:
Iterates on the OPL elements declared before the current execute or main block.
Index resolution:
Default behavior.
Available for:
flow control

Constructor Summary
Constructor Attributes Constructor Name and Description
 
IloOplModel(def, engine)
Uses the model definition def and the engine CPLEX or CP.
Property Summary
Field Attributes Field Name and Description
flow control and preprocessing
The default conflict iterator for this OPL model.
flow control
Data elements for this OPL model.
flow control
The model definition for this OPL model.
flow control and preprocessing
The default relaxation iterator for this OPL model.
all
Accesses the OPL settings for this model instance.
Method Summary
Method Attributes Method Name and Description
flow control
addDataSource(dataSource)
Adds a source for external data.
 
applyOpsSettings(path, file)
Applies the settings to OPL and the required engine.
flow control
Relaxes integer decision variables.
flow control
end()
Clears the memory used by this model.
flow control
Creates the model and extracts it.
flow control
Gets the objective.
flow control
Checks whether model is run in server mode.
flow control
Accesses a model for the CPLEX engine.
flow control
main()
Invokes the main scripting block of a model.
flow control
Postprocesses the model.
flow control
Prints the conflicting constraints found in an infeasible model.
flow control
Prints all the external data.
flow control
Prints all the internal data.
flow control
Prints the relaxations proposed to obtain a feasible model.
flow control
Prints the current solution values for all decision variables.
all
resolvePath(name)
Resolves a resource name as file path.
flow control
Sets which solution from the solution pool to use as the solution.
flow control
Undoes the relaxation of all integer decision variables.
Constructor Detail
IloOplModel
IloOplModel(def, engine)
Uses the model definition def and the engine CPLEX or CP. If the engine parameter is missing thisOplModel.cplex or thisOplModel.cp will be used.
Parameters:
def - Uses this model definition.
engine - Uses this engine, CPLEX or CP. Optional, if missing thisOplModel.cplex or thisOplModel.cp will be used.
Property Detail
conflictIterator
{IloOplConflictIterator} conflictIterator
The default conflict iterator for this OPL model.

The conflict iterator can be used to attach elements in order to control the conflict refinement.

Available for:
flow control and preprocessing

dataElements
{IloOplDataElements} dataElements
Data elements for this OPL model.

Data elements can be used to create more instances of IloOplModel with the same .dat files.

The caller is responsible for ending the returned object.

Example:

var data = thisOplModel.dataElements; //code that uses the data

data.end(); //cleans the memory used by the data elements

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

Available for:
flow control

modelDefinition
{IloOplModelDefinition} modelDefinition
The model definition for this OPL model.

The model definition can be used to create more instances of IloOplModel for the same .mod file. A data source cannot be reused for multiple models.

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

Available for:
flow control

relaxationIterator
{IloOplRelaxationIterator} relaxationIterator
The default relaxation iterator for this OPL model.

You can use the relaxation iterator to attach elements in order to control the relaxation.

Available for:
flow control and preprocessing

settings
{IloOplSettings} settings
Accesses the OPL settings for this model instance.
Available for:
all
Method Detail
addDataSource
addDataSource(dataSource)
Adds a source for external data.
Parameters:
dataSource - An instance of IloOplDataSource or IloOplDataElements.
Available for:
flow control

applyOpsSettings
{void} applyOpsSettings(path, file)
Applies the settings to OPL and the required engine. For example: oplModel.applyOpsSettings(null, "c:/temp/mytrans.ops"); Or: oplModel.applyOpsSettings("c:/temp/", "mytrans.ops");
Parameters:
path - Base directory or null
file - OPS file name or OPS full path

convertAllIntVars
convertAllIntVars()
Relaxes integer decision variables.
Available for:
flow control

end
end()
Clears the memory used by this model.
Available for:
flow control

generate
generate()
Creates the model and extracts it.
Available for:
flow control

getObjective
{IloObjective} getObjective()
Gets the objective.
Returns:
The objective.
Available for:
flow control

isRunOnServer
{boolean} isRunOnServer()
Checks whether model is run in server mode.
Returns:
true if this model is run on a server
Available for:
flow control

isUsingCplex
{boolean} isUsingCplex()
Accesses a model for the CPLEX engine.
Returns:
true if this model is using CPLEX.
Available for:
flow control

main
{int} main()
Invokes the main scripting block of a model.
Returns:
The status.
Available for:
flow control

postProcess
postProcess()
Postprocesses the model.
Available for:
flow control

printConflict
{string} printConflict()
Prints the conflicting constraints found in an infeasible model.

See the note about conflict computation and caching in the documentation of IloOplConflictIterator.

Returns:
The string containing the conflicting constraints found in an infeasible model.
Available for:
flow control

printExternalData
{string} printExternalData(title)
Prints all the external data.

The output is a valid .dat file.

Parameters:
title - optional
Returns:
The string containing all the external data.
Available for:
flow control

printInternalData
{string} printInternalData(title)
Prints all the internal data.

The output is a valid .dat file.

Parameters:
{string} title - optional
Returns:
The string containing all the internal data.
Available for:
flow control

printRelaxation
{string} printRelaxation()
Prints the relaxations proposed to obtain a feasible model.

See the note about relaxation computation and caching in the documentation of IloOplRelaxationIterator.

Returns:
A string containing the relaxations proposed to obtain a feasible model and changes the state of the invoking object to relaxation mode.
Available for:
flow control

printSolution
{string} printSolution()
Prints the current solution values for all decision variables.

The output is a valid .dat file.

Returns:
The string containing the current solution values for all decision variables.
Available for:
flow control

resolvePath
{string} resolvePath(name)
Resolves a resource name as file path.

Relative paths are resolved relative to this OPL model.

Parameters:
name - The resource name.
Returns:
The resolved path.
Available for:
all

setPoolSolution
setPoolSolution(i)
Sets which solution from the solution pool to use as the solution. This method works only if the embedded algorithm had been collecting a pool of solutions. If the value of the identifier, i, is higher than the available number of solutions in the pool, the method does nothing and returns false. If i is negative, the model is returned to the default solution state.
Parameters:
i - The identifier of the solution to use.
Available for:
flow control

unconvertAllIntVars
unconvertAllIntVars()
Undoes the relaxation of all integer decision variables.
Available for:
flow control

©Copyright IBM Corp. 1987-2011.