we are currently looking for a way to check if a certain configuration fullfills specific constraints. Our idea is to use JaCoP to generate possible solutions for these constraints and check our configuration afterwards.
A typical constraint would be "a->(b&c)" or "a->(b^c)"
As I understand, there is no easy way to express these constraints, or am I overlooking something?
Best regards
Moritz Fey
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There exist several ways of representing this constraint.
One way is to use finite domain solver and IfThen constraints since this models implication. In this case, you model your boolean expression, for example "a->(b&c)"as follows
store.impose(new IfThen(new XeqC(a, 1), new And(new XeqC(b, 1), new XeqC(c, 1)))));
The other way is to use SAT solver interfact (http://jacopguide.osolpro.com/guideJaCoP.html#x1-590001) and it will look more or less as
SatTranslation sat = new SatTranslation(store);
sat.impose(); // impose SAT-solver as constraint
BooleanVar a = new BooleanVar(store, "a");
BooleanVar b = new BooleanVar(store, "b");
BooleanVar c = new BooleanVar(store, "c");
BooleanVar x = new BooleanVar(store, "x");
It contains example how to use ExtensionalSupport constraints to obtain good model for a bit more complex boolean constraints. There are multiple ExtensionalSupport constraints and you may want to experiment with different implementations.
This type of approach gives you the strongest reasoning algorithm called GAC.
best,
Radek
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
we are currently looking for a way to check if a certain configuration fullfills specific constraints. Our idea is to use JaCoP to generate possible solutions for these constraints and check our configuration afterwards.
A typical constraint would be "a->(b&c)" or "a->(b^c)"
As I understand, there is no easy way to express these constraints, or am I overlooking something?
Best regards
Moritz Fey
Hi Motitz!
There exist several ways of representing this constraint.
One way is to use finite domain solver and IfThen constraints since this models implication. In this case, you model your boolean expression, for example "a->(b&c)"as follows
store.impose(new IfThen(new XeqC(a, 1), new And(new XeqC(b, 1), new XeqC(c, 1)))));
The other way is to use SAT solver interfact (http://jacopguide.osolpro.com/guideJaCoP.html#x1-590001) and it will look more or less as
SatTranslation sat = new SatTranslation(store);
sat.impose(); // impose SAT-solver as constraint
BooleanVar a = new BooleanVar(store, "a");
BooleanVar b = new BooleanVar(store, "b");
BooleanVar c = new BooleanVar(store, "c");
BooleanVar x = new BooleanVar(store, "x");
// adding SAT clauses
sat.generate_implication(a, x);
sat.generate_and(new BooleanVar[] {b, c}, x);
/Kris
Hi,
I would recommend checking Gates example from JaCoP library.
https://github.com/radsz/jacop/blob/master/src/main/java/org/jacop/examples/fd/Gates.java
It contains example how to use ExtensionalSupport constraints to obtain good model for a bit more complex boolean constraints. There are multiple ExtensionalSupport constraints and you may want to experiment with different implementations.
This type of approach gives you the strongest reasoning algorithm called GAC.
best,
Radek
Thank you very much for your responses! I'm looking into your recommendations.
Best regards
Moritz