Reputation: 1
I'm quite new to CPLEX and I have an issue with one of my constraint.
I need to sum over only terms that respect a certain condition :
I first wrote
forall(r in RangeR, w in RangeW, d in RangeD, h in RangeH){
sum(k in RangeK) sum(j in RangeJ) rc[j][r] * sum(g in max(0,h-p[j]+1)..h) x[k][j][w][d][g] <= ra[r][w][d][h];
}
Of course, that made me get the classical "cannot extract expression" error. I tried to by-pass this error by writing the constraint differently :
forall(r in RangeR, w in RangeW, d in RangeD, h in RangeH){
sum(k in RangeK) sum(j in RangeJ) rc[j][r]*sum (g in RangeH)(g >= h - p[j]+1 && g <= h)*x[k][j][w][d][g] <= ra[r][w][d][h];
}
If I understood correctly, the expression between brackets should count every time the condition is true.
With this reformulation, I no longer have the "cannot extract expression" error (in fact I no longer have errors), but the constraint is not considered in the solution.
How do I make this constraint count in the solving ?
Thanks !
Upvotes: 0
Views: 112
Reputation: 303
Please check if you still get a "cannot extract expression" error when you replace sum(g in max(0,h-p[j]+1)..h)
by sum(g in max(1,h-p[j]+1)..h)
because in your mathematical formulation there is a >0
restriction imposed on the summation index.
Upvotes: 0