Search in sources :

Example 16 with TableFactor

use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor in project aic-praise by aic-sri-international.

the class BenchmarkingIsingModel method testAEBP.

private static void testAEBP(AEBPTestingDataFrame df, int nRepetitions, int timeLimit, int complexity, LinkedList<Pair<Double, Double>> weights, BiFunction<Integer, Pair<Double, Double>, List<? extends Factor>> networkGenerator, BiFunction<Integer, List<TableFactor>, TableVariable> getQuery, String netName) {
    for (Pair<Double, Double> weight : weights) {
        for (int i = 0; i < nRepetitions; i++) {
            @SuppressWarnings("unchecked") List<TableFactor> network = (List<TableFactor>) networkGenerator.apply(complexity, weight);
            TableVariable query = getQuery.apply(complexity, network);
            testAEBPP(df, i, timeLimit, network, query, netName + " - " + complexity);
        }
    }
}
Also used : TableFactor(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor) List(java.util.List) LinkedList(java.util.LinkedList) TableVariable(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable)

Example 17 with TableFactor

use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor in project aic-praise by aic-sri-international.

the class BenchmarkingIsingModel method testEBP.

private static void testEBP(AEBPTestingDataFrame df, int nRepetitions, LinkedList<Integer> complexities, LinkedList<Pair<Double, Double>> weights, BiFunction<Integer, Pair<Double, Double>, List<? extends Factor>> networkGenerator, BiFunction<Integer, List<TableFactor>, TableVariable> getQuery, String netName) {
    // TestEBP
    for (Integer complexity : complexities) {
        for (Pair<Double, Double> weight : weights) {
            @SuppressWarnings("unchecked") List<TableFactor> network = (List<TableFactor>) networkGenerator.apply(complexity, weight);
            TableVariable query = getQuery.apply(complexity, network);
            testEBPP(df, nRepetitions, network, query, netName + " - " + complexity);
        }
    }
}
Also used : TableFactor(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor) List(java.util.List) LinkedList(java.util.LinkedList) TableVariable(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable)

Example 18 with TableFactor

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 testf2SumOutV2.

public void testf2SumOutV2() {
    println();
    println("SUM OUT V2 from F2");
    println("------------------");
    ArrayList<TableVariable> variablesToSumOut = Util.arrayList(V2);
    TableFactor f2SumOutV2 = (TableFactor) f2.sumOut(variablesToSumOut);
    f2SumOutV2.setName("f2SumOutV2");
    println(f2SumOutV2);
    assertEquals("f2SumOutV2[{V4:card=2}]: [63.0, 66.0]", f2SumOutV2.toString());
    println();
}
Also used : TableFactor(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor) TableVariable(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable)

Example 19 with TableFactor

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 testf1SumOutV1V2.

@Test
public void testf1SumOutV1V2() {
    println();
    println("SUM OUT V1 and V2 frpm F1");
    println("-------------------------");
    ArrayList<TableVariable> variablesToSumOut = Util.arrayList(V1, V2);
    TableFactor f1SumOutV1V2 = (TableFactor) f1.sumOut(variablesToSumOut);
    f1SumOutV1V2.setName("f1SumOutV1V2");
    println(f1SumOutV1V2);
    assertEquals("f1SumOutV1V2[{V3:card=4}]: [6.0, 6.0, 6.0, 6.0]", f1SumOutV1V2.toString());
    println();
}
Also used : TableFactor(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor) TableVariable(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable) Test(org.junit.Test)

Example 20 with TableFactor

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 testf2f1SumOutV1V2V3.

@Test
public void testf2f1SumOutV1V2V3() {
    println();
    println("SUM OUT V1, V2, and V3 from F2*F1");
    println("------------------");
    ArrayList<TableVariable> variablesToSumOut = Util.arrayList(V1, V2, V3);
    TableFactor f2f1SumOutV1V2V3 = (TableFactor) (f2.multiply(f1)).sumOut(variablesToSumOut);
    f2f1SumOutV1V2V3.setName("f2f1SumOutV1V2");
    println(f2f1SumOutV1V2V3);
    assertEquals("f2f1SumOutV1V2[{V4:card=2}]: [504.0, 528.0]", f2f1SumOutV1V2V3.toString());
    println();
}
Also used : TableFactor(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor) TableVariable(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable) Test(org.junit.Test)

Aggregations

TableFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor)52 TableVariable (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable)36 ArrayList (java.util.ArrayList)19 Test (org.junit.Test)11 Factor (com.sri.ai.praise.core.representation.interfacebased.factor.api.Factor)10 Util.mapIntoArrayList (com.sri.ai.util.Util.mapIntoArrayList)10 List (java.util.List)9 ExpressionFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.api.ExpressionFactor)8 TableFactor.copyToSubTableFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor.copyToSubTableFactor)8 Pair (com.sri.ai.util.base.Pair)7 Variable (com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable)6 TableFactorNetwork (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactorNetwork)6 LinkedHashMap (java.util.LinkedHashMap)6 Expression (com.sri.ai.expresso.api.Expression)5 DefaultExpressionFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.core.DefaultExpressionFactor)5 Util (com.sri.ai.util.Util)5 Util.arrayList (com.sri.ai.util.Util.arrayList)5 Util.println (com.sri.ai.util.Util.println)5 BiFunction (java.util.function.BiFunction)5 LinkedList (java.util.LinkedList)4