Replies: 4 comments 13 replies
-
Hi |
Beta Was this translation helpful? Give feedback.
-
To me, the main difficulty comes from the modelling aspect. In the current version, there is no such question, because tuples can only deal with integers and Model model = new Model();
IntVar x = model.intVar(1, 3);
IntVar y = model.intVar(1, 3);
IntVar z = model.intVar(1, 3);
Tuples ts = new Tuples(true);
int ST = 99;
ts.setUniversalValue(ST);
ts.add(3, ST, 1);
ts.add(1, 2, 3);
ts.add(2, 2, 3);
model.table(new IntVar[]{x, y, z}, ts, "CT+").post(); So I think the first thing to do is to design a smart tuple data structure, presumably only dedicated to smart table (to avoid changing the entire table API), which makes possible to declare smart tuples. May be relying on Model model = new Model();
IntVar x = model.intVar(1, 3);
IntVar y = model.intVar(1, 3);
IntVar z = model.intVar(1, 3);
SmartTuples ts = new SmartTuples();
ts.add(eq(3), gt(0), 1);
ts.add(lt(3), 2, 3);
model.table(new IntVar[]{x, y, z}, ts, "CTsmart").post(); ? |
Beta Was this translation helpful? Give feedback.
-
I have a first prototype, based on STR2 (not Compact table), that makes possible to deal with simple expressions like: import static org.chocosolver.solver.constraints.extension.hybrid.HybridTuples.*;
//...
Model model = new Model();
IntVar x = model.intVar("x", 1, 3);
IntVar y = model.intVar("y", 1, 3);
IntVar z = model.intVar("z", 1, 3);
int a = 1, b = 2, c = 3;
HybridTuples tuples = new HybridTuples();
tuples.add(ne(a), any(), eq(c));
tuples.add(eq(c), le(b), ne(a));
tuples.add(lt(c), eq(b), ne(b));
tuples.add(gt(b), ge(b), any());
model.table(new IntVar[]{x, y, z}, tuples).post();
Solver solver = model.getSolver();
solver.setSearch(Search.inputOrderLBSearch(x, y, z));
while (solver.solve()) {
System.out.printf("(%d, %d, %d)\n",
x.getValue(), y.getValue(), z.getValue());
} In particular, one can define Model model = new Model();
IntVar x = model.intVar("x", 1, 3);
IntVar y = model.intVar("y", 1, 3);
IntVar z = model.intVar("z", 1, 3);
HybridTuples tuples = new HybridTuples();
tuples.add(any(), col(0), col(0));
model.table(new IntVar[]{x, y, z}, tuples).post();
Solver solver = model.getSolver();
solver.setSearch(Search.inputOrderLBSearch(x, y, z));
while (solver.solve()) {
System.out.printf("(%d, %d, %d)\n",
x.getValue(), y.getValue(), z.getValue());
} I'm considering an extension to simple arithmetical relations (like I have started a minimalist DSL from scratch, not reusing already existing classes (like ReExpression or ArExpression). Soon I will push to a dev branch, if one of you want to play around with the code. |
Beta Was this translation helpful? Give feedback.
-
See PR #1008 |
Beta Was this translation helpful? Give feedback.
-
Hi, I was reading about the Table constraints in choco-solver and have a question. Does Choco-solver have any plan to implement Smart Table Constraints related to the paper "Extending Compact-Table to Basic Smart Tables"?
https://link.springer.com/chapter/10.1007/978-3-319-66158-2_19
Beta Was this translation helpful? Give feedback.
All reactions