use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class LinearNormalizedFieldsTest method testDerivedTypesLinearNormOutliers.
@Test
public void testDerivedTypesLinearNormOutliers() throws Exception {
// new PMML4Wrapper().getPmml().getTransformationDictionary().getDerivedField().get(0).getNormContinuous().getOutliers().value()
FactType age = getKbase().getFactType(packageName, "Age");
FactType age1 = getKbase().getFactType(packageName, "Age_norm");
FactType age2 = getKbase().getFactType(packageName, "Age_norm2");
FactType age3 = getKbase().getFactType(packageName, "Age_norm3");
// value is an outlier
getKSession().getEntryPoint("in_Age").insert(-100);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, -100);
checkFirstDataFieldOfTypeStatus(age1, true, false, null, 0.0);
checkFirstDataFieldOfTypeStatus(age2, true, true, null, 0.0);
checkFirstDataFieldOfTypeStatus(age3, true, false, null, -1.25);
refreshKSession();
// value is an outlier
getKSession().getEntryPoint("in_Age").insert(1000);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, 1000);
checkFirstDataFieldOfTypeStatus(age1, true, false, null, 2.0);
checkFirstDataFieldOfTypeStatus(age2, true, true, null, 0.0);
checkFirstDataFieldOfTypeStatus(age3, true, false, null, 12.5);
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class LinearNormalizedFieldsTest method testDerivedTypesLinearNormInterpolation.
@Test
public void testDerivedTypesLinearNormInterpolation() throws Exception {
// new PMML4Wrapper().getPmml().getTransformationDictionary().getDerivedField().get(0).getNormContinuous().getOutliers().value()
FactType age = getKbase().getFactType(packageName, "Age");
FactType age1 = getKbase().getFactType(packageName, "Age_norm");
getKSession().getEntryPoint("in_Age").insert(30);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, 30);
checkFirstDataFieldOfTypeStatus(age1, true, false, null, 0.375);
refreshKSession();
getKSession().getEntryPoint("in_Age").insert(90);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, false, null, 90);
checkFirstDataFieldOfTypeStatus(age1, true, false, null, 1.5);
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class LinearNormalizedFieldsTest method testDerivedTypesLinearNormMapMissing.
@Test
public void testDerivedTypesLinearNormMapMissing() throws Exception {
// new PMML4Wrapper().getPmml().getTransformationDictionary().getDerivedField().get(0).getNormContinuous().getOutliers().value()
FactType age = getKbase().getFactType(packageName, "Age");
FactType age1 = getKbase().getFactType(packageName, "Age_norm");
FactType age2 = getKbase().getFactType(packageName, "Age_norm2");
FactType age3 = getKbase().getFactType(packageName, "Age_norm3");
assertNotNull(getKSession().getEntryPoint("in_Age"));
assertNull(getKSession().getEntryPoint("in_Age_mis"));
assertNull(getKSession().getEntryPoint("in_Age_norm"));
// value is "missing" for age, so should be mapped by the mapMissingTo policy
getKSession().getEntryPoint("in_Age").insert(-1);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(age, true, true, null, -1);
checkFirstDataFieldOfTypeStatus(age1, true, false, null, 0.0);
checkFirstDataFieldOfTypeStatus(age2, true, false, null, -931.0);
checkFirstDataFieldOfTypeStatus(age3, true, false, null, 789.0);
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project jbpm by kiegroup.
the class AgendaFilterTest method newCancelFact.
private Object newCancelFact(KieSession ksession, boolean cancel) {
FactType type = ksession.getKieBase().getFactType("org.jboss.qa.brms.agendafilter", "CancelFact");
Object instance = null;
try {
instance = type.newInstance();
type.set(instance, "cancel", cancel);
} catch (IllegalAccessException ex) {
ex.printStackTrace();
} catch (InstantiationException ex) {
ex.printStackTrace();
}
return instance;
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class IndexingTest method testRange2.
@Test(timeout = 10000)
public void testRange2() throws Exception {
String rule = "package org.drools.compiler.test\n" + "declare A\n" + " a: int\n" + "end\n" + "declare B\n" + " b: int\n" + "end\n" + "declare C\n" + " c: int\n" + "end\n" + "rule R1 when\n" + " A( $a : a )\n" + " B( $b : b )\n" + " exists C( c > $a && < $b )\n" + "then\n" + " System.out.println( $a + \", \" + $b );\n" + "end";
KieBase kbase = loadKnowledgeBaseFromString(rule);
KieSession ksession = kbase.newKieSession();
FactType aType = kbase.getFactType("org.drools.compiler.test", "A");
FactType bType = kbase.getFactType("org.drools.compiler.test", "B");
FactType cType = kbase.getFactType("org.drools.compiler.test", "C");
Object a1 = aType.newInstance();
aType.set(a1, "a", 5);
ksession.insert(a1);
Object a2 = aType.newInstance();
aType.set(a2, "a", 11);
ksession.insert(a2);
Object b1 = bType.newInstance();
bType.set(b1, "b", 10);
ksession.insert(b1);
Object b2 = bType.newInstance();
bType.set(b2, "b", 6);
ksession.insert(b2);
Object c = cType.newInstance();
cType.set(c, "c", 7);
ksession.insert(c);
ksession.fireAllRules();
}
Aggregations