コード例 #1
0
  /**
   * Update the mean fitness variable.
   *
   * @param population a set representing the population.
   */
  private void updateMeanPopulationFitness(final ClassifierSet population) {
    meanPopulationFitness = 0;
    final int populationSize = population.getNumberOfMacroclassifiers();
    for (int i = 0; i < populationSize; i++) {
      final int clNumerosity = population.getClassifierNumerosity(i);
      final Classifier cl = population.getClassifier(i);
      final double fitness = ((UCSClassifierData) cl.getUpdateDataObject()).fitness;
      meanPopulationFitness += fitness * clNumerosity;
    }

    meanPopulationFitness /= population.getTotalNumerosity();
  }
コード例 #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * gr.auth.ee.lcs.data.UpdateAlgorithmFactoryAndStrategy#getComparisonValue
   * (gr.auth.ee.lcs.classifiers.Classifier, int)
   */
  @Override
  public double getComparisonValue(final Classifier aClassifier, final int mode) {
    final UCSClassifierData data = (UCSClassifierData) aClassifier.getUpdateDataObject();

    switch (mode) {
      case COMPARISON_MODE_EXPLORATION:
      case COMPARISON_MODE_EXPLOITATION:
        final double value =
            data.fitness
                * ((aClassifier.experience < deleteAge)
                    ? ((double) aClassifier.experience) / ((double) deleteAge)
                    : 1);
        return Double.isNaN(value) ? 0 : value;
      case COMPARISON_MODE_DELETION:
        if (aClassifier.experience < deleteAge) {
          final double result = (data.cs * meanPopulationFitness) / data.fitness;
          return Double.isNaN(result) ? 1 : result;
        }

        return data.cs;

        /*
         * final double acc = (((double) (data.tp)) / (double) (data.msa));
         * final double exploitValue = acc (aClassifier.experience <
         * deleteAge ? 0 : 1); return Double.isNaN(exploitValue) ? 0 :
         * exploitValue;
         */
      default:
        return 0;
    }
  }
コード例 #3
0
  /**
   * Perform an update to the set.
   *
   * @param matchSet the match set used for the update
   * @param correctSet the correct set used for the update
   */
  @Override
  public void performUpdate(final ClassifierSet matchSet, final ClassifierSet correctSet) {
    double strengthSum = 0;
    final int matchSetMacroclassifiers = matchSet.getNumberOfMacroclassifiers();
    final int correctSetSize = correctSet.getTotalNumerosity();
    for (int i = 0; i < matchSetMacroclassifiers; i++) {
      final Classifier cl = matchSet.getClassifier(i);
      UCSClassifierData data = ((UCSClassifierData) cl.getUpdateDataObject());
      cl.experience++;
      data.msa += 1;

      if (correctSet.getClassifierNumerosity(cl) > 0) {
        data.cs = data.cs + (b * (correctSetSize - data.cs));
        data.tp += 1;
        final double accuracy = ((double) data.tp) / ((double) data.msa);
        if (accuracy > accuracy0) {
          data.fitness0 = 1;

          // Check subsumption
          if (cl.experience >= this.subsumptionExperienceThreshold) cl.setSubsumptionAbility(true);

        } else {
          data.fitness0 = a * Math.pow(accuracy / accuracy0, n);
          cl.setSubsumptionAbility(false);
        }

        strengthSum += data.fitness0 * matchSet.getClassifierNumerosity(i);
      } else {
        data.fp += 1;
        data.fitness0 = 0;
      }
    }

    // Fix for avoiding problems...
    if (strengthSum == 0) strengthSum = 1;

    // double fitnessSum = 0;
    final int msSize = matchSet.getNumberOfMacroclassifiers();
    for (int i = 0; i < msSize; i++) {
      Classifier cl = matchSet.getClassifier(i);
      UCSClassifierData data = ((UCSClassifierData) cl.getUpdateDataObject());
      data.fitness += b * ((data.fitness0 / strengthSum) - data.fitness); // TODO:
      // Something
      // else?
      // fitnessSum += data.fitness * matchSet.getClassifierNumerosity(i);
    }
  }
コード例 #4
0
 @Override
 public void setComparisonValue(
     final Classifier aClassifier, final int mode, final double comparisonValue) {
   final UCSClassifierData data = ((UCSClassifierData) aClassifier.getUpdateDataObject());
   data.fitness = comparisonValue;
 }
コード例 #5
0
 @Override
 public String getData(final Classifier aClassifier) {
   final UCSClassifierData data = ((UCSClassifierData) aClassifier.getUpdateDataObject());
   return "tp:" + data.tp;
 }