Originally posted by: SystemAdmin
[Olivier Lhomme said:]
Hello Pierre,
This is a documentation problem in the CP 1.1 release.
Here is the missing documentation for IloEqSum:
--------------------------------
IloEqSum
public IloConstraint IloEqSum(const IloEnv, const IloIntSetVar var1, const IloIntVar var2, const IloIntToIntFunction f)
public IloConstraint IloEqSum(const IloEnv, const IloIntSetVar var1, const IloIntVar var2, const IloIntToIntVarFunction f)
Definition file: ilconcert/iloset.h
For ILOG Solver: a constraint forcing a variable to the sum of returned values.
This function creates and returns a constraint (an instance of IloConstraint) for use in a model. The constraint forces var2 to the sum of the values returned by the function f when it is applied to the variable var1.
In order for the constraint to take effect, you must add it to a model with the template IloAdd or the member function IloModel::add and extract the model for an algorithm with the member function IloAlgorithm::extract.
--------------------------------
In your case you can define an IloIntToIntFunction in the following way:
class MyFunctionI : public IloFunctionI<IloInt, IloInt>{
public:
MyFunctionI(IloEnvI* e): IloFunctionI<IloInt, IloInt>( e) {};
virtual IloInt getValue(IloInt a){return the cost of a;}
};
int main(int argc, char** argv) {
IloEnv env;
IloIntToIntFunction myFunction(new (env) MyFunctionI(env.getImpl()));
}
Hope it helps,
Olivier
#CPOptimizer#DecisionOptimization