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