Instances of the class IloSearchLimit are objects linked to a model. They are allocated on the environment, an instance of IloEnv, and not on the Solver reversible heap. When an instance of this class is used, the IloSolver::extract method is called. This method returns an instance of the class IlcSearchLimit to be used during the search.
To use a custom search limit in a Concert Technology model, you must use the class IloSearchLimitI.
class IloMyLimitI : public IloSearchLimitI {
IloInt& _counter;
IloInt _limit;
public:
IloMyLimitI(IloEnvI*, IloInt&, IloInt);
virtual IlcSearchLimit extract(const IloSolver) const;
virtual IloSearchLimitI* makeClone(IloEnvI* env) const;
virtual void display(ILOSTD(ostream&)) const;
};
|
The constructor initializes the _limit member:
IloMyLimitI::IloMyLimitI(IloEnvI* e, IloInt& counter, IloInt limit) :
IloSearchLimitI(e), _counter(counter), _limit(limit) {}
|
The member function extract returns the internal search limit extracted for solver from the invoking search limit of the model:
IlcSearchLimit IloMyLimitI::extract(const IloSolver solver) const {
return IlcMyLimit(solver, _counter, _limit);
}
|
The member function makeClone is called internally to duplicate the current search limit:
IloSearchLimitI* IloMyLimitI::makeClone(IloEnvI* env) const {
return new (env) IloMyLimitI(env, _counter, _limit);
}
|
The member function display prints the invoking search limit on an output stream:
void IloMyLimitI::display(ostream& str) const {
str << "IloMyLimit(" << _counter << ", " << _limit << ") ";
}
|
The function IloMyLimit returns a handle of type IloSearchLimit built from an instance of the class IloMyLimitI.
IloSearchLimit IloMyLimit(const IloEnv env, IloInt& counter, IloInt limit) {
return new (env) IloMyLimitI(env.getImpl(), counter, limit);
}
|