IloOplModel
See the Overview for a general presentation of the ILOG Script extensions for OPL.
float maxOfx = ...;
dvar float x;
maximize x;
subject to {
x<=maxOfx;
}maxOfx=10;
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();
}execute or main block.| Constructor Attributes | Constructor Name and Description |
|---|---|
|
IloOplModel(def, engine)
Uses the model definition
def and the engine CPLEX or CP. |
| 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 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 |
generate()
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 |
printExternalData(title)
Prints all the external data.
|
| flow control |
printInternalData(title)
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.
|
def and the engine CPLEX or CP.
If the engine parameter is missing thisOplModel.cplex or thisOplModel.cp will be used.thisOplModel.cplex or thisOplModel.cp will be used.
The conflict iterator can be used to attach elements in order to control the conflict refinement.
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.
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.
You can use the relaxation iterator to attach elements in order to control the relaxation.
IloOplDataSource or IloOplDataElements.
oplModel.applyOpsSettings(null, "c:/temp/mytrans.ops");
Or: oplModel.applyOpsSettings("c:/temp/", "mytrans.ops");
true if this model is run on a servertrue if this model is using CPLEX.See the note about conflict computation and caching in the documentation
of IloOplConflictIterator.
The output is a valid .dat file.
The output is a valid .dat file.
See the note about relaxation computation and caching in the documentation
of IloOplRelaxationIterator.
The output is a valid .dat file.
Relative paths are resolved relative to this OPL model.
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.