@Test
  public void testCorrectness() {
    String costMethod = "MAXLIKELIHOOD";
    NominalProject project = setUpNominalProject();
    ILabelProbabilityDistributionCostCalculator lpdcc =
        LabelProbabilityDistributionCostCalculators.get(costMethod);
    IPriorityCalculator<String> pc = new CostBasedPriorityCalculator(lpdcc);
    Scheduler<String> scheduler = new Scheduler<String>(project, pc);
    Worker worker = new Worker("Worker1");
    INominalData data = project.getData();
    LObject<String> object1 = data.getOrCreateObject("object1");
    LObject<String> object2 = data.getOrCreateObject("object2");
    int w = 0;
    data.addAssign(assign(w++, object1, "A"));
    data.addAssign(assign(w++, object1, "B"));
    data.addAssign(assign(w++, object2, "A"));
    scheduler.update();
    LObject<String> object = scheduler.nextObject();
    assertEquals(object1, object);
    object = scheduler.nextObject();
    assertEquals(object1, object);
    scheduler.update();
    object = scheduler.nextObject();
    assertEquals(object1, object);

    data.addAssign(assign(w++, object2, "B"));
    data.addAssign(assign(w++, object2, "C"));
    scheduler.update();
    assertEquals(object2, scheduler.nextObject());

    data.addAssign(assign(w++, object2, "C"));
    data.addAssign(assign(w++, object2, "C"));
    scheduler.update();
    assertEquals(object1, scheduler.nextObject());
  }
 public static NominalProject setUpNominalProject() {
   IncrementalMV imv = new IncrementalMV();
   MemoryJobStorage js = new MemoryJobStorage();
   Collection<String> categories = Arrays.asList(new String[] {"A", "B", "C"});
   NominalProject project =
       new NominalProject(
           imv, js.getNominalData("testId"), js.getNominalResults("testId", categories));
   project.initializeCategories(categories, null, null);
   project.getData().addNewUpdatableAlgorithm(imv);
   return project;
 }
Пример #3
0
 @Test
 public void testBatchMV() {
   BatchMV mv = new BatchMV();
   NominalProject np = new NominalProject(mv);
   np.initializeCategories(categories, null, null);
   NominalData nd = np.getData();
   Results<String, DatumResult, WorkerResult> results = np.getResults();
   mv.setData(nd);
   mv.setResults(results);
   fillNominalData(nd);
   mv.compute();
   testMVResults(results);
 }
Пример #4
0
 @Test
 public void testIncrementalMV() {
   IncrementalMV mv = new IncrementalMV();
   NominalProject np = new NominalProject(mv);
   np.initializeCategories(categories, null, null);
   NominalData nd = np.getData();
   Results<String, DatumResult, WorkerResult> results = np.getResults();
   mv.setData(nd);
   mv.setResults(results);
   nd.addNewUpdatableAlgorithm(mv);
   fillNominalData(nd);
   testMVResults(results);
 }