Ejemplo n.º 1
0
  @Test
  public void testGetNumConfigs() {
    Var v0 = getVar(0, 2);
    Var v1 = getVar(1, 3);
    Var v2 = getVar(2, 5);

    VarSet vars = new VarSet();
    vars.add(v0);
    vars.add(v1);
    vars.add(v2);

    assertEquals(2 * 3 * 5, vars.calcNumConfigs());
  }
Ejemplo n.º 2
0
  @Test
  public void testGetConfigArray1() {
    Var v0 = getVar(0, 2);
    Var v1 = getVar(1, 3);
    Var v2 = getVar(2, 5);

    VarSet vars1 = new VarSet();
    vars1.add(v0);
    vars1.add(v1);
    vars1.add(v2);

    VarSet vars2 = new VarSet();
    vars2.add(v1);
    vars2.add(v2);

    int[] configs = vars2.getConfigArr(vars1);
    System.out.println(Arrays.toString(configs));
    assertEquals(2 * 3 * 5, configs.length);
    Assert.assertArrayEquals(
        new int[] {
          0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13,
          13, 14, 14
        },
        configs);
  }
Ejemplo n.º 3
0
  @Test
  public void testGetConfigArray2Swapped() {
    Var v0 = getVar(0, 2);
    Var v1 = getVar(1, 3);
    Var v2 = getVar(2, 5);

    VarSet vars1 = new VarSet();
    vars1.add(v0);
    vars1.add(v1);
    vars1.add(v2);

    VarSet vars2 = new VarSet();
    vars2.add(v0);
    vars2.add(v2);

    System.out.println(new DenseFactor(vars1));

    // TODO: we can't loop over a particular configuration of vars1, only the config in which each
    // (non-vars2) variable has state 0.
    int[] configs = vars1.getConfigArr(vars2);
    System.out.println(Arrays.toString(configs));
    assertEquals(2 * 5, configs.length);
    Assert.assertArrayEquals(new int[] {0, 1, 6, 7, 12, 13, 18, 19, 24, 25}, configs);
  }