Loading the necessary structures

Lists the structures needed to manipulate models and data.

The structures you will use to manipulate models and data are listed in the following table.

Table 1. Scripting: structures to manipulate models and data
Name Role
IloOplModelDefinition Links to the.mod file representation of the model
IloOplDataSource Links to a .dat file representation of the data
IloCplex An instance of the CPLEX algorithm
IloOplModel A structure linking one model definition to (possibly) one or several data sources

See the Reference Manual of IBM ILOG Script Extensions for OPL for more information on these classes.

When a main block is executed, a variable called thisOplModel representing the IloOplModel instance is available by default. This variable links to the model definition that contains the main block currently executed and to the associated .dat files (if they exist) to run the model. The model definition uses IloOplModelSource instance that is initialized with the model name. There is also a variable called cplex which corresponds to an already created instance of the CPLEX algorithm.

If you want to run another model and/or use other data, you may create your own IloOplModel instance, like this:


var src = new IloOplModelSource("cutstock_sub.mod");
var def = new IloOplModelDefinition(src);
var opl2 = new IloOplModel(def,cplex);

To create a new data source using a different .dat file, you can write:


var data = new IloOplDataSource("mulprod.dat") 

Then, to link the IloOplModel instance to a new data source, write:


opl2.addDataSource(data);

In the mulprod_main example, you don't need to create all these structures since you want to use the already defined thisOplModel instance which corresponds to the model included in the mulprod_main.mod file.