Simple allSame constraint

Help
2012-09-06
2013-05-30
  • 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
    _

     
  • That would work.

    Thanks :)