FRAMES NO FRAMES

Lazy Copy
PREVIOUS NEXT

Concert Technology makes a lazy copy when you use any of the following objects inside a predefined Concert Technology object:

That is, a physical copy of those objects is created only when needed.

In Concert Technology, expressions, columns, and sets are implemented by handle classes and corresponding implementation classes. One or more handles may point to the same implementation object. For example, many instances of the handle class IloNumColumn may point to the same implementation object.

A handle may be empty; that is, it may point to 0 (zero). You can test whether a handle is empty by means of the member function handle.getImpl. If that member function returns 0, the handle points to a null implementation.

When you modify an expression, a column, or a set that has been used in a Concert Technology object, Concert Technology considers whether the handle you are modifying is the sole reference to the corresponding implementation object. If so, Concert Technology simply makes the modification.

In contrast, if the handle you are modifying points to an implementation object that is used by other objects predefined in Concert Technology, Concert Technology first copies the implementation object for the handle you are modifying and then makes the modification. The other handles pointing to the original implementation object remain unchanged and your modification has no impact on them.

Examples:

Here is an example illustrating lazy copy of variables:

  IloEnv env;
  IloIntVar a1(env, 0, 10);
  IloIntVar a2(env, 0, 10); 
  IloIntVar a3(env, 0, 10);
  IloExpr e = a1+ a2;;
  IloConstraint ct = e <= 10;
  e += a3;
  return 0;
  

Because of the lazy copy, even though a3 was added to A, ct uses only a1 and a2.

PREVIOUS NEXT