Originally posted by: davidoff
Hello
To my understanding, and after browsing the documentation, I thought this following test with the inverse function would work, but the answer is "no solution"
using CP;
range rcandidats = 0 .. 3;
range ralveoles = 0 .. 9;
dvar int alv[rcandidats] in 0 .. 10;
dvar int can[ralveoles] in 0 .. 4;
constraints{
inverse(alv,can);
}
Here, I want to say that any candidate 0,1,2,3 will have a destination alv among the 10 locations 0,..9. Or a dummy destination 10 otherwise
Reversely, for any destination 0,..9, I will store in can the chosen candidate , that will be between 0 and 3 except if no candidate is chosen for this destination and in this case, the can variable is set to 4.
This seems compatible to me with the documentation :
if the length of the array f is n, and the length of the array invf is m, then the inverse constraint guarantees that:
-
for all i in the interval [0,n-1], if f[i] is in [0,m-1], then invf[f[i]]==i;
-
for all j in the interval [0,m-1], if invf[j] is in [0,n-1], then f[invf[j]]==j.
However, the program runs with no solution.
Do I miss something here ?
David
#DecisionOptimization#OPLusingCPOptimizer