Search in sources :

Example 6 with JunctionTreeBuilder

use of org.drools.beliefs.bayes.JunctionTreeBuilder in project drools by kiegroup.

the class EarthQuakeTest method setUp.

@Before
public void setUp() {
    connectParentToChildren(burglaryNode, alarmNode);
    connectParentToChildren(earthquakeNode, alarmNode);
    connectParentToChildren(alarmNode, johnCallsNode, maryCallsNode);
    burglaryNode.setContent(burglary);
    earthquakeNode.setContent(earthquake);
    alarmNode.setContent(alarm);
    johnCallsNode.setContent(johnCalls);
    maryCallsNode.setContent(maryCalls);
    JunctionTreeBuilder jtBuilder = new JunctionTreeBuilder(graph);
    jTree = jtBuilder.build();
    // jTree.initialize();
    jtNode1 = jTree.getRoot();
    jtNode2 = jtNode1.getChildren().get(0).getChild();
    jtNode3 = jtNode1.getChildren().get(1).getChild();
    bayesInstance = new BayesInstance(jTree);
    burglaryState = bayesInstance.getVarStates()[burglary.getId()];
    earthquakeState = bayesInstance.getVarStates()[earthquake.getId()];
    alarmState = bayesInstance.getVarStates()[alarm.getId()];
    johnCallsState = bayesInstance.getVarStates()[johnCalls.getId()];
    maryCallsState = bayesInstance.getVarStates()[maryCalls.getId()];
}
Also used : JunctionTreeBuilder(org.drools.beliefs.bayes.JunctionTreeBuilder) BayesInstance(org.drools.beliefs.bayes.BayesInstance) Before(org.junit.Before)

Aggregations

JunctionTreeBuilder (org.drools.beliefs.bayes.JunctionTreeBuilder)6 BayesInstance (org.drools.beliefs.bayes.BayesInstance)4 JunctionTree (org.drools.beliefs.bayes.JunctionTree)3 JunctionTreeClique (org.drools.beliefs.bayes.JunctionTreeClique)3 Test (org.junit.Test)3 Before (org.junit.Before)2 BayesNetwork (org.drools.beliefs.bayes.BayesNetwork)1 Bif (org.drools.beliefs.bayes.model.Bif)1 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)1 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)1 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)1 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)1 ResourceTypePackage (org.kie.api.internal.io.ResourceTypePackage)1 ResourceType (org.kie.api.io.ResourceType)1 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)1