コード例 #1
0
 @Override
 public void initializeByPopulation(Population pop, boolean reset) {
   this.setPopulation((Population) pop.clone());
   if (reset) {
     this.getPopulation().initialize();
     this.optimizationProblem.evaluate(this.getPopulation());
     this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
   }
 }
コード例 #2
0
ファイル: MOCCOState.java プロジェクト: openea/eva2
  public void addPopulation2History(Population pop) {
    InterfaceOptimizationObjective[] tmpObj = null;

    if (this.show == null) {
      this.use = new boolean[1];
      this.use[0] = true;
      this.show = new boolean[1];
      this.show[0] = true;
      this.colors = new Color[1];
      this.colors[0] = this.getColor4Index(0);
    } else {
      boolean[] newUse = new boolean[this.show.length + 1];
      boolean[] newShow = new boolean[this.show.length + 1];
      Color[] newColor = new Color[this.show.length + 1];
      for (int i = 0; i < this.show.length; i++) {
        newUse[i] = this.use[i];
        newShow[i] = this.show[i];
        newColor[i] = this.colors[i];
      }
      newUse[show.length] = true;
      newShow[show.length] = true;
      newColor[show.length] = this.getColor4Index(this.populationHistory.length);
      this.use = newUse;
      this.show = newShow;
      this.colors = newColor;
    }

    Population[] newPop = new Population[this.populationHistory.length + 1];
    System.arraycopy(this.populationHistory, 0, newPop, 0, this.populationHistory.length);
    newPop[newPop.length - 1] = (Population) pop.clone();
    newPop[newPop.length - 1].addPopulation(newPop[newPop.length - 1].getArchive());
    newPop[newPop.length - 1].SetArchive(null);
    this.populationHistory = newPop;
    ArrayList fitness = new ArrayList();
    ArrayList objectives = new ArrayList();
    ArrayList constraint = new ArrayList();
    if (this.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
      tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.currentProblem).getProblemObjectives();
    }
    for (int j = 0; j < newPop[newPop.length - 1].size(); j++) {
      if (tmpObj != null) {
        double[] tmoF = new double[tmpObj.length];
        for (int k = 0; k < tmpObj.length; k++) {
          tmoF[k] = (Double) newPop[newPop.length - 1].get(j).getData(tmpObj[k].getIdentName());
        }
        objectives.add(tmoF);
      }
      fitness.add(newPop[newPop.length - 1].get(j).getFitness());
      constraint.add(newPop[newPop.length - 1].get(j).getConstraintViolation());
    }
    if (this.objectiveCache != null) {
      this.objectiveCache.add(objectives);
    }
    this.fitnessCache.add(fitness);
    this.constraintCache.add(constraint);
  }
コード例 #3
0
ファイル: FloodAlgorithm.java プロジェクト: openea/eva2
 /**
  * This method will initialize the optimizer with a given population
  *
  * @param reset If true the population is reset.
  */
 @Override
 public void initializeByPopulation(Population pop, boolean reset) {
   this.population = (Population) pop.clone();
   if (reset) {
     this.population.initialize();
     this.optimizationProblem.evaluate(this.population);
     this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
   }
   this.currentFloodPeak = this.initialFloodPeak;
 }