use of choco.kernel.model.variables.integer.IntegerVariable in project Malai by arnobl.
the class ChocoWrapper method initialization.
/*
* Initialize the warpper.
*/
public static void initialization() {
m = new CPModel();
s = new CPSolver();
stack = new Stack<Constraint>();
varMap = new HashMap<String, IntegerVariable>();
solved = false;
}
use of choco.kernel.model.variables.integer.IntegerVariable in project abstools by abstools.
the class ChocoSolver method addIntVar.
/**
* add int variable
*
* @param name
* - name of the variable to be added
* @param from
* - lowerlimit of the domain of the variable
* @param to
* - upper limit of the domain of the variable
*/
public void addIntVar(String name, int from, int to) {
IntegerVariable v = Choco.makeIntVar(name, from, to);
// addConstraint(Choco.geq(v,from)); // needed to include the variable
// in the constraints to be solved.
vars.put(name, v);
defaultvals.put(name, from);
if (absmodel.debug)
absmodel.println(" adding Int var '" + name + "' (default -> " + from + ")");
// 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 forceTrue.
/**
* set a bool variable to true *
*/
public void forceTrue(String name) {
IntegerVariable v = Choco.makeIntVar(name, 1, 1);
vars.put(name, v);
defaultvals.put(name, 1);
cpmodel.addVariable(v);
}
use of choco.kernel.model.variables.integer.IntegerVariable in project abstools by abstools.
the class ChocoSolver method getSolution.
public Map<String, Integer> getSolution() {
if (!solved)
solve();
HashMap<String, Integer> result = new HashMap<>();
Iterator<IntegerVariable> it = cpmodel.getIntVarIterator();
while (it.hasNext()) {
IntegerVariable var = it.next();
result.put(var.getName(), solver.getVar(var).getVal());
}
return result;
}
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.
}
Aggregations