Exemplo n.º 1
0
  /**
   * This method will return a naming String
   *
   * @return The name of the algorithm
   */
  public String getName() {
    String title = "PSOD-";

    String cognitivePart = "";
    if (algoTypeSimplified.isSelectedString(strNo)) {
      cognitivePart = getPhi1() + "_";
    } else {
      title += "VG-";
    }

    String typePart = "";
    if (algoTypePsod.isSelectedString(strAlgoTypeSixSigma)) {
      typePart = "6o_";
    }

    if (algoTypePsod.isSelectedString(strAlgoTypeStagnationRiot)) {
      typePart = "RS.";
      if (stagnationMeasure.isSelectedString("Generations")) typePart += "Gn.";
      else typePart += "Ft.";
      if (convergenceCondition.isSelectedString("Relative")) typePart += "Rel.";
      else typePart += "Abs.";

      typePart += getStagnationTime() + "_";
      typePart += getConvergenceThreshold() + "_";
    }

    return title + typePart + getTopology() + getTopologyRange() + "_" + cognitivePart + getPhi2();
  }
Exemplo n.º 2
0
 public void setAlgoTypeSimplified(SelectedTag algoTypeSimplified) {
   this.algoTypeSimplified = algoTypeSimplified;
   if (algoTypeSimplified.isSelectedString(strYes)) {
     algType.setSelectedTag(0); // inertness
     m_Phi1 = 0.0;
     m_Phi2 = 1.49445;
   } else {
     algType.setSelectedTag(1); // constriction
     m_Phi1 = 2.05;
     setPhi2(2.05);
   }
   GenericObjectEditor.setShowProperty(
       ParticleSwarmOptimization.class, "phi1", algoTypeSimplified.isSelectedString(strNo));
   GenericObjectEditor.setShowProperty(
       ParticleSwarmOptimization.class, "algoType", algoTypeSimplified.isSelectedString(strNo));
 }
Exemplo n.º 3
0
  public PSOD() {
    super();

    algoTypePsod = new SelectedTag(strAlgoTypeSixSigma, strAlgoTypeStagnationRiot);
    algoTypePsod.setSelectedTag(strAlgoTypeSixSigma);

    algoTypeSimplified = new SelectedTag(strNo, strYes);
    algoTypeSimplified.setSelectedTag(0);

    stagnationMeasure = new SelectedTag("Fitness calls", "Generations");
    this.pMetric = new PhenotypeMetric();
    this.stagnationMeasure.setSelectedTag(1);

    convergenceCondition = new SelectedTag("Relative", "Absolute");
    this.convergenceCondition.setSelectedTag(0);

    sigmaFilter = 0.7;
    lowLimit = 1;
    upLimit = 2;
  }
Exemplo n.º 4
0
 private boolean stagnationTimeHasPassed(PopulationInterface pop) {
   if (stagnationMeasure.isSelectedString("Fitness calls")) { // by fitness calls
     //			System.out.println("stagnationTimeHasPassed returns " + ((pop.getFunctionCalls() -
     // popFitCalls) >= m_stagTime) + " after " + (pop.getFunctionCalls() - popFitCalls));
     return (pop.getFunctionCalls() - popFitCalls) >= m_stagTime;
   } else { // by generation
     //			System.out.println("stagnationTimeHasPassed returns " + ((pop.getFunctionCalls() -
     // popGens) >= m_stagTime) + " after " + (pop.getFunctionCalls() - popGens));
     return (pop.getGeneration() - popGens) >= m_stagTime;
   }
 }
Exemplo n.º 5
0
 /**
  * Return true if |oldFit - curFit| < |oldFit| * thresh (relative case) and if |oldFit - curFit| <
  * thresh (absolute case).
  *
  * @param
  * @return
  */
 protected boolean isStillConverged(PopulationInterface pop) {
   double[] curFit = pop.getBestFitness();
   double dist = EuclideanMetric.euclideanDistance(oldFit, curFit);
   boolean ret;
   if (convergenceCondition.isSelectedString("Relative")) {
     ret = (dist < (oldNorm * convThresh));
   } else {
     ret = (dist < convThresh);
   }
   return ret;
 }
Exemplo n.º 6
0
 public void doHiding() {
   GenericObjectEditor.setShowProperty(
       ParticleSwarmOptimization.class, "phi1", algoTypeSimplified.isSelectedString(strNo));
   GenericObjectEditor.setShowProperty(
       getClass(),
       "convergenceCondition",
       algoTypePsod.isSelectedString(strAlgoTypeStagnationRiot));
   GenericObjectEditor.setShowProperty(
       getClass(), "stagnationMeasure", algoTypePsod.isSelectedString(strAlgoTypeStagnationRiot));
   GenericObjectEditor.setShowProperty(
       getClass(), "stagnationTime", algoTypePsod.isSelectedString(strAlgoTypeStagnationRiot));
   GenericObjectEditor.setShowProperty(
       getClass(),
       "convergenceThreshold",
       algoTypePsod.isSelectedString(strAlgoTypeStagnationRiot));
   GenericObjectEditor.setShowProperty(
       getClass(), "sigmaFilter", algoTypePsod.isSelectedString(strAlgoTypeSixSigma));
 }
Exemplo n.º 7
0
  protected double[] getAcceleration(
      double[] personalBestPos, double[] neighbourBestPos, double[] curPosition, double[][] range) {
    double[] accel = new double[curPosition.length];
    double chi;

    RNG.setRandomSeed();

    boolean bIsAlgoSixSigma = algoTypePsod.isSelectedString(strAlgoTypeSixSigma);
    boolean bIsStagOnRiot = algoTypePsod.isSelectedString(strAlgoTypeStagnationRiot);

    double gen = 0;
    boolean is_extreme = false;
    boolean is_partial = false;
    if (bIsAlgoSixSigma) {
      gen = RNG.gaussianDouble(sigmaFilter);

      // double chance_of_disagreements = RNG.randomDouble(0, 1);
      // if (execCursor < chance_of_disagreements) {
      if ((-2 < gen && gen <= -1) || (1 < gen && gen < 2)) // +- 2 sigma
      {
        partial_disagreements++;
        is_partial = true;
      } else {
        if (gen <= -2 || gen >= 2) {
          extreme_disagreements++;
          is_extreme = true;
        }
      }
      // }
    } else {
      if (bIsStagOnRiot && riotReady) {
        extreme_disagreements++;
        is_extreme = true;
      }
    }

    for (int i = 0; i < personalBestPos.length; i++) {
      // the component from the old velocity
      accel[i] = 0;

      if (algType.getSelectedTag().getID() == 1) chi = m_InertnessOrChi;
      else chi = 1.;

      // the component from the social model
      double agreedAccel = neighbourBestPos[i] - curPosition[i]; // common PSO case

      if (bIsAlgoSixSigma) {
        if (is_partial) // +- 2 sigma
        {
          // make partial disagreements
          double partialDisagreement = RNG.randomDouble(-1.0 * lowLimit, lowLimit);
          agreedAccel *= partialDisagreement;
        } else {
          if (is_extreme) {
            double extremeDisagreement = RNG.randomDouble(-1.0 * lowLimit, lowLimit);
            // agreedAccel *= extremeDisagreement;
            if (extremeDisagreement < 0)
              agreedAccel *= (extremeDisagreement - (upLimit - lowLimit)); // -2 to -1
            else agreedAccel *= (extremeDisagreement + (upLimit - lowLimit)); // 1 to 2*/
          }
        }
      } else {
        if (bIsStagOnRiot && is_extreme) {
          double extremeDisagreement = RNG.randomDouble(-1.0 * lowLimit, lowLimit);
          if (extremeDisagreement < 0)
            agreedAccel *= (extremeDisagreement - (upLimit - lowLimit)); // -2 to -1
          else agreedAccel *= (extremeDisagreement + (upLimit - lowLimit)); // 1 to 2
        }
      }

      // the component from the cognition model (invalid in Pederson case)
      if (algoTypeSimplified.isSelectedString(strNo))
        accel[i] =
            this.m_Phi1 * chi * RNG.randomDouble(0, 1) * (personalBestPos[i] - curPosition[i]);
      // the component from social model
      accel[i] += this.m_Phi2 * chi * RNG.randomDouble(0, 1) * agreedAccel;
    }
    return accel;
  }