ErrorSelection.java [src/java/m/ann/selection/mechanism] Revision: default  Date:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package m.ann.selection.mechanism;

import java.util.ArrayList;
import java.util.List;
import m.ann.selection.Selected;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.encog.neural.neat.NEATNetwork;

/**
 *
 * @author sidereus
 */
public class ErrorSelection extends SelectionMechanism {

  public ErrorSelection(String varName, String errorName, double threshold, String ann) {
    super(varName, errorName, threshold, ann);
  }

  @Override
  public Selected select() {
    List<ObjectId> id = new ArrayList<>();
    List<NEATNetwork> nn = new ArrayList<>();
    double tError = 0.0;

    for (Document dd : D) {
      if (errorOutOfBounds(dd, THRESHOLD)) {
        break;
      }
      addIdNN(dd, id, nn);
      tError = getError(dd);
    }
    return new Selected(id, nn, tError);
  }
}