use of fr.lirmm.graphik.graal.forward_chaining.ChaseWithGRD in project graal by graphik-team.
the class DefaultKnowledgeBase method fesSaturate.
// /////////////////////////////////////////////////////////////////////////
// PRIVATE METHODS
// /////////////////////////////////////////////////////////////////////////
/**
* Run saturation with a timeout at <code>timeout</code> milliseconds for this thread to die. A timeout of 0 means to wait forever.
* @param timeout in milliseconds
* @throws ChaseException
* @throws TimeoutException
*/
protected void fesSaturate(long timeout) throws ChaseException, TimeoutException {
if (!isFESSaturated) {
GraphOfRuleDependencies grd = this.getFESGraphOfRuleDependencies();
ChaseWithGRD<AtomSet> chase = new ChaseWithGRD<>(grd, this.store);
chase.setProfiler(this.getProfiler());
chase.execute(timeout);
this.isFESSaturated = true;
}
}
use of fr.lirmm.graphik.graal.forward_chaining.ChaseWithGRD in project graal by graphik-team.
the class MFAProperty method check.
/**
*/
@Override
public int check(AnalyserRuleSet ruleSet) {
RuleSet R = translateToMFA(ruleSet);
AtomSet A = Rules.criticalInstance(ruleSet);
Chase chase = new ChaseWithGRD<AtomSet>(new DefaultGraphOfRuleDependencies(R), A, new DefaultRuleApplier<AtomSet>(new FrontierRestrictedChaseHaltingCondition()));
DefaultConjunctiveQuery Q = new DefaultConjunctiveQuery();
DefaultAtom q = new DefaultAtom(C);
q.setTerm(0, FAKE);
Q.getAtomSet().add(q);
try {
while (chase.hasNext()) {
chase.next();
if (SmartHomomorphism.instance().exist(Q, A)) {
return -1;
}
}
} catch (ChaseException e) {
LOGGER.warn("An error occurs during the chase: ", e);
return 0;
} catch (HomomorphismException e) {
LOGGER.warn("An error occurs during the homomorphism: ", e);
return 0;
}
return 1;
}
use of fr.lirmm.graphik.graal.forward_chaining.ChaseWithGRD in project graal by graphik-team.
the class DefaultKnowledgeBase method saturate.
@Override
public void saturate() throws KnowledgeBaseException {
if (!this.isSaturated) {
boolean run = this.approach == Approach.SATURATION_ONLY;
if (!run) {
this.analyse();
run = this.analyse.isFES();
}
if (run) {
GraphOfRuleDependencies grd = this.analysedRuleSet.getGraphOfRuleDependencies();
ChaseWithGRD<AtomSet> chase = new ChaseWithGRD<>(grd, this.store);
chase.setProfiler(this.getProfiler());
try {
chase.execute();
} catch (ChaseException e) {
throw new KnowledgeBaseException(e);
}
this.isSaturated = true;
this.isFESSaturated = true;
this.isSemiSaturated = true;
} else {
throw new KnowledgeBaseException("There is no proof for FES decidability");
}
}
}
Aggregations