Esempio n. 1
0
  public void testPotentialConnections() {
    Variable v1 = new Variable(2);
    Variable v2 = new Variable(2);
    Variable v3 = new Variable(2);
    Variable[] vars = new Variable[] {v1, v2, v3};
    FactorGraph mdl = new FactorGraph();

    TableFactor ptl = new TableFactor(vars, new double[8]);
    mdl.addFactor(ptl);

    assertTrue(mdl.isAdjacent(v1, v2));
    assertTrue(mdl.isAdjacent(v2, v3));
    assertTrue(mdl.isAdjacent(v1, v3));
  }
Esempio n. 2
0
  public void testThreeNodeModel() {
    Random r = new Random(23534709);

    FactorGraph mdl = new FactorGraph();
    Variable root = new Variable(2);
    Variable childL = new Variable(2);
    Variable childR = new Variable(2);

    mdl.addFactor(root, childL, RandomGraphs.generateMixedPotentialValues(r, 1.5));
    mdl.addFactor(root, childR, RandomGraphs.generateMixedPotentialValues(r, 1.5));

    //    assertTrue (mdl.isConnected (root, childL));
    //    assertTrue (mdl.isConnected (root, childR));
    //    assertTrue (mdl.isConnected (childL, childR));
    assertTrue(mdl.isAdjacent(root, childR));
    assertTrue(mdl.isAdjacent(root, childL));
    assertTrue(!mdl.isAdjacent(childL, childR));

    assertTrue(mdl.factorOf(root, childL) != null);
    assertTrue(mdl.factorOf(root, childR) != null);
  }