Constraint with 9 or more IntVars

Help
2012-08-14
2013-05-30
  • David Torres
    David Torres
    2012-08-14

    hello there,

    I have  a problem, i need to know how to implement a constraint with 9 intVars, for a example  i have a+b+c+d+f+g+h+i<1000, how do i do that on Jacop?
    thanks,

     
  • Graeme
    Graeme
    2012-08-15

    You can use the Sum constraint to do this. For example if vars is an array of IntVar:-

    store.impose( new Sum(vars,total));
    store.impose( new XlteqC(total, 1000));
    

    Will ensure that the total of all the elements of vars is kept in total, and this is <= 1000.

     
  • David Torres
    David Torres
    2012-08-16

    Thanks, i appreciate yor help.