Simple allSame constraint

Help
2012-09-06
2013-05-30
  • Binh-Nguyen Tran

    Hi,

    Sorry if I missed out simple stuff from the docs but is there a built-in allSame constraint (all values in IntVar are the same) or how do I go and implement this?

    Thanks.

     
  • kris

    kris - 2012-09-06

    Hi!

    No, there is no global constraint allSame but you can simply implement it by the following code

    IntVarr a = …
    for (int i=0; i<a.length; i++)
       for (int j=0; j<a.length; j++)
          if (i<j)
              impose.store(new XeqY(a_, a));

    Best regards,
    /Kris
    _

     
  • Binh-Nguyen Tran

    That would work.

    Thanks :)

     

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