In the current version of JaCoP, I think, you can use the following solution written in peudo-code. IntVar[] z = new IntVar[n]; make domains for each z[i].domain = x[i].domain union {0} forall i store.impose(new IfThenElse(c[i], new XeqY(z[i], x[i]), new XeqC(z[i], 0) result = sum(z) For sum you can use either Sum constraint (avoids recomputations of already ground variables) or SumInt constraint (recomputs everything). Depending on cache efficiency one of constraints can be mnore efficient. If you...
There is, in fact another posibility to solve your problem. This formulation dies not use set variables. It basically creates a vector of values that are not in y (for othe values a constant outside the domain is added) and the finds a m inimal value. The program looks like that. int n = 5; Store store = new Store(); IntVar[] x = new IntVar[n]; for (int i = 0; i < n; i++) { x[i] = new IntVar(store, "x["+i+"]", 1, n); } IntVar[] y = new IntVar[n]; for (int i = 0; i < n; i++) { y[i] = new IntVar(store,...
I do not see any simple solution. The solution I propose is based on set variables. In minizinc it can be programmed as follows. include "globals.mzn"; int: n = 5; array[1..n] of var 1..n: x; array[1..n] of var 1..n: y; var 1..n: m; var set of 1..n: xs; constraint xs = array2set(x) diff array2set(y) /\ m = min(xs); solve satisfy; output["x = (x)\ny = (y)\nmin = (m)\nxs = (xs)"] It basically creates set variable xs that contains all elements of x that are not in y and then it finds minimum value in...
I do not know :( The constraints should be in store... /Kris
Hi! No, if you print the store you will see the constraint. In your first question it was constraint XplusYeqZ46, that is the foolowing constraint. *** Constraint: XplusYeqZ46 : XplusYeqZ(U1-2-R1-1:(1)-li = 110, U1-2-R1-1:(1)-w2::{1..362}, U1-2-R1-1:(1)-i::{111..472} ) Best, /Kris
Hi Peter, Yes, XplusYeqZ21 is an particular instance of XplusYeqZ. Similar for XplusYeqZ19. You can see all the constraints when you print the store in Java. However, you will not see waht was the store state when constraint failed :( Best, /Kris
Hi! The informartion is that 182 times constraints of type XplusYeqZ failed during search and more specifically 182 times fails constraint XplusYeqZ46. I hope it helps to understand the output of statistics. Best, /Kris
Hi Peter, You can take a look at my slides at https://fileadmin.cs.lth.se/cs/Education/EDAN01/presentations/lecture6.pdf. First 18 slides discuss depth-fist-search in general and slides 14-15 present a simpliied Java method for search in JaCoP. In this method variable selection uses input order and value selection starts from minimal value. Alternatively, you can try to find similar discussions on internet. Best, /Kris