use of choco.kernel.model.variables.integer.IntegerVariable in project abstools by abstools.
the class ChocoSolver method addIntVar.
public void addIntVar(String name, int[] vals) {
IntegerVariable v = Choco.makeIntVar(name, vals);
vars.put(name, v);
// vals has at least 1 element! (by the
defaultvals.put(name, vals[0]);
// parser constraints)
if (absmodel.debug)
absmodel.println(" adding Int var '" + name + "' (default -> " + vals[0] + ")");
// needed to include the variable in the constraints
cpmodel.addVariable(v);
// to be solved.
}
use of choco.kernel.model.variables.integer.IntegerVariable in project abstools by abstools.
the class ChocoSolver method getSolutions.
/*
* Return ALL solutions of the feature model
*/
public Set<Map<String, Integer>> getSolutions() {
Set<Map<String, Integer>> solutions = new HashSet<>();
// int i=0;
while (solveAgain()) {
Map<String, Integer> sol = new HashMap<>();
Iterator<IntegerVariable> it = cpmodel.getIntVarIterator();
while (it.hasNext()) {
IntegerVariable var = it.next();
sol.put(var.getName(), solver.getVar(var).getVal());
}
// System.out.println(i++ + " sol: " + sol);
solutions.add(sol);
}
return solutions;
}
use of choco.kernel.model.variables.integer.IntegerVariable in project abstools by abstools.
the class ChocoSolver method addIntVar.
public void addIntVar(String name, int fromto, boolean from) {
IntegerVariable v = Choco.makeIntVar(name);
if (from)
addConstraint(Choco.geq(v, fromto));
else
addConstraint(Choco.leq(v, fromto));
vars.put(name, v);
defaultvals.put(name, fromto);
if (absmodel.debug)
absmodel.println(" adding Int var '" + name + "' (default -> " + fromto + ")");
// m.addVariable(v); // not needed, since v is used in the constraints
}
use of choco.kernel.model.variables.integer.IntegerVariable in project abstools by abstools.
the class ChocoSolver method addIntVar.
public void addIntVar(String name) {
IntegerVariable v = Choco.makeIntVar(name);
vars.put(name, v);
defaultvals.put(name, 0);
if (absmodel.debug)
absmodel.println(" adding Int var '" + name + "' (default -> 0)");
// m.addVariable(v); // not needed - if variable is not constrained in
// any way, it should not be considered when solving.
}
use of choco.kernel.model.variables.integer.IntegerVariable in project Malai by arnobl.
the class ChocoWrapper method pushVariable.
/*
* Add the variable at the top of the stack
*/
public static void pushVariable(String var) {
IntegerVariable theVar = varMap.get(var);
if (theVar == null) {
theVar = Choco.makeIntVar(var, 0, 1);
varMap.put(var, theVar);
}
// FIXME:find a better way
Constraint res = Choco.or(theVar, theVar);
stack.push(res);
}
Aggregations