I'm testing Jacop as a potential solver for an application in a technical domain.
How can one impose non-primitive constraints as conditional? E.g. the second example constraint below?
IntVar MARKET_AREA = new IntVar(store , "MARKET_AREA", 1, 7);
IntVar DIM_BB = new IntVar(store , "DIM_BB", 500, 3000);
//This works as intended
//Constraint: MARKET_AREA == 1 implies DIM_BB in (700,..,1600)
store.impose (new IfThen(
new XeqC(MARKET_AREA, 1),
new In (DIM_BB, new IntervalDomain(700, 1600))));
// BUT: how to manage this one
//Constraint: MARKET_AREA == 1 implies DIM_BB mod 5 = 0
IntVar tmp007= new IntVar(store);
tmp007.addDom(5, 5);
IntVar tmp008= new IntVar(store);
tmp008.addDom(0, 0);
//cannot use non-primitive constraint in IfThen
store.impose (new IfThen(
new XeqC(MARKET_AREA, 1),
new XmodYeqZ (DIM_BB, tmp007, tmp008)));
//cannot reify non-primitive constraint
BooleanVar tmpModReif = new BooleanVar(store);
store.impose(new Reified(
new XmodYeqZ (DIM_BB, tmp007, tmp008),
tmpModReif));
//...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We divided the constraints into two types Primitive and non-primitive on purpose. We only make constraint of type Primitive if we can write an efficient propagation algorithm for notConsistent function that is used if constraint is used it in IfThen for example.
You will need to change your constraint model to a different one. Instead of using Reified, XmodYeqZ constraint you could look at TableExtensionalSupport* constraint that may be more than enough and efficient from modeling/reasoning point of view too.
Some examples that use on of the version of TableExtensionalSupport* is Gates, SleepingArrangements, WolfGoatCabbage, Crosswords, and Nonogram.
Hope that helps.
best,
Radek
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm testing Jacop as a potential solver for an application in a technical domain.
How can one impose non-primitive constraints as conditional? E.g. the second example constraint below?
Hi,
We divided the constraints into two types Primitive and non-primitive on purpose. We only make constraint of type Primitive if we can write an efficient propagation algorithm for notConsistent function that is used if constraint is used it in IfThen for example.
You will need to change your constraint model to a different one. Instead of using Reified, XmodYeqZ constraint you could look at TableExtensionalSupport* constraint that may be more than enough and efficient from modeling/reasoning point of view too.
Some examples that use on of the version of TableExtensionalSupport* is Gates, SleepingArrangements, WolfGoatCabbage, Crosswords, and Nonogram.
Hope that helps.
best,
Radek
Hi!
You can decompose the constraint as follows.
store.impose(new XmodYeqZ(X, Y, Tmp));
store.impose(new Reified(newXeqZ(Tmp, Z));
The result is the same as reified modulo.
Best,
/Kris