public boolean needsToRun(Run run, int generation) {
    Population pop = getPopulationFor(run, generation);
    int count = run.getIntProperty(GenetikConstants.POPULATION, Integer.MAX_VALUE, true);
    int scoreCount = 0;

    for (int i = 0, max = pop.size(); i < max; i++) {
      Individual ind = pop.get(i);

      if (ind.hasFitness() && ind.hasScores()) {
        scoreCount++;
      }
    }

    return scoreCount != count;
  }
예제 #2
0
  public Individual[] generateChildren(Individual[] parents, Run run) {
    Individual parent = parents[0];
    Individual retVal = parent.duplicate();

    retVal.setId(parent.getId());
    retVal.setParentOne(parent.getId());
    retVal.setParentTwo(null);

    Individual[] children = {retVal};

    return children;
  }