Search in sources :

Example 1 with GraphBaseBackJumping

use of fr.lirmm.graphik.graal.homomorphism.backjumping.GraphBaseBackJumping in project graal by graphik-team.

the class TestUtil method getHomomorphisms.

@SuppressWarnings({ "rawtypes" })
public static Homomorphism[] getHomomorphisms() {
    BCC bcc0 = new BCC(true);
    BCC bcc1 = new BCC(new GraphBaseBackJumping(), true);
    BCC bcc2 = new BCC(new GraphBaseBackJumping(), true);
    BCC bcc3 = new BCC(new GraphBaseBackJumping(), true);
    BCC bcc4 = new BCC(new GraphBaseBackJumping(), true);
    BCC bcc5 = new BCC(new GraphBaseBackJumping(), true);
    return new Homomorphism[] { SmartHomomorphism.instance(), RecursiveBacktrackHomomorphism.instance(), // Without Optimization
    new BacktrackHomomorphism(DefaultScheduler.instance(), StarBootstrapper.instance(), NoForwardChecking.instance(), NoBackJumping.instance()), // BackJumping
    new BacktrackHomomorphism(DefaultScheduler.instance(), StarBootstrapper.instance(), NoForwardChecking.instance(), new GraphBaseBackJumping()), // BCC
    new BacktrackHomomorphism(bcc0.getBCCScheduler(), StarBootstrapper.instance(), NoForwardChecking.instance(), bcc0.getBCCBackJumping()), new BacktrackHomomorphism(bcc1.getBCCScheduler(), StarBootstrapper.instance(), NoForwardChecking.instance(), bcc1.getBCCBackJumping()), // Forward Checking
    new BacktrackHomomorphism(DefaultScheduler.instance(), StarBootstrapper.instance(), new NFC0(), new GraphBaseBackJumping()), new BacktrackHomomorphism(DefaultScheduler.instance(), StarBootstrapper.instance(), new NFC2(), new GraphBaseBackJumping()), new BacktrackHomomorphism(DefaultScheduler.instance(), StarBootstrapper.instance(), new NFC2(true), new GraphBaseBackJumping()), new BacktrackHomomorphism(DefaultScheduler.instance(), StarBootstrapper.instance(), new SimpleFC(), new GraphBaseBackJumping()), new BacktrackHomomorphism(DefaultScheduler.instance(), StarBootstrapper.instance(), new NFC2WithLimit(8), new GraphBaseBackJumping()), // Bootstrapper
    new BacktrackHomomorphism(bcc2.getBCCScheduler(), StarBootstrapper.instance(), new NFC2(), bcc2.getBCCBackJumping()), new BacktrackHomomorphism(bcc3.getBCCScheduler(), StatBootstrapper.instance(), new NFC2(), bcc3.getBCCBackJumping()), new BacktrackHomomorphism(bcc4.getBCCScheduler(), DefaultBootstrapper.instance(), new NFC2(), bcc4.getBCCBackJumping()), new BacktrackHomomorphism(bcc5.getBCCScheduler(), AllDomainBootstrapper.instance(), new NFC2(), bcc5.getBCCBackJumping()) };
}
Also used : NFC0(fr.lirmm.graphik.graal.homomorphism.forward_checking.NFC0) BCC(fr.lirmm.graphik.graal.homomorphism.bbc.BCC) NFC2(fr.lirmm.graphik.graal.homomorphism.forward_checking.NFC2) SimpleFC(fr.lirmm.graphik.graal.homomorphism.forward_checking.SimpleFC) NFC2WithLimit(fr.lirmm.graphik.graal.homomorphism.forward_checking.NFC2WithLimit) RecursiveBacktrackHomomorphism(fr.lirmm.graphik.graal.homomorphism.RecursiveBacktrackHomomorphism) BacktrackHomomorphism(fr.lirmm.graphik.graal.homomorphism.BacktrackHomomorphism) SmartHomomorphism(fr.lirmm.graphik.graal.homomorphism.SmartHomomorphism) RecursiveBacktrackHomomorphism(fr.lirmm.graphik.graal.homomorphism.RecursiveBacktrackHomomorphism) Homomorphism(fr.lirmm.graphik.graal.api.homomorphism.Homomorphism) BacktrackHomomorphism(fr.lirmm.graphik.graal.homomorphism.BacktrackHomomorphism) GraphBaseBackJumping(fr.lirmm.graphik.graal.homomorphism.backjumping.GraphBaseBackJumping)

Example 2 with GraphBaseBackJumping

use of fr.lirmm.graphik.graal.homomorphism.backjumping.GraphBaseBackJumping 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

GraphBaseBackJumping (fr.lirmm.graphik.graal.homomorphism.backjumping.GraphBaseBackJumping)2 BCC (fr.lirmm.graphik.graal.homomorphism.bbc.BCC)2 NFC2 (fr.lirmm.graphik.graal.homomorphism.forward_checking.NFC2)2 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)1 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)1 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 DefaultInMemoryGraphStore (fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore)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 NFC0 (fr.lirmm.graphik.graal.homomorphism.forward_checking.NFC0)1 NFC2WithLimit (fr.lirmm.graphik.graal.homomorphism.forward_checking.NFC2WithLimit)1 SimpleFC (fr.lirmm.graphik.graal.homomorphism.forward_checking.SimpleFC)1 Test (org.junit.Test)1