use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor in project aic-praise by aic-sri-international.
the class TableFactorTest method testMultiplicationf1f2.
@Test
public void testMultiplicationf1f2() {
println();
println("MULTIPLYING f1 * f2");
println("-------------------");
TableFactor f1f2 = (TableFactor) f1.multiply(f2);
f1f2.setName("f1f2");
println(f1f2);
assertEquals("phi[{V1:card=2}, {V2:card=3}, {V3:card=4}, {V4:card=2}]: [11.0, 12.0, 11.0, 12.0, 11.0, 12.0, 11.0, 12.0, " + "21.0, 22.0, 21.0, 22.0, 21.0, 22.0, 21.0, 22.0, " + "31.0, 32.0, 31.0, 32.0, 31.0, 32.0, 31.0, 32.0, " + "11.0, 12.0, 11.0, 12.0, 11.0, 12.0, 11.0, 12.0, " + "21.0, 22.0, 21.0, 22.0, 21.0, 22.0, 21.0, 22.0, " + "31.0, 32.0, 31.0, 32.0, 31.0, 32.0, 31.0, 32.0]", f1.multiply(f2).toString());
println();
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor in project aic-praise by aic-sri-international.
the class TableFactorTest method testf1SumOutV1.
@Test
public void testf1SumOutV1() {
println();
println("SUM OUT V1 from F1");
println("------------------");
ArrayList<TableVariable> variablesToSumOut = Util.arrayList(V1);
TableFactor f1SumOutV1 = (TableFactor) f1.sumOut(variablesToSumOut);
f1SumOutV1.setName("f1SumOutV1");
println(f1SumOutV1);
assertEquals("f1SumOutV1[{V2:card=3}, {V3:card=4}]: [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0]", f1SumOutV1.toString());
println();
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor in project aic-praise by aic-sri-international.
the class TableFactorTest method testf2SumOutV4.
public void testf2SumOutV4() {
println();
println("SUM OUT V4 from F2");
println("------------------");
ArrayList<TableVariable> variablesToSumOut = Util.arrayList(V4);
TableFactor f2SumOutV4 = (TableFactor) f2.sumOut(variablesToSumOut);
f2SumOutV4.setName("f2SumOutV4");
println(f2SumOutV4);
assertEquals("f2SumOutV4[{V4:card=2}]: [13.0, 23.0, 33.0]", f2SumOutV4.toString());
println();
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor in project aic-praise by aic-sri-international.
the class TableFactorTest method testf2f1SumOutV1V2.
@Test
public void testf2f1SumOutV1V2() {
println();
println("SUM OUT V1 and V2 from F2*F1");
println("------------------");
ArrayList<TableVariable> variablesToSumOut = Util.arrayList(V1, V2);
TableFactor f2f1SumOutV1V2 = (TableFactor) (f2.multiply(f1)).sumOut(variablesToSumOut);
f2f1SumOutV1V2.setName("f2f1SumOutV1V2");
println(f2f1SumOutV1V2);
assertEquals("f2f1SumOutV1V2[{V4:card=2}, {V3:card=4}]: [126.0, 126.0, 126.0, 126.0, 132.0, 132.0, 132.0, 132.0]", f2f1SumOutV1V2.toString());
println();
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor in project aic-praise by aic-sri-international.
the class TestCases method treeWithRandomEntries.
public static List<TableFactor> treeWithRandomEntries(int depth, int childrenPerNode, int cardinality, Function<Random, Double> randomGen) {
Random r = new Random();
Function<ArrayList<TableVariable>, ArrayList<Double>> entryGen = (l) -> Util.fill(pow(cardinality, l.size()), () -> randomGen.apply(r));
List<TableFactor> result = tree(depth, childrenPerNode, entryGen, cardinality);
return result;
}
Aggregations