Beispiel #1
0
  public List<Family> getFamiliesTDT() {

    List<Family> families = new ArrayList<>();
    Individual ind;

    for (Map.Entry<String, Individual> entry : this.individuals.entrySet()) {
      ind = entry.getValue();
      if (ind.getFather() != null && ind.getMother() != null) {
        addIndividualToFamily(ind, ind.getFather(), ind.getMother(), families);
      }
    }
    return families;
  }
  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;
  }
Beispiel #3
0
  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("Pedigree\n");
    if (fields.size() > 0) {
      sb.append("fields = " + fields.keySet().toString() + "\n");
    }

    for (Map.Entry<String, Set<Individual>> elem : this.families.entrySet()) {
      sb.append(elem.getKey() + "\n");
      for (Individual ind : elem.getValue()) {
        sb.append("\t" + ind.toString() + "\n");
      }
    }
    return sb.toString();
  }
Beispiel #4
0
 /** Saves an individual to disk under a given filename, in computer-readable format. */
 public void storeIndividual(final EvolutionState state, String filename, Individual ind) {
   try {
     File file = openFile(state, filename);
     // PrintWriter writer = new PrintWriter(file);
     // ind.printIndividual(state, writer);
     // writer.close();
     int log =
         state.output.addLog(
             file,
             Output.V_NO_GENERAL - 1,
             false,
             !state.parameters.getBoolean(new Parameter(P_COMPRESS), null, false),
             state.parameters.getBoolean(new Parameter(P_COMPRESS), null, false));
     ind.printIndividual(state, log, Output.V_NO_GENERAL);
     state.output.message("Best Individual stored in " + filename);
   } catch (Exception e) {
     state.output.error("Exception " + e);
   }
 }
Beispiel #5
0
 public void addIndividual(Individual ind) {
   this.individuals.put(ind.getId(), ind);
 }