There are several strange things in the alternative constraints in your model. For instance, consider the one below:
forall(a1,a2 in allActivities, b1,b2 in MainProcessUnits, c1,c2 in wp1NewStorages, j1,j2 in 1..maxPieces :c1==c2&&a1.nBatch==a2.nBatch && a1.allActivities.Num==a2.allActivities.Num && j1==j2 && b1==b2 )
alternative(storage[c1], all (c2 in wp1NewStorages) wp1_pieces_storage[a2][b2][c2][j2]);
b and b2 are constrained to be equal, as c1/c2, and j1/j2. To simplify, you can write:
forall(a1,a2 in allActivities, b in MainProcessUnits, c in wp1NewStorages, j in 1..maxPieces :a1.nBatch==a2.nBatch && a1.allActivities.Num==a2.allActivities.Num )
alternative(storage[c], all (c in wp1NewStorages) wp1_pieces_storage[a2][b][c][j]);
Then, there is no parameter a1 used in the alternative. Is it what you mean? The effect is probably not what you expect (stating several times the constraint, if several a1 match a2)
Moreover, the variable c (or c2 in your original constraint) is overloaded by the construct "all(c in wp1NewStorages)", so the "c" in the left term is not the same as the "c" in the right term. Not sure this is what you want.
------------------------------
Olivier Lhomme
------------------------------
Original Message:
Sent: Tue June 04, 2024 04:17 PM
From: Mohamed Awad
Subject: How to overcome a conflict in constraints?
Hi,
I am working on a model that works fine until I activate an alternative constraint to pick one resource from a list of resources. To explain it, the screenshot below shows 4 resources reserved at each duration. The alternative constraint will allow removing three out of these four intervals leaving only one interval with one resource. Whenever I activate the alternative constraint, a conflict occurs and the model stops. Could you please advise on that?
Here is the screenshot:
I am attaching the model with the data file.
Regards,
Mohamed
------------------------------
Mohamed Awad
------------------------------