Menu

question to understand

hercule
2013-01-22
2013-04-06
  • hercule

    hercule - 2013-01-22

    Hi !!
    I have a question and i want just to understand if that's normal and why

    i have to maximize an objectif variable "obj"

    IntegerExpressionVariable ie = Choco.constant(0);
    //ie is an accumulator where i compute the sum of data
    for (int i = 0; i<n ; i++)
        ie = Choco.plus(ie, Choco...)
    IntegerVariable obj = Choco.makeIntVar("cout");
    m.addConstraint(Choco.eq(obj,ie));
    s.maximize(s.getVar(obj), true);
    

    the solver return me a solution in 30 seconds, but when i change the weight of obj the solver takes more time to give the solution.

    IntegerVariable obj = Choco.makeIntVar("cout");
    m.addConstraint(Choco.eq(obj,Choco.mult(ie,1000)));
    

    in 40 seconds

    IntegerVariable obj = Choco.makeIntVar("cout");
    m.addConstraint(Choco.eq(obj,Choco.mult(ie,10000)));
    

    in 2 minutes and 39 sec

    thank you very much for help

     
  • Arnaud Malapert

    Arnaud Malapert - 2013-01-22

    Hello,

    The complexity of the filtering algorithm can depend on the domain sizes.
    Do you have the same problem using the Choco.sum or Choco.scalar constraint ?
    Try also to change the value of model.setDefaultExpressionDecomposition(final Boolean defDecExp)

    Best,
    Arnaud

     
  • hercule

    hercule - 2013-01-22

    hi arnaud,

    i can't use Choco.sum or Choco.scalar, i should create a temporary variable ie to compute my objective and then Choco.eq(obj,ie)

    but in changing the weight obj=ie , obj=100*ie and obj=10000*ie the duration of resolution change

    is that normal in choco??

    i tried as you sais to change setDefaultExpressionDecomposition, it work with true (the same result and duration as described) and with false it is much more long i wait for 4 minutes and no results

     
  • Arnaud Malapert

    Arnaud Malapert - 2013-01-22

    Hello,

    Could you provide a minimal example ?

    Best.

     
  • hercule

    hercule - 2013-01-22

    this is an example

          int tab [] = new int [1000];      
          IntegerVariable[] IV1 = makeIntVarArray("v", 1000, 0, n);
          IntegerVariable obj1 = Choco.makeIntVar("cout1");
         
          IntegerExpressionVariable tm1 = Choco.constant(0);
          for (int i=0; i<nbre_plan-1; i++) 
              tm1 = Choco.plus(tm1, Choco.mult(Choco.min(IV1[i], 1), Math.min(tab[i+1], 1) ));
          m.addConstraint(Choco.eq(obj1,Choco.mult(tm1, 1000)));
          Solver s = new CPSolver();
          s.read(m);
          s.maximize(s.getVar(obj1), true);
    

    in changing the weight 1000 in this example with 1 or 100000, the duration remarkably change

    thanks

     
  • Arnaud Malapert

    Arnaud Malapert - 2013-01-22

    Thanks, I will have a look this evening.

     
  • hercule

    hercule - 2013-01-22

    a small modification in _

    _

          int tab [] = new int [1000];      
          IntegerVariable[] IV1 = makeIntVarArray("v", 1000, 0, n);
          IntegerVariable obj1 = Choco.makeIntVar("cout1");
         
          IntegerExpressionVariable tm1 = Choco.constant(0);
          for (int i=0; i<nbre_plan-1; i++) 
              tm1 = Choco.plus(tm1, Choco.mult(Choco.min(IV1[i], 1), Math.min(tab[i+1], 1) ));
          m.addConstraint(Choco.eq(obj1,Choco.mult(tm1, 1000)));
          Solver s = new CPSolver();
          s.read(m);
          s.maximize(s.getVar(obj1), true);
    

    _

    thank you very much_

     
  • hercule

    hercule - 2013-01-23

    There is no explanation?

    Normally, it is expected that the response time will be the same, Maximizing (X) or Maximizing (1000 X) it is the same.

    Thans

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.