Commit fa426187 authored by Nicolas Seydoux's avatar Nicolas Seydoux
Browse files

Fixed logic for rule propagation

parent a0ce2e0e
...@@ -260,10 +260,10 @@ public class RuleManager { ...@@ -260,10 +260,10 @@ public class RuleManager {
public void propagateRules(Model inference){ public void propagateRules(Model inference){
Map<String, List<String>> transfers = Node.getInstance() Map<String, List<String>> transfers = Node.getInstance()
.getShapesManager().extractTransferNodes(inference); .getShapesManager().extractTransferNodes(inference);
Boolean activatedRule = false;
if(transfers.size() == 0){ if(transfers.size() == 0){
LOGGER.debug("No transferrable rules"); LOGGER.debug("No transferrable rules");
} }
Boolean activatedRule = false;
for (String ruleURI : transfers.keySet()) { for (String ruleURI : transfers.keySet()) {
for (String nodeURI : transfers.get(ruleURI)) { for (String nodeURI : transfers.get(ruleURI)) {
if (E_Centralization.rulePropagationAllowed(Node.getInstance().getConfiguration().getCentralization())) { if (E_Centralization.rulePropagationAllowed(Node.getInstance().getConfiguration().getCentralization())) {
...@@ -297,18 +297,19 @@ public class RuleManager { ...@@ -297,18 +297,19 @@ public class RuleManager {
Model reinference = Node.getInstance().getKBManager().executeRules(true, true); Model reinference = Node.getInstance().getKBManager().executeRules(true, true);
Node.getInstance().getKBManager().addToModel(reinference); Node.getInstance().getKBManager().addToModel(reinference);
LOGGER.debug("Reinference : " + ModelPrinter.get().print(reinference)); LOGGER.debug("Reinference : " + ModelPrinter.get().print(reinference));
LOGGER.warn("Productions are not annouced (there was reinference)");
Node.getInstance().getInterestManager().propagateInterests();
} }
} }
} }
if (Node.getInstance().getShapesManager().hasActivatedRule(inference) || // If a reinference was performed, the first infernece is no longer valid, and was integrated into
(!E_Centralization.rulePropagationAllowed(Node.getInstance().getConfiguration().getCentralization()) && // the reinference, hence the condition.
activatedRule)) { if(Node.getInstance().getShapesManager().hasActivatedRule(inference) && !activatedRule){
Node.getInstance().getInterestManager().propagateInterests();
LOGGER.warn("Productions are not annouced");
// If the deduction is obtained when adding the rule (and not when receiving an observation), // If the deduction is obtained when adding the rule (and not when receiving an observation),
// it is never added to the KB, that is why it is done here // it is never added to the KB, that is why it is done here
Node.getInstance().getKBManager().addToModel(inference); Node.getInstance().getKBManager().addToModel(inference);
// Node.getInstance().getProductionManager().pro Node.getInstance().getInterestManager().propagateInterests();
LOGGER.warn("Productions are not annouced");
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment