IntVar v = model.intVar("v", 1, 12, true);
// or
v= model.intVar("v", 20, 30, true);
I want the value of IntVar v not only in [1,12] but also in [20,30] and in other segment of values [...,....] I don't understand how to do this with the specific declaration of an IntVar
In choco-solver, you can either define bounded domain variables (with model.intVar(name, lowerBound, upperBound)
)
// domain is [1,7]
IntVar v = model.intVar("v", 1,7);
or enumerated domain variables (with model.intVar(name, values...)
:
// domain is {1,3,5}
IntVar v = model.intVar("v", new int[]{1,3,5});
So, if the domain you want to declare is made of ranges, there is no other option than to list all possible values.
// domain is [1,3]U[5,7]
IntVar v = model.intVar("v", new int[]{1,2,3,5,6,7});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.