Search in sources :

Example 36 with CommonTheory

use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.

the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method numericGroupTest03.

@Test
public void numericGroupTest03() {
    // get method name as string
    String testName = new Object() {
    }.getClass().getEnclosingMethod().getName();
    Theory theory = new CommonTheory();
    String[] symbolsAndTypes = {};
    Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
    Expression[] operandExpressions = { parse("1"), parse("2"), parse("3") };
    Expression[] expectedResultPerGroup = { parse("3"), parse("6"), parse("6") };
    repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, NUMERIC_GROUPS);
    println();
}
Also used : CommonTheory(com.sri.ai.grinder.application.CommonTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) CommonTheory(com.sri.ai.grinder.application.CommonTheory) Theory(com.sri.ai.grinder.api.Theory) Expression(com.sri.ai.expresso.api.Expression) TrueContext(com.sri.ai.grinder.core.TrueContext) Test(org.junit.Test)

Example 37 with CommonTheory

use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.

the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method numericGroupTestWithMaxOperands.

@Test
public void numericGroupTestWithMaxOperands() {
    // get method name as string
    String testName = new Object() {
    }.getClass().getEnclosingMethod().getName();
    Theory theory = new CommonTheory();
    String[] symbolsAndTypes = {};
    Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
    Expression[] operandExpressions = { parse("max({{(on I in 1..5) if I = 3 then 10 else I }})"), parse("max({{(on J in 10..20) if J < 10 then 10 else J }})") };
    Expression[] expectedResultPerGroup = { parse("20"), parse("200"), parse("30") };
    repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, NUMERIC_GROUPS);
    println();
}
Also used : CommonTheory(com.sri.ai.grinder.application.CommonTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) CommonTheory(com.sri.ai.grinder.application.CommonTheory) Theory(com.sri.ai.grinder.api.Theory) Expression(com.sri.ai.expresso.api.Expression) TrueContext(com.sri.ai.grinder.core.TrueContext) Test(org.junit.Test)

Example 38 with CommonTheory

use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.

the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method numericGroupTest02.

@Test
public void numericGroupTest02() {
    // get method name as string
    String testName = new Object() {
    }.getClass().getEnclosingMethod().getName();
    Theory theory = new CommonTheory();
    String[] symbolsAndTypes = {};
    Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
    Expression[] operandExpressions = { parse("1"), parse("2"), parse("0"), parse("3") };
    Expression[] expectedResultPerGroup = { parse("3"), parse("0"), parse("6") };
    repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, NUMERIC_GROUPS);
    println();
}
Also used : CommonTheory(com.sri.ai.grinder.application.CommonTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) CommonTheory(com.sri.ai.grinder.application.CommonTheory) Theory(com.sri.ai.grinder.api.Theory) Expression(com.sri.ai.expresso.api.Expression) TrueContext(com.sri.ai.grinder.core.TrueContext) Test(org.junit.Test)

Example 39 with CommonTheory

use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.

the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method quantifierBasedGroupTest05.

@Test
public void quantifierBasedGroupTest05() {
    // get method name as string
    String testName = new Object() {
    }.getClass().getEnclosingMethod().getName();
    Theory theory = new CommonTheory();
    String[] symbolsAndTypes = { "X", "0..2", "Y", "0..2" };
    Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
    Expression[] operandExpressions = { parse("if X != 1 then false else true"), parse("if Y = 2 then true else false") };
    Expression[] expectedResultPerGroup = { parse("if X != 1 then false else Y = 2"), parse("if X != 1 then Y = 2 else true") };
    repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, QUANTIFIER_BASED_GROUPS);
    println();
}
Also used : CommonTheory(com.sri.ai.grinder.application.CommonTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) CommonTheory(com.sri.ai.grinder.application.CommonTheory) Theory(com.sri.ai.grinder.api.Theory) Expression(com.sri.ai.expresso.api.Expression) TrueContext(com.sri.ai.grinder.core.TrueContext) Test(org.junit.Test)

Example 40 with CommonTheory

use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.

the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method numericGroupTest01.

@Test
public void numericGroupTest01() {
    // get method name as string
    String testName = new Object() {
    }.getClass().getEnclosingMethod().getName();
    Theory theory = new CommonTheory();
    String[] symbolsAndTypes = {};
    Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
    Expression[] operandExpressions = { parse("1"), parse("2") };
    Expression[] expectedResultPerGroup = { parse("2"), parse("2"), parse("3") };
    repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, NUMERIC_GROUPS);
    println();
}
Also used : CommonTheory(com.sri.ai.grinder.application.CommonTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) CommonTheory(com.sri.ai.grinder.application.CommonTheory) Theory(com.sri.ai.grinder.api.Theory) Expression(com.sri.ai.expresso.api.Expression) TrueContext(com.sri.ai.grinder.core.TrueContext) Test(org.junit.Test)

Aggregations

Context (com.sri.ai.grinder.api.Context)58 CommonTheory (com.sri.ai.grinder.application.CommonTheory)58 TrueContext (com.sri.ai.grinder.core.TrueContext)58 Expression (com.sri.ai.expresso.api.Expression)55 Test (org.junit.Test)47 Theory (com.sri.ai.grinder.api.Theory)36 Factor (com.sri.ai.praise.core.representation.interfacebased.factor.api.Factor)13 ExpressionFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.api.ExpressionFactor)13 DefaultExpressionFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.core.DefaultExpressionFactor)12 ConstantFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.ConstantFactor)11 CompoundTheory (com.sri.ai.grinder.theory.compound.CompoundTheory)9 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)9 EqualityTheory (com.sri.ai.grinder.theory.equality.EqualityTheory)9 LinearRealArithmeticTheory (com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory)9 PropositionalTheory (com.sri.ai.grinder.theory.propositional.PropositionalTheory)9 TupleTheory (com.sri.ai.grinder.theory.tuple.TupleTheory)9 DefaultExpressionVariable (com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.core.DefaultExpressionVariable)7 ExpressionVariable (com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.api.ExpressionVariable)5 ExpressionFactorNetwork (com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.core.ExpressionFactorNetwork)4 ArrayList (java.util.ArrayList)3