use of com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.api.ExpressionFactor in project aic-praise by aic-sri-international.
the class ExpressionFactorTest method testMax.
@Test
public void testMax() {
Context context = new TrueContext(new CommonTheory()).extendWithSymbolsAndTypes("U", "Boolean", "V", "Boolean");
ExpressionFactor factorUV = new DefaultExpressionFactor(parse("if U then if V then 4 else 2 else 3"), context);
ExpressionVariable u = new DefaultExpressionVariable(parse("U"));
List<ExpressionVariable> variablesToMaxOut = new ArrayList<>();
variablesToMaxOut.add(u);
Factor maxFactor = factorUV.max(variablesToMaxOut);
assertEquals("if V then 4 else 3", maxFactor.toString());
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.api.ExpressionFactor in project aic-praise by aic-sri-international.
the class ExpressionFactorTest method testMultiply3.
@Test
public void testMultiply3() {
Theory theory = new CommonTheory();
Context context = new TrueContext(theory);
Expression a = DefaultSymbol.createSymbol("a");
ExpressionFactor aFactor = new DefaultExpressionFactor(a, context);
Factor result = aFactor.multiply(ZERO_FACTOR);
assertEquals(ZERO_FACTOR, result);
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.api.ExpressionFactor in project aic-praise by aic-sri-international.
the class ExpressionFactorTest method testAdd4.
@Test
public void testAdd4() {
Theory theory = new CommonTheory();
Context context = new TrueContext(theory);
Expression a = DefaultSymbol.createSymbol("a");
ExpressionFactor aFactor = new DefaultExpressionFactor(a, context);
ConstantFactor tenFactor = new ConstantFactor(10.);
Factor result = aFactor.add(tenFactor);
assertEquals("10 + a", result.toString());
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.api.ExpressionFactor in project aic-praise by aic-sri-international.
the class ExpressionFactorTest method testAdd3.
@Test
public void testAdd3() {
Theory theory = new CommonTheory();
Context context = new TrueContext(theory);
Expression a = DefaultSymbol.createSymbol("a");
ExpressionFactor aFactor = new DefaultExpressionFactor(a, context);
Factor result = aFactor.add(ZERO_FACTOR);
assertEquals(aFactor, result);
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.api.ExpressionFactor in project aic-praise by aic-sri-international.
the class FromTableToExpressionFactorConverter method convert.
public ExpressionFactor convert(TableFactor tableFactor, Theory theory, boolean convertAsTreeBasedExpression) {
Expression expression = makeExpressionEquivalentToTableFactor(tableFactor, convertAsTreeBasedExpression);
Context context = makeContextWithVariablesFrom(tableFactor, theory);
ExpressionFactor expressionFactor = new DefaultExpressionFactor(expression, context);
return expressionFactor;
}
Aggregations