IBM ILOG Solver User's Manual > Extending the Library > Extraction Concepts > Main rule of extraction: 1 to 1 correspondence

The main rule of extraction is that there is a 1 to 1 correspondence between extractables and Solver objects. This means that, for each Ilo object, there will be one corresponding Ilc object. This rule has two exceptions that will be described in the next section.

Let's go through the extraction mechanism.

When an instance of IloSolver extracts a model, it iterates over each object added to the model. For each of these objects, it starts extracting them. This mechanism is recursive in the sense that the extraction of an object may lead to the extraction of another object.

The following code example illustrates this process. Here's the code to be extracted:

IloEnv env;
IloIntVar a1(env, 0, 3);
IloIntVar a2(env, 0, 3);
IloModel model(env);
model.add(a1 < a2);
IloSolver solver(model);

In the last line, an instance of IloSolver extracts model. First, it takes the range constraint a1 < a2 and starts extracting it. In order to extract the range constraint, it extracts the two variables a1 and a2. The extraction of these variables creates two IlcIntVar objects: ca1 and ca2. Then, the extraction of the range constraint continues. The instance of IloSolver takes the two IlcIntVar objects and creates the equivalent Ilc constraint: ca1 < ca2. This inequality constraint is then added to the instance of IloSolver.

The extraction will create the following Ilc code

IlcIntVar ca1(solver, 0, 3);
IlcIntVar ca2(solver, 0, 3);
solver.add(ca1 < ca2);

The extraction process can be summarized in the following way. During extraction, an instance of IloSolver will iterate over the model, and extract each element one after another. The extraction of an extractable involves the extraction of each of its subextractables. Given an Ilo object, all subextractable Ilo objects are extracted into Ilc objects. An Ilc object is then built that is the extraction of the original Ilo object.