IBM ILOG Solver User's Manual > Extending the Library > Writing a Constraint: Allocating Frequencies > Writing your own constraint > Using ILOCPCONSTRAINTWRAPPER to wrap constraints

You can use the macro ILOCPCONSTRAINTWRAPPER to wrap an existing instance of IlcConstraint when you want to use it within Concert Technology model objects.

This macro defines a constraint class named _thisI with n data members. When n is greater than zero, the types and names of the data members must be supplied as arguments to the macro. Each data member is defined by its type ti and a name ai.

  ILOCPCONSTRAINTWRAPPER0(_this, solver)
  ILOCPCONSTRAINTWRAPPER1(_this, solver, t1, a1)
  ILOCPCONSTRAINTWRAPPER2(_this, solver, t1, a1, t2, a2)
  ILOCPCONSTRAINTWRAPPER3(_this, solver, t1, a1, t2, a2, t3, a3)
  ILOCPCONSTRAINTWRAPPER4(_this, solver, t1, a1, t2, a2, t3, a3, t4, a4)

In order to use an instance of IlcConstraint in this way, you need to follow these steps:

  1. Use the macro to wrap the instance of IlcConstraint in an instance of IloConstraint.
  2. Extract your model and model objects for an instance of IloSolver by calling the member function IloSolver::extract. During extraction, IloSolver::extract will put back the instance of IloConstraint.

You must use the following IloCPConstraintI member functions to force extraction of an extractable or an array of extractables:

 void use(const IloSolver solver, const IloExtractable ext)const;
 void use(const IloSolver solver, const IloExtractableArray extArray)const;

For more information on wrapping constraints for use with Concert Technology, see the documentation for the macro ILOCPCONSTRAINTWRAPPER and the class IloCPConstraintI in the IBM ILOG Solver Reference Manual. The section "Using the constraint wrapper" shows you how to do this for the frequency allocation example.