예제 #1
0
 /**
  * As TRIBES manages an own structured set of particles (the list of Tribes containing explorers
  * and memories), the setPopulation method is only telling Tribes the range of the indiviuals in
  * the beginning of the run, the individuals will be discarded.
  */
 public void setPopulation(Population pop) {
   if (pop == null) return;
   population = pop;
   if (population.get(0) instanceof InterfaceDataTypeDouble) {
     range = ((InterfaceDataTypeDouble) population.get(0)).getDoubleRange();
     setDimension(range.length);
   } else {
     System.err.println(
         "warning, TRIBES requires InterfaceESIndidivual instead of "
             + population.get(0).getClass()
             + ". Couldnt correctly init the problem range.");
   }
 }
  /**
   * This method allows you to merge to populations into an archive. This method will add elements
   * from pop to the archive but will also remove elements from the archive if the archive target
   * size is exceeded.
   *
   * @param pop The population that may add Individuals to the archive.
   */
  public void addElementsToArchive(Population pop) {

    if (pop.getArchive() == null) pop.SetArchive(new Population());

    // test for each element in population if it
    // is dominating a element in the archive
    for (int i = 0; i < pop.size(); i++) {
      if (this.isDominant((AbstractEAIndividual) pop.get(i), pop.getArchive())) {
        this.addIndividualToArchive(
            (AbstractEAIndividual) ((AbstractEAIndividual) pop.get(i)).clone(), pop.getArchive());
      }
    }

    // Now clear the archive of surplus individuals
    Population archive = pop.getArchive();

    this.m_Cleaner.removeSurplusIndividuals(archive);
  }
예제 #3
0
 protected TribesExplorer positionToExplorer(TribesPosition pos) {
   TribesExplorer tmp = (TribesExplorer) population.get(0);
   if (tmp == null) System.err.println("Error in Tribes::positionToExplorer!");
   TribesExplorer indy = tmp.clone();
   indy.clearPosVel();
   indy.SetDoubleGenotype(pos.getPos());
   indy.SetFitness(pos.getFitness());
   return indy;
 }
예제 #4
0
  /** This method will optimize */
  public void optimize() {
    AbstractEAIndividual indy;
    Population original = (Population) this.m_Population.clone();
    double tmpD;
    InterfaceMutation tmpMut;

    for (int i = 0; i < this.m_Population.size(); i++) {
      indy = ((AbstractEAIndividual) this.m_Population.get(i));
      tmpD = indy.getMutationProbability();
      indy.setMutationProbability(1.0);
      if (mutator == null) indy.mutate();
      else mutator.mutate(indy);
      indy.setMutationProbability(tmpD);
    }
    this.m_Problem.evaluate(this.m_Population);
    for (int i = 0; i < this.m_Population.size(); i++) {
      if (((AbstractEAIndividual) original.get(i))
          .isDominatingDebConstraints(((AbstractEAIndividual) this.m_Population.get(i)))) {
        this.m_Population.remove(i);
        this.m_Population.add(i, original.get(i));
      } else {
        // else: mutation improved the individual
      }
    }
    this.m_Population.incrGeneration();
    //        for (int i = 0; i < this.m_Population.size(); i++) {
    //            indy1 = (AbstractEAIndividual) this.m_Population.get(i);
    //            indy2 = (AbstractEAIndividual)(indy1).clone();
    //            indy2.mutate();
    //            this.m_Problem.evaluate((AbstractEAIndividual) indy2);
    //            //indy2.SetFitness(0, indy2.evaulateAsMiniBits());
    //            this.m_Population.incrFunctionCalls();
    //            //if (indy2.getFitness(0) < indy1.getFitness(0)) {
    //            if (indy2.isDominating(indy1)) {
    //                this.m_Population.remove(i);
    //                this.m_Population.add(i, indy2);
    //            }
    //        }
    //        this.m_Population.incrGeneration();
    this.firePropertyChangedEvent(Population.nextGenerationPerformed);
  }