Example #1
0
  @Test
  public void testUnion() {
    Parameters params = Parameters.getAllDefaultParameters();
    Parameters arg = Parameters.getAllDefaultParameters();
    arg.setParameterByKey(KEY.CELLS_PER_COLUMN, 5);

    assertTrue((int) params.getParameterByKey(KEY.CELLS_PER_COLUMN) != 5);
    params.union(arg);
    assertTrue((int) params.getParameterByKey(KEY.CELLS_PER_COLUMN) == 5);
  }
Example #2
0
 @Test
 public void testDefaultsAndUpdates() {
   Parameters params = Parameters.getAllDefaultParameters();
   assertEquals(params.getParameterByKey(Parameters.KEY.CELLS_PER_COLUMN), 32);
   assertEquals(params.getParameterByKey(Parameters.KEY.SEED), 42);
   assertEquals(
       true,
       ((Random) params.getParameterByKey(Parameters.KEY.RANDOM))
           .getClass()
           .equals(MersenneTwister.class));
   System.out.println("All Defaults:\n" + Parameters.getAllDefaultParameters());
   System.out.println("Spatial Defaults:\n" + Parameters.getSpatialDefaultParameters());
   System.out.println("Temporal Defaults:\n" + Parameters.getTemporalDefaultParameters());
   parameters = Parameters.getSpatialDefaultParameters();
   parameters.setParameterByKey(Parameters.KEY.INPUT_DIMENSIONS, new int[] {64, 64});
   parameters.setParameterByKey(Parameters.KEY.COLUMN_DIMENSIONS, new int[] {32, 32});
   parameters.setParameterByKey(Parameters.KEY.NUM_ACTIVE_COLUMNS_PER_INH_AREA, 0.02 * 64 * 64);
   System.out.println("Updated/Combined:\n" + parameters);
 }
Example #3
0
 @Test
 public void testApply() {
   DummyContainer dc = new DummyContainer();
   Parameters params = Parameters.getAllDefaultParameters();
   params.setParameterByKey(Parameters.KEY.COLUMN_DIMENSIONS, new int[] {2048});
   params.setParameterByKey(Parameters.KEY.POTENTIAL_PCT, 20.0);
   params.setParameterByKey(Parameters.KEY.CELLS_PER_COLUMN, null);
   params.apply(dc);
   assertTrue(Arrays.equals(new int[] {2048}, dc.getColumnDimensions()));
   assertEquals(20.0, dc.getPotentialPct(), 0);
 }
Example #4
0
  @Test
  public void testPrettyPrintDatum() {
    Parameters parameters = Parameters.getAllDefaultParameters();
    Connections connections = new Connections();
    parameters.apply(connections);

    TemporalMemory temporalMemory = new TemporalMemory();
    TemporalMemory.init(connections);
    MonitoredTemporalMemory monitoredTM = new MonitoredTemporalMemory(temporalMemory, connections);

    Metric metric = new Metric(monitoredTM, "Test", Arrays.asList(2.3, 3.4, 5.5, 6.6, 7.7));

    MetricsTrace trace = null;
    String traceData = null;
    try {
      trace = new MetricsTrace(monitoredTM, "Test");
      traceData = trace.prettyPrintDatum(metric);
    } catch (Exception e) {
      fail();
    }

    assertEquals("min: 2.30, max: 7.70, sum: 25.50, mean: 5.10, std dev: 1.99", traceData);
  }