use of fr.lirmm.graphik.graal.homomorphism.VarSharedData in project graal by graphik-team.
the class GraphBaseBackJumping method append.
@Override
public StringBuilder append(StringBuilder sb, int level) {
sb.append("\tBJSet{");
for (VarSharedData v : this.data[level].backjumpSet) {
sb.append(v.value);
sb.append(", ");
}
return sb.append("}");
}
use of fr.lirmm.graphik.graal.homomorphism.VarSharedData in project graal by graphik-team.
the class NFC2 method checkForward.
// /////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS
// /////////////////////////////////////////////////////////////////////////
@Override
public boolean checkForward(Var v, AtomSet g, Substitution initialSubstitution, Map<Variable, Integer> map, Var[] varData, RulesCompilation rc) throws BacktrackException {
// clear all computed candidats for post variables
for (VarSharedData z : v.shared.postVars) {
this.clear(v.shared, z);
}
Var varToAssign = null;
for (Atom atom : v.shared.postAtoms) {
boolean runCheck = true;
if (checkMode) {
int i = 0;
for (Variable t : atom.getVariables()) {
Integer idx = map.get(t);
if (idx != null) {
Var z = varData[idx];
if (z.shared.level > v.shared.level) {
++i;
varToAssign = z;
if (i > 1 || !this.data[z.shared.level].candidats[v.shared.level].init) {
runCheck = false;
break;
}
}
}
}
}
if (checkMode && runCheck) {
try {
if (!check(atom, v.shared, varToAssign.shared, g, initialSubstitution, map, varData, rc)) {
return false;
}
} catch (AtomSetException e) {
throw new BacktrackException("An error occurs while checking current candidate");
}
} else {
try {
if (!select(atom, v, g, initialSubstitution, map, varData, rc)) {
return false;
}
} catch (IteratorException e) {
throw new BacktrackException("An error occurs while selecting candidates for next steps ");
} catch (AtomSetException e) {
throw new BacktrackException("An error occurs while selecting candidates for next steps ");
}
}
}
return true;
}
Aggregations