public void buildModel() {
_dom = readDOM(dir + File.separator + DOM);
_var = readVAR(dir + File.separator + VAR);
_ctr = readCTR(dir + File.separator + CTR);
TIntHashSet values = new TIntHashSet();
vars = new IntVar[_var.length];
vars = new IntVar[_var[_var.length - 1][0]];
int n = vars.length;
int prev = 0;
for (int i = 0; i < _var.length; i++) {
int vidx = _var[i][0] - 1;
if (vidx > prev) {
for (; prev < vidx; ) {
vars[prev++] = VariableFactory.fixed(0, solver);
}
}
int didx = _var[i][1];
if (_var[i].length > 2) {
vars[vidx] = VariableFactory.fixed(_var[i][2], solver);
} else {
vars[vidx] = VariableFactory.enumerated("v_" + vidx, _dom[didx], solver);
values.addAll(_dom[didx]);
}
prev = vidx + 1;
}
int[][] graph = new int[n][n];
for (int i = 0; i < _ctr.length; i++) {
int[] ci = _ctr[i];
solver.post(IntConstraintFactory.distance(vars[ci[0] - 1], vars[ci[1] - 1], (ci[2] == 0 ? "=" : ">"), ci[3]));
// MARK BOTH SPOTS IN "PRECEDENCE" GRAPH
graph[ci[0] - 1][ci[1] - 1] = 1;
graph[ci[1] - 1][ci[0] - 1] = 1;
}
if (opt) {
cards = VariableFactory.boundedArray("c", values.size(), 0, vars.length, solver);
freqs = values.toArray();
Arrays.sort(freqs);
for (int i = 0; i < freqs.length; i++) {
solver.post(IntConstraintFactory.count(freqs[i], vars, cards[i]));
}
nb0 = VariableFactory.bounded("nb0", 0, freqs.length, solver);