use of at.ac.tuwien.kr.alpha.core.grounder.RuleGroundingOrder in project Alpha by alpha-asp.
the class StratifiedEvaluation method calculateSatisfyingSubstitutionsForRule.
private List<Substitution> calculateSatisfyingSubstitutionsForRule(CompiledRule rule, boolean checkAllStartingLiterals) {
LOGGER.debug("Grounding rule {}", rule);
RuleGroundingInfo groundingOrders = rule.getGroundingInfo();
// Treat rules with fixed instantiation first.
LOGGER.debug("Is fixed rule? {}", rule.getGroundingInfo().hasFixedInstantiation());
if (groundingOrders.hasFixedInstantiation()) {
RuleGroundingOrder fixedGroundingOrder = groundingOrders.getFixedGroundingOrder();
return calcSubstitutionsWithGroundingOrder(fixedGroundingOrder, Collections.singletonList(new BasicSubstitution()));
}
List<Literal> startingLiterals = groundingOrders.getStartingLiterals();
// Check only one starting literal if indicated by the parameter.
if (!checkAllStartingLiterals) {
// If this is the first evaluation run, it suffices to start from the first starting literal only.
Literal lit = startingLiterals.get(0);
return calcSubstitutionsWithGroundingOrder(groundingOrders.orderStartingFrom(lit), substituteFromRecentlyAddedInstances(lit));
}
// Ground from all starting literals.
// Collection of full ground substitutions for the given rule.
List<Substitution> groundSubstitutions = new ArrayList<>();
for (Literal lit : startingLiterals) {
List<Substitution> substitutionsForStartingLiteral = calcSubstitutionsWithGroundingOrder(groundingOrders.orderStartingFrom(lit), substituteFromRecentlyAddedInstances(lit));
groundSubstitutions.addAll(substitutionsForStartingLiteral);
}
return groundSubstitutions;
}
Aggregations