Reputation: 425
A brief description of the problem. I have a number of objects let's call this object X. Each X can be assigned to a number of containers Y. Each Y, needs two each of X. Each X has an attribute L. Each Y has a minimum specification of its L level, i.e. the two X that are assigned to a particular Y must equal or exceed Y's L specification.
X is an array of structs with field L (single value) with values 0 to 5
Y is an array of structs with field L (single value) with values 0 to 8
CP cp = new CP();
IIntVar[] dies = cp.IntVarArray(X.size(), 0, 10);
IIntVar[] YvarL= cp.IntVarArray(Y.size(), 0, 10);
for (int i = 1; i <= Y.Lenth; i++)
{
IIntExpr tempL = cp.IfThen(cp.Eq(dies[0], i), cp.Sum(YvarL[i], X[0].L));
for (int j = 1; j < X.Length(); j++)
cp.IfThen(cp.Eq(dies[j], i), cp.Sum(YvarL[i], X[j].L);
cp.Add(cp.Ge(YvarL[i], Y[i].L)
}
But I get an error on the 5th line saying Argument 2: Cannot convert from 'ILOG.Concert.IIntExpr' to 'ILOG.Constraint.IConstraint'
What I'm trying to accomplish is that for all 'dies' decision variables that have value of 'i', the sum of their corresponding X variable's 'L' attribute fields must exceed the 'L' field attribute of Y[i] (here dies corresponds to X)
Upvotes: 2
Views: 249
Reputation: 26
Opl is right: cp.Sum(YvarL[i], X[0].L)
is an integer expression while the ifThen
construct requires a constraint argument.
Upvotes: 1