Search in sources :

Example 1 with SimpleLogicalDependency

use of org.drools.core.beliefsystem.simple.SimpleLogicalDependency in project drools by kiegroup.

the class DefaultKnowledgeHelper method blockMatch.

public void blockMatch(Match act) {
    AgendaItem targetMatch = (AgendaItem) act;
    // iterate to find previous equal logical insertion
    LogicalDependency<SimpleMode> dep = null;
    if (this.previousBlocked != null) {
        for (dep = this.previousBlocked.getFirst(); dep != null; dep = dep.getNext()) {
            if (targetMatch == dep.getJustified()) {
                this.previousBlocked.remove(dep);
                break;
            }
        }
    }
    if (dep == null) {
        SimpleMode mode = new SimpleMode();
        dep = new SimpleLogicalDependency(activation, targetMatch, mode);
        mode.setObject(dep);
    }
    this.activation.addBlocked(dep);
    if (targetMatch.getBlockers().size() == 1 && targetMatch.isQueued()) {
        if (targetMatch.getRuleAgendaItem() == null) {
            // it wasn't blocked before, but is now, so we must remove it from all groups, so it cannot be executed.
            targetMatch.remove();
        } else {
            targetMatch.getRuleAgendaItem().getRuleExecutor().removeLeftTuple(targetMatch.getTuple());
        }
        if (targetMatch.getActivationGroupNode() != null) {
            targetMatch.getActivationGroupNode().getActivationGroup().removeActivation(targetMatch);
        }
        if (targetMatch.getActivationNode() != null) {
            final InternalRuleFlowGroup ruleFlowGroup = (InternalRuleFlowGroup) targetMatch.getActivationNode().getParentContainer();
            ruleFlowGroup.remove(targetMatch);
        }
    }
}
Also used : SimpleLogicalDependency(org.drools.core.beliefsystem.simple.SimpleLogicalDependency) RuleAgendaItem(org.drools.core.phreak.RuleAgendaItem) AgendaItem(org.drools.core.common.AgendaItem) InternalRuleFlowGroup(org.drools.core.common.InternalRuleFlowGroup) SimpleMode(org.drools.core.beliefsystem.simple.SimpleMode)

Example 2 with SimpleLogicalDependency

use of org.drools.core.beliefsystem.simple.SimpleLogicalDependency in project drools by kiegroup.

the class JTMSBeliefSystem method newLogicalDependency.

public LogicalDependency newLogicalDependency(Activation<M> activation, BeliefSet<M> beliefSet, Object object, Object value) {
    JTMSMode<M> mode = asMode(value);
    SimpleLogicalDependency dep = new SimpleLogicalDependency(activation, beliefSet, object, mode);
    mode.setLogicalDependency(dep);
    return dep;
}
Also used : SimpleLogicalDependency(org.drools.core.beliefsystem.simple.SimpleLogicalDependency)

Example 3 with SimpleLogicalDependency

use of org.drools.core.beliefsystem.simple.SimpleLogicalDependency in project drools by kiegroup.

the class BayesBeliefSystem method newLogicalDependency.

@Override
public LogicalDependency<M> newLogicalDependency(Activation<M> activation, BeliefSet<M> beliefSet, Object object, Object value) {
    BayesHardEvidence<M> mode = (M) value;
    SimpleLogicalDependency dep = new SimpleLogicalDependency(activation, beliefSet, object, (M) value);
    mode.setLogicalDependency(dep);
    return dep;
}
Also used : SimpleLogicalDependency(org.drools.core.beliefsystem.simple.SimpleLogicalDependency)

Aggregations

SimpleLogicalDependency (org.drools.core.beliefsystem.simple.SimpleLogicalDependency)3 SimpleMode (org.drools.core.beliefsystem.simple.SimpleMode)1 AgendaItem (org.drools.core.common.AgendaItem)1 InternalRuleFlowGroup (org.drools.core.common.InternalRuleFlowGroup)1 RuleAgendaItem (org.drools.core.phreak.RuleAgendaItem)1