Пример #1
0
  /**
   * This constructor creates the match set of the population. It has to cover the uncovered actions
   * while, at least, the theta_mna actions aren't covered. It uses the actionCovered variable to do
   * this.
   *
   * @param envState is the state of the input (it has to take the classifiers that match with it).
   * @param pop is the population of the system (it contains all the classifiers).
   * @param tStamp it's the actual time. It's needed to create the new classifiers).
   * @param isExploreExecution indicates if the current step is an explore or an exploit trail,
   *     because the covering operator will be applied or not.
   */
  public Population(double[] envState, Population pop, int tStamp, boolean isExploreExecution) {
    int pos = 0;
    // A population of size parent.numerosity + numberOfActions is needed,
    // because in the worst case, it will have to cover all the actions.
    set = new Classifier[pop.macroClSum + Config.numberOfActions];
    microClSum = 0;
    macroClSum = 0;
    parentRef = pop;
    specify = new Specify();

    boolean[] actionCovered = new boolean[Config.numberOfActions];
    for (pos = 0; pos < actionCovered.length; pos++) {
      actionCovered[pos] = false;
    }

    for (pos = 0; pos < pop.getMacroClSum(); pos++) {
      if (pop.set[pos].match(envState)) {
        addClassifier(pop.set[pos]);
        actionCovered[pop.set[pos].getAction()] = true;
      }
    }

    if (isExploreExecution) {
      Covering cov = new Covering();
      cov.coverActions(pop, this, envState, tStamp, actionCovered);
    }
  } // end Population