Skip to content

How do I make sure that no more than n variables have the same value? #4348

Discussion options

You must be logged in to vote

you have multiple options.

The basic problem is a scheduling problem with a cumulative constraint of size 2 (which is at odd with your solution top left cell which contains 3 numbers).

So the best option is to see that as a scheduling problem. Look at all jobshop_ft06_sat.py, create all task intervals with precedences.
Instead of using n no_overlap constraints, use one cumulative constraint with a capacity of 2.

Your code is fine. But it would be better not to use Boolean vars if the crux of the problem is a temporal one.

My initial reaction is that persons coming from the CP community tends to create integer variables for assignment, which is not optimal.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@MarcelloTheArcane
Comment options

Comment options

You must be logged in to vote
1 reply
@MarcelloTheArcane
Comment options

Answer selected by MarcelloTheArcane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants