use of com.sri.ai.util.math.Rational in project aic-expresso by aic-sri-international.
the class DefaultSymbolTest method testDisplayExact.
@Test
public void testDisplayExact() {
// NOTE: the tearDown method will set us back to the correct default.
ExpressoConfiguration.setDisplayNumericsExactlyForSymbols(true);
Assert.assertEquals("0.1", Expressions.makeSymbol(new Rational(1, 10)).toString());
Assert.assertEquals("1.1", Expressions.makeSymbol(new Rational(11, 10)).toString());
Assert.assertEquals("2/3", Expressions.makeSymbol(new Rational(2, 3)).toString());
Assert.assertEquals("0.123456789", Expressions.makeSymbol(new Rational(123456789, 1000000000)).toString());
Assert.assertEquals("0.999999999999999", Expressions.makeSymbol(new Rational(999999999999999L, 1000000000000000L)).toString());
Assert.assertEquals("1/3", Expressions.makeSymbol(new Rational(1, 3)).toString());
Assert.assertEquals("1/7", Expressions.makeSymbol(new Rational(1, 7)).toString());
Assert.assertEquals("-0.1", Expressions.makeSymbol(new Rational(-1, 10)).toString());
Assert.assertEquals("-1.1", Expressions.makeSymbol(new Rational(-11, 10)).toString());
Assert.assertEquals("-2/3", Expressions.makeSymbol(new Rational(-2, 3)).toString());
Assert.assertEquals("-0.123456789", Expressions.makeSymbol(new Rational(-123456789, 1000000000)).toString());
Assert.assertEquals("-0.999999999999999", Expressions.makeSymbol(new Rational(-999999999999999L, 1000000000000000L)).toString());
Assert.assertEquals("-1/3", Expressions.makeSymbol(new Rational(-1, 3)).toString());
Assert.assertEquals("-1/7", Expressions.makeSymbol(new Rational(-1, 7)).toString());
}
use of com.sri.ai.util.math.Rational in project aic-expresso by aic-sri-international.
the class MeasureTest method testTupleTypeDomain.
// (element_1, ..., element_n) = measure(element_1) * ... * measure(element_n)
@Test
public void testTupleTypeDomain() {
Assert.assertEquals(new Rational(6), measure("{{ (on T in (0..2 x Boolean)) T : true }}"));
Assert.assertEquals(new Rational(12), measure("{{ (on T in (0..2 x [3;7])) T : true }}"));
}
use of com.sri.ai.util.math.Rational in project aic-expresso by aic-sri-international.
the class MeasureTest method testRealTypeDomain.
@Test
public void testRealTypeDomain() {
Assert.assertEquals(new Rational(3), measure("{{ (on X in Real) X : X > 4 and X < 7 }}"));
Assert.assertEquals(new Rational(2), measure("{{ (on X in Real) X : X > 4 and X > 5 and X < 7 }}"));
Assert.assertEquals(new Rational(0), measure("{{ (on X in Real) X : X > 4 and X > 5 and X < 7 and X < 3 }}"));
}
use of com.sri.ai.util.math.Rational in project aic-expresso by aic-sri-international.
the class MeasureTest method testCategoricalTypeDomain.
@Test
public void testCategoricalTypeDomain() {
updateContextWithIndexAndType("N", new Categorical("People", 5, parse("p1"), parse("p2"), parse("p3"), parse("p4"), parse("p5")));
Assert.assertEquals(new Rational(5), measure("{{(on I in People) I : true}}"));
Assert.assertEquals(new Rational(4), measure("{{(on I in People) I : I != p1}}"));
Assert.assertEquals(new Rational(3), measure("{{(on I in People) I : I != p1 and I != p5}}"));
}
use of com.sri.ai.util.math.Rational in project aic-expresso by aic-sri-international.
the class MeasureTest method testIntegerIntervalTypeDomain.
@Test
public void testIntegerIntervalTypeDomain() {
Assert.assertEquals(new Rational(5), measure("{{ (on X in 3..7) X : true }}"));
Assert.assertEquals(new Rational(4), measure("{{ (on X in 3..7) X : X != 5 }}"));
}
Aggregations