Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Custom constraint: constructor invoked too often?

    Posted 07/23/15 09:56 PM

    Originally posted by: JorisK


    I've implemented a simple custom constraint "IloDiffConstraint(IloIntVar a, IloIntvar b)" which requires that variables a and b must take different values. The code is attached. I've modified the graph coloring example packaged with the CP optimizer examples to test the new constraint. The code works fine. The thing that worries me though is the output that is produced when I run cp.solve():

     

    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
    Invoking diff constructor
     ! ----------------------------------------------------------------------------
     ! Satisfiability problem - 6 variables, 9 constraints
     ! Workers              = 1
     ! Initial process time : 0.00s (0.00s extraction + 0.00s propagation)
     !  . Log search space  : 12.0 (before), 12.0 (after)
     !  . Memory usage      : 513.5 kB (before), 513.5 kB (after)
     ! Using sequential search.
     ! ----------------------------------------------------------------------------
     !               Branches  Non-fixed            Branch decision
     *                      5 0.00s                   0  = DK
     ! ----------------------------------------------------------------------------
     ! Search terminated normally, 1 solution found.
     ! Number of branches     : 5
     ! Number of fails        : 0
     ! Total memory usage     : 553.7 kB (513.5 kB CP Optimizer + 40.2 kB Concert)
     ! Time spent in solve    : 0.00s (0.00s engine + 0.00s extraction)
     ! Search speed (br. / s) : 500.0
     ! ----------------------------------------------------------------------------

    Feasible Solution
    Belgium:     white
    Denmark:     blue
    France:      blue
    Germany:     yellow
    Luxembourg:  green
    Netherlands: blue

     

    In the attached CP model (main.cpp), there are exactly 9 IloDiffConstraints. Yet, the message "Invoking diff constructor" is printed 27 times! That's 3 times the number of constraints? Is there a logical explanation for this? Am I doing something wrong? In a similar fashion, the propagate function seems to be invoked a lot more than it should be? Note that I put the number of workers equal to 1, so I don't think it's a multi-threading issue?


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Custom constraint: constructor invoked too often?

    Posted 07/27/15 04:26 AM

    Originally posted by: PhilippeLaborie


    Hello,

    CP Optimizer indeed calls several times the initial propagation, this is expected  and due to the fact the automatic search is more complex than just a single exploration of a search tree.

    As far as your constraint is concerned, I think it is ok. One remarks still: you did not implement isViolated() virtual function. It is ok if the constraint is directly posted (like in the color example) but you would need to implement this function if the constraint can used in composite constraints like IloDiffConstraint(...) || IloDiffConstraint(...)

    Philippe


    #CPOptimizer
    #DecisionOptimization