示例#1
0
 /**
  * It creates a new Population with only the sufficiently experienced classifiers.
  *
  * @param maxReward is the maximum reward of the environment.
  * @return a Population with the experienced population
  */
 public Population deleteNotExpClassifiers(double maxReward) {
   // We create a Config.popSize population instead of a macroClSum classifier, because, if it's
   // used in a training execution, this population can increase (new classifiers can be added).
   Population pExp = new Population(Config.popSize);
   for (int i = 0; i < macroClSum; i++) {
     if (set[i].couldReduce(maxReward)) {
       pExp.addClassifier(set[i]);
     }
   }
   return pExp;
 } // end deleteNotExpClassifiers
示例#2
0
  /**
   * It creates the D population defined by Wilson 2002. It creates a population with the minimum
   * number of classifiers that cover all the input examples.
   *
   * @param env Environment to be set in the new population.
   * @return the D population created
   */
  public Population createMCompPopulation(Environment env) {
    int moreMatches = 0, maxMatched = 0;

    // We create a Config.popSize population instead of a macroClSum classifier, because, if it's
    // used in a training execution, this population can increase (new classifiers can be added).
    Population Mcomp = new Population(Config.popSize);

    while (env.getNumberOfExamples() > 0 && macroClSum > 0) {
      moreMatches = 0;
      maxMatched = set[0].getNumberMatches();
      for (int i = 1; i < macroClSum; i++) {
        if (set[i].getNumberMatches() > maxMatched) {
          maxMatched = set[i].getNumberMatches();
          moreMatches = i;
        }
      }

      Mcomp.addClassifier(set[moreMatches]);
      env.deleteMatchedExamples(set[moreMatches]);
      deleteClassifier(moreMatches);
    }
    return Mcomp;
  } // end createMcompPopulation