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 tree.
private static List<TableFactor> tree(int depth, int childrenPerNode, Function<ArrayList<TableVariable>, ArrayList<Double>> entryGen, int cardinality) {
TableVariable[][] treeVars = treeVariables(depth, childrenPerNode, cardinality);
List<TableFactor> result = new ArrayList<>();
for (int i = 0; i < depth; i++) {
for (int j = 0; j < pow(childrenPerNode, i); j++) {
ArrayList<TableVariable> vars = listWithVariableNodeAndItschildren(depth, childrenPerNode, treeVars, i, j);
TableFactor newNode = new TableFactor(vars, entryGen.apply(vars));
result.add(newNode);
}
}
return result;
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor in project aic-praise by aic-sri-international.
the class PerformanceTest method constructEquivalentRandomFactorsRepresentedInDifferentWays.
// / FACTOR CONSTRUCTION METHODS ////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////////////
private List<Factor> constructEquivalentRandomFactorsRepresentedInDifferentWays(SpecsForRandomTableFactorGeneration factorSpecs) {
TableFactor tableFactor = makeRandomTableFactor(factorSpecs, FROM_VARIABLE_INDEX_TO_NAME, RANDOM);
ArrayList<Factor> factors = new ArrayList<>(NUMBER_OF_TESTED_FACTORS);
if (includeTableFactor) {
addTableFactorToListOfFactors(tableFactor, factors);
}
if (includeTreeBasedExpressionFactors) {
addTreeBasedExpressionFactorsToListOfFactors(tableFactor, factors);
}
if (includeLinearTableExpressionFactors) {
addLinearTableExpressionFactorsToListOfFactors(tableFactor, factors);
}
return factors;
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor in project aic-praise by aic-sri-international.
the class PerformanceTest method addTreeBasedExpressionFactorsToListOfFactors.
private void addTreeBasedExpressionFactorsToListOfFactors(TableFactor tableFactor, ArrayList<Factor> factors) {
Factor newFactor;
for (Theory theory : THEORIES_TO_TEST) {
newFactor = TABLE_TO_EXPRESSION_FACTOR_CONVERTER.convert(tableFactor, theory, true);
factors.add(newFactor);
}
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor in project aic-praise by aic-sri-international.
the class PerformanceTest method addLinearTableExpressionFactorsToListOfFactors.
private void addLinearTableExpressionFactorsToListOfFactors(TableFactor tableFactor, ArrayList<Factor> factors) {
Factor newFactor;
for (Theory theory : THEORIES_TO_TEST) {
newFactor = TABLE_TO_EXPRESSION_FACTOR_CONVERTER.convert(tableFactor, theory, false);
factors.add(newFactor);
}
}
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 testf2f1SumOutV1.
@Test
public void testf2f1SumOutV1() {
println();
println("SUM OUT V1 from F2*F1");
println("------------------");
ArrayList<TableVariable> variablesToSumOut = Util.arrayList(V1);
TableFactor f2f1SumOutV1 = (TableFactor) (f2.multiply(f1)).sumOut(variablesToSumOut);
f2f1SumOutV1.setName("f2f1SumOutV1");
println(f2f1SumOutV1);
assertEquals("f2f1SumOutV1[{V2:card=3}, {V4:card=2}, {V3:card=4}]: [22.0, 22.0, 22.0, 22.0, " + "24.0, 24.0, 24.0, 24.0, " + "42.0, 42.0, 42.0, 42.0, " + "44.0, 44.0, 44.0, 44.0, " + "62.0, 62.0, 62.0, 62.0, " + "64.0, 64.0, 64.0, 64.0]", f2f1SumOutV1.toString());
println();
}
Aggregations