How to get the solution under Count() constraint


    SHANSHAN WANG - 2013-07-26


    I've created several variables and applied "Count" constraint on them. I want to count 1 on those variables and the IntVar(occurence)'s domain is 3..7. Yes, I want to restrict value of 1 appear 3 to 7 times. However, the solution always be 3 occurrences of 1, even 7 occurrences of 1 is available. How can I search from the max value in this variable?

    Many Thanks

  • Radoslaw Szymanek


    I assume you search for just one solution, so search heuristic will decide what solution you will find first. If you keep the search for one solution then you need to change your search heuristic to find a different solution first.

    You can also add new constraint (e.g. ExtensionalSupport*) and establish relationship between number of occurences of 1 and its cost. Now, you could use this new variable as an optimization variable. The search will find first the solution that is low occurrences of 1s and then the optimization criteria will force to search for next solution with more occurrences.

    Hope that helps.



    SHANSHAN WANG - 2013-07-27

    Thank you very much! I've changed the search heuristic and find the expected solution!

    Your response is quite helpful! Thank you again!


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks