Search in sources :

Example 6 with VarSharedData

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("}");
}
Also used : VarSharedData(fr.lirmm.graphik.graal.homomorphism.VarSharedData)

Example 7 with VarSharedData

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;
}
Also used : IteratorException(fr.lirmm.graphik.util.stream.IteratorException) Variable(fr.lirmm.graphik.graal.api.core.Variable) Var(fr.lirmm.graphik.graal.homomorphism.Var) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) VarSharedData(fr.lirmm.graphik.graal.homomorphism.VarSharedData) Atom(fr.lirmm.graphik.graal.api.core.Atom) BacktrackException(fr.lirmm.graphik.graal.homomorphism.BacktrackException)

Aggregations

VarSharedData (fr.lirmm.graphik.graal.homomorphism.VarSharedData)7 Variable (fr.lirmm.graphik.graal.api.core.Variable)5 Term (fr.lirmm.graphik.graal.api.core.Term)4 Atom (fr.lirmm.graphik.graal.api.core.Atom)2 TreeSet (java.util.TreeSet)2 AtomSetException (fr.lirmm.graphik.graal.api.core.AtomSetException)1 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)1 HomomorphismException (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException)1 Store (fr.lirmm.graphik.graal.api.store.Store)1 BacktrackException (fr.lirmm.graphik.graal.homomorphism.BacktrackException)1 Var (fr.lirmm.graphik.graal.homomorphism.Var)1 DefaultHyperGraph (fr.lirmm.graphik.util.graph.DefaultHyperGraph)1 HyperGraph (fr.lirmm.graphik.util.graph.HyperGraph)1 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)1 HashMap (java.util.HashMap)1