Search in sources :

Example 86 with FactType

use of org.kie.api.definition.type.FactType in project drools by kiegroup.

the class UserDefinedFunctionsTest method testFunctions0.

@Test
public void testFunctions0() throws Exception {
    setKSession(getModelSession(source0, VERBOSE));
    setKbase(getKSession().getKieBase());
    FactType userAge1 = getKbase().getFactType(packageName, "UserAge");
    PMMLRequestData request = new PMMLRequestData("TestSimple");
    request.addRequestParam("Age", 2.2);
    getKSession().insert(request);
    // getKSession().getEntryPoint( "in_Age" ).insert( 2.2 );
    getKSession().fireAllRules();
    System.out.println(reportWMObjects(getKSession()));
    checkFirstDataFieldOfTypeStatus(userAge1, true, false, null, 22.0);
    checkGeneratedRules();
}
Also used : PMMLRequestData(org.kie.api.pmml.PMMLRequestData) FactType(org.kie.api.definition.type.FactType) DroolsAbstractPMMLTest(org.kie.pmml.pmml_4_2.DroolsAbstractPMMLTest) Test(org.junit.Test)

Example 87 with FactType

use of org.kie.api.definition.type.FactType in project drools by kiegroup.

the class UserDefinedFunctionsTest method testFunctions2.

@Test
public void testFunctions2() throws Exception {
    setKSession(getModelSession(source3, VERBOSE));
    setKbase(getKSession().getKieBase());
    FactType userAge2 = getKbase().getFactType(packageName, "UserAge2");
    getKSession().getEntryPoint("in_Age").insert(10);
    getKSession().fireAllRules();
    checkFirstDataFieldOfTypeStatus(userAge2, true, false, null, 0.1);
    checkGeneratedRules();
}
Also used : FactType(org.kie.api.definition.type.FactType) DroolsAbstractPMMLTest(org.kie.pmml.pmml_4_2.DroolsAbstractPMMLTest) Test(org.junit.Test)

Example 88 with FactType

use of org.kie.api.definition.type.FactType in project drools by kiegroup.

the class UserDefinedFunctionsTest method testFunctionsNested.

@Test
public void testFunctionsNested() throws Exception {
    setKSession(getModelSession(source1, VERBOSE));
    setKbase(getKSession().getKieBase());
    FactType userAge1 = getKbase().getFactType(packageName, "UserAge");
    getKSession().getEntryPoint("in_Age").insert(10.0);
    getKSession().fireAllRules();
    System.out.println(reportWMObjects(getKSession()));
    checkFirstDataFieldOfTypeStatus(userAge1, true, false, null, 130.0);
    checkGeneratedRules();
}
Also used : FactType(org.kie.api.definition.type.FactType) DroolsAbstractPMMLTest(org.kie.pmml.pmml_4_2.DroolsAbstractPMMLTest) Test(org.junit.Test)

Example 89 with FactType

use of org.kie.api.definition.type.FactType in project drools by kiegroup.

the class SVMTest method testSVM1vN.

@Test
public void testSVM1vN() throws Exception {
    setKSession(getModelSession(source2, VERBOSE));
    setKbase(getKSession().getKieBase());
    KieSession kSession = getKSession();
    // init model
    kSession.fireAllRules();
    FactType ztype = kSession.getKieBase().getFactType(packageName, "Z");
    assertNotNull(ztype);
    kSession.getEntryPoint("in_X").insert(0.0);
    kSession.getEntryPoint("in_Y").insert(0.0);
    kSession.fireAllRules();
    checkFirstDataFieldOfTypeStatus(ztype, true, false, "SVMXORMODEL", "no");
    checkFirstDataFieldOfTypeStatus(kSession.getKieBase().getFactType(packageName, "OutZ"), true, false, "SVMXORMODEL", "no");
    checkFirstDataFieldOfTypeStatus(kSession.getKieBase().getFactType(packageName, "ProbZNo"), true, false, "SVMXORMODEL", 0.7357588);
    checkGeneratedRules();
}
Also used : KieSession(org.kie.api.runtime.KieSession) FactType(org.kie.api.definition.type.FactType) DroolsAbstractPMMLTest(org.kie.pmml.pmml_4_2.DroolsAbstractPMMLTest) Test(org.junit.Test)

Example 90 with FactType

use of org.kie.api.definition.type.FactType in project drools by kiegroup.

the class SVMTest method testSVM.

@Test
public void testSVM() throws Exception {
    setKSession(getModelSession(source1, VERBOSE));
    setKbase(getKSession().getKieBase());
    KieSession kSession = getKSession();
    // init model
    kSession.fireAllRules();
    FactType ztype = kSession.getKieBase().getFactType(packageName, "Z");
    assertNotNull(ztype);
    kSession.getEntryPoint("in_X").insert(0.0);
    kSession.getEntryPoint("in_Y").insert(0.0);
    kSession.fireAllRules();
    System.out.println(reportWMObjects(kSession));
    checkFirstDataFieldOfTypeStatus(ztype, true, false, "SVMXORMODEL", "yes");
    kSession.getEntryPoint("in_X").insert(0.23);
    kSession.getEntryPoint("in_Y").insert(0.75);
    kSession.fireAllRules();
    checkFirstDataFieldOfTypeStatus(ztype, true, false, "SVMXORMODEL", "no");
    kSession.getEntryPoint("in_X").insert(0.85);
    kSession.fireAllRules();
    checkFirstDataFieldOfTypeStatus(ztype, true, false, "SVMXORMODEL", "yes");
    kSession.getEntryPoint("in_Y").insert(-0.12);
    kSession.fireAllRules();
    checkFirstDataFieldOfTypeStatus(ztype, true, false, "SVMXORMODEL", "no");
    kSession.getEntryPoint("in_X").insert(7.85);
    kSession.fireAllRules();
    System.out.println(reportWMObjects(kSession));
    checkFirstDataFieldOfTypeStatus(ztype, true, false, "SVMXORMODEL", "no");
    checkGeneratedRules();
}
Also used : KieSession(org.kie.api.runtime.KieSession) FactType(org.kie.api.definition.type.FactType) DroolsAbstractPMMLTest(org.kie.pmml.pmml_4_2.DroolsAbstractPMMLTest) Test(org.junit.Test)

Aggregations

FactType (org.kie.api.definition.type.FactType)208 Test (org.junit.Test)193 KieSession (org.kie.api.runtime.KieSession)114 KieBase (org.kie.api.KieBase)63 DroolsAbstractPMMLTest (org.drools.pmml.pmml_4_2.DroolsAbstractPMMLTest)45 DroolsAbstractPMMLTest (org.kie.pmml.pmml_4_2.DroolsAbstractPMMLTest)31 ArrayList (java.util.ArrayList)28 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)27 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)27 KieServices (org.kie.api.KieServices)22 ByteArrayResource (org.drools.core.io.impl.ByteArrayResource)18 Resource (org.kie.api.io.Resource)17 KieBuilder (org.kie.api.builder.KieBuilder)16 ClassObjectFilter (org.kie.api.runtime.ClassObjectFilter)16 KieFileSystem (org.kie.api.builder.KieFileSystem)15 KieContainer (org.kie.api.runtime.KieContainer)15 List (java.util.List)10 Results (org.kie.api.builder.Results)10 NamedEntryPoint (org.drools.core.common.NamedEntryPoint)9 LogicalTypeInconsistencyException (org.drools.core.factmodel.traits.LogicalTypeInconsistencyException)9