Originally posted by: Oblivion
I have observed that using dvar interval instead of dvar int can lead to duplicated solutions and I don't understand why. Has anybody some explanation for this ?
-
Consider the Program 1 that tries to fix the beginning of a one unit length task within a window of 3 unit. This version uses a dvar int variable
using CP;
execute {
cp.param.searchType="DepthFirst";
cp.param.logVerbosity="Quiet";
cp.param.workers=1;
}
dvar int b in 0..2; // task beginning
constraints {
bt >= 0; // at least one constraint involving the variable
// otherwise it doesn't backtrack
}
include "allSolutions.mod"; // A main bloc for enumerating solutions
// --- PostProcessing
execute {
writeln("b = ",b);
}
This program has 3 solutions :
----------- Solution 1-------------
b = 0
----------- Solution 2-------------
b = 1
----------- Solution 3-------------
b = 2
No (more) solution
# solutions : 3
-
Consider now the Program 2 that does the same but using a dvar interval variable :
using CP;
execute {
cp.param.searchType="DepthFirst";
cp.param.logVerbosity="Quiet";
cp.param.workers=1;
}
dvar interval t in 0..3 size 1;
constraints {
startOf(t) >= 0; // at least one constraint for backtrack
}
include "allSolutions.mod";
// --- Post processing
execute {
writeln("t = ",t);
}
Now we get 4 solutions
----------- Solution 1-------------
t = <1 0 1 1>
----------- Solution 2-------------
t = <1 0 1 1>
----------- Solution 3-------------
t = <1 1 2 1>
----------- Solution 4-------------
t = <1 2 3 1>
No (more) solution
Nb Solutions : 4
Why is the first solution duplicated ?
A third version with both variables and an additional constraint startOf(t) == b also gives 4 solutions.
#DecisionOptimization#OPLusingCPOptimizer