Search in sources :

Example 6 with NFC2

use of fr.lirmm.graphik.graal.homomorphism.forward_checking.NFC2 in project graal by graphik-team.

the class HomomorphismTest method test5.

@Test
public void test5() throws HomomorphismException, IteratorException, AtomSetException {
    InMemoryAtomSet data = new DefaultInMemoryGraphStore();
    data.addAll(DlgpParser.parseAtomSet("p(a,b), r(b,b), r(c,c), q(c), q(b)."));
    Variable x = DefaultTermFactory.instance().createVariable("X");
    InMemoryAtomSet positivePart = new LinkedListAtomSet();
    positivePart.addAll(DlgpParser.parseAtomSet("p(a,X),r(W,Y),q(Y)."));
    positivePart.iterator().next().setTerm(1, x);
    InMemoryAtomSet negatedPart = new LinkedListAtomSet();
    negatedPart.addAll(DlgpParser.parseAtomSet("q(X)."));
    negatedPart.iterator().next().setTerm(0, x);
    DefaultConjunctiveQueryWithNegatedParts query = new DefaultConjunctiveQueryWithNegatedParts(positivePart, Collections.singletonList(negatedPart), Collections.<Term>emptyList());
    BCC bcc = new BCC(new GraphBaseBackJumping(), true);
    BacktrackHomomorphismWithNegatedParts h = new BacktrackHomomorphismWithNegatedParts(bcc.getBCCScheduler(), StarBootstrapper.instance(), new NFC2(), bcc.getBCCBackJumping());
    CloseableIterator<Substitution> res = h.execute(query, data);
    Assert.assertFalse(res.hasNext());
    res.close();
}
Also used : DefaultConjunctiveQueryWithNegatedParts(fr.lirmm.graphik.graal.core.DefaultConjunctiveQueryWithNegatedParts) Variable(fr.lirmm.graphik.graal.api.core.Variable) BCC(fr.lirmm.graphik.graal.homomorphism.bbc.BCC) NFC2(fr.lirmm.graphik.graal.homomorphism.forward_checking.NFC2) Substitution(fr.lirmm.graphik.graal.api.core.Substitution) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) DefaultInMemoryGraphStore(fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore) GraphBaseBackJumping(fr.lirmm.graphik.graal.homomorphism.backjumping.GraphBaseBackJumping) Test(org.junit.Test)

Aggregations

NFC2 (fr.lirmm.graphik.graal.homomorphism.forward_checking.NFC2)6 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)5 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)5 DefaultInMemoryGraphStore (fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore)5 Test (org.junit.Test)5 AtomSet (fr.lirmm.graphik.graal.api.core.AtomSet)4 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)4 CPUTimeProfiler (fr.lirmm.graphik.util.profiler.CPUTimeProfiler)3 Profiler (fr.lirmm.graphik.util.profiler.Profiler)3 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)2 GraphBaseBackJumping (fr.lirmm.graphik.graal.homomorphism.backjumping.GraphBaseBackJumping)2 BCC (fr.lirmm.graphik.graal.homomorphism.bbc.BCC)2 Random (java.util.Random)2 Variable (fr.lirmm.graphik.graal.api.core.Variable)1 Homomorphism (fr.lirmm.graphik.graal.api.homomorphism.Homomorphism)1 DefaultConjunctiveQueryWithNegatedParts (fr.lirmm.graphik.graal.core.DefaultConjunctiveQueryWithNegatedParts)1 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)1 BacktrackHomomorphism (fr.lirmm.graphik.graal.homomorphism.BacktrackHomomorphism)1 RecursiveBacktrackHomomorphism (fr.lirmm.graphik.graal.homomorphism.RecursiveBacktrackHomomorphism)1 SmartHomomorphism (fr.lirmm.graphik.graal.homomorphism.SmartHomomorphism)1