Search in sources :

Example 16 with TableVariable

use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable 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 17 with TableVariable

use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable 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)

Example 18 with TableVariable

use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable 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();
}
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 19 with TableVariable

use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable 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();
}
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 20 with TableVariable

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

the class TableFactorTest method testf2SumOutV2V4.

@Test
public void testf2SumOutV2V4() {
    println();
    println("SUM OUT V2 and V4 from F2");
    println("-------------------------------");
    ArrayList<TableVariable> variablesToSumOut = Util.arrayList(V2, V4);
    ConstantFactor f2SumOutV2V4 = (ConstantFactor) f2.sumOut(variablesToSumOut);
    // f1SumOutV1V2V3.setName("f1SumOutV1V2V3");  cannot set name of a [now] ConstantFactor
    print("f2SumOutV2V4: ");
    println(f2SumOutV2V4);
    assertEquals("129.0", f2SumOutV2V4.toString());
    println();
}
Also used : ConstantFactor(com.sri.ai.praise.core.representation.interfacebased.factor.core.ConstantFactor) TableVariable(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable) Test(org.junit.Test)

Aggregations

TableVariable (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable)49 TableFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor)34 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)13 Util.mapIntoArrayList (com.sri.ai.util.Util.mapIntoArrayList)10 Variable (com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable)8 LinkedHashMap (java.util.LinkedHashMap)8 List (java.util.List)8 TableFactor.copyToSubTableFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor.copyToSubTableFactor)7 TableFactorNetwork (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactorNetwork)6 Pair (com.sri.ai.util.base.Pair)6 Expression (com.sri.ai.expresso.api.Expression)4 Factor (com.sri.ai.praise.core.representation.interfacebased.factor.api.Factor)3 DefaultDatapoint (com.sri.ai.praise.learning.parameterlearning.representation.dataset.DefaultDatapoint)3 DefaultDataset (com.sri.ai.praise.learning.parameterlearning.representation.dataset.DefaultDataset)3 TableBayesianNode (com.sri.ai.praise.learning.parameterlearning.representation.table.TableBayesianNode)3 Util (com.sri.ai.util.Util)3 Util.arrayList (com.sri.ai.util.Util.arrayList)3 File (java.io.File)3 LinkedList (java.util.LinkedList)3