| @@ -1,6 +1,7 @@ | ||||
| package eva2.optimization.individuals; | ||||
|  | ||||
| import eva2.tools.EVAERROR; | ||||
| import eva2.util.annotation.Parameter; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.util.Comparator; | ||||
| @@ -79,8 +80,8 @@ public class IndividualWeightedFitnessComparator implements Comparator<AbstractE | ||||
|         double[] f1 = o1.getFitness(); | ||||
|         double[] f2 = o2.getFitness(); | ||||
|  | ||||
|         double score1 = calcScore(f1); | ||||
|         double score2 = calcScore(f2); | ||||
|         double score1 = calculateScore(f1); | ||||
|         double score2 = calculateScore(f2); | ||||
|  | ||||
|         if (score1 < score2) { | ||||
|             return -1; | ||||
| @@ -95,7 +96,7 @@ public class IndividualWeightedFitnessComparator implements Comparator<AbstractE | ||||
|      * @param f | ||||
|      * @return | ||||
|      */ | ||||
|     private double calcScore(double[] f) { | ||||
|     private double calculateScore(double[] f) { | ||||
|         if (f == null || fitWeights == null) { | ||||
|             throw new RuntimeException("Error, missing information in " + this.getClass()); | ||||
|         } | ||||
| @@ -117,9 +118,9 @@ public class IndividualWeightedFitnessComparator implements Comparator<AbstractE | ||||
|      * @param indy | ||||
|      * @return | ||||
|      */ | ||||
|     public double calcScore(AbstractEAIndividual indy) { | ||||
|     public double calculateScore(AbstractEAIndividual indy) { | ||||
|         double[] f = indy.getFitness(); | ||||
|         return calcScore(f); | ||||
|         return calculateScore(f); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -133,6 +134,7 @@ public class IndividualWeightedFitnessComparator implements Comparator<AbstractE | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Parameter(description = "Weights of the fitness values in the linear combination") | ||||
|     public void setFitWeights(double[] fitWeights) { | ||||
|         this.fitWeights = fitWeights; | ||||
|     } | ||||
| @@ -140,23 +142,4 @@ public class IndividualWeightedFitnessComparator implements Comparator<AbstractE | ||||
|     public double[] getFitWeights() { | ||||
|         return fitWeights; | ||||
|     } | ||||
|  | ||||
|     public String fitWeightsTipText() { | ||||
|         return "Weights of the fitness values in the linear combination"; | ||||
|     } | ||||
|  | ||||
| //	public static void main(String[] args) { | ||||
| //		TF1Problem prob = new TF1Problem(); | ||||
| //		Population pop = new Population(10); | ||||
| //		prob.initializePopulation(pop); | ||||
| //		prob.evaluate(pop); | ||||
| //		System.out.println(pop.getStringRepresentation()); | ||||
| //		System.out.println("***"); | ||||
| //		IndividualWeightedFitnessComparator wfComp = new IndividualWeightedFitnessComparator(new double[]{0.5,0.5}); | ||||
| //		System.out.println("***"); System.out.println(pop.getSortedPop(wfComp).getStringRepresentation()); | ||||
| //		wfComp.setFitWeights(new double[] {0.1, 0.9}); | ||||
| //		System.out.println("***"); System.out.println(pop.getSortedPop(wfComp).getStringRepresentation()); | ||||
| //		wfComp.setFitWeights(new double[] {0.9, 0.1}); | ||||
| //		System.out.println("***"); System.out.println(pop.getSortedPop(wfComp).getStringRepresentation()); | ||||
| //	} | ||||
| } | ||||
|   | ||||
| @@ -64,11 +64,11 @@ public class DiversityTerminator extends PopulationMeasureTerminator implements | ||||
|  | ||||
|     @Override | ||||
|     protected double calculateInitialMeasure(PopulationInterface pop) { | ||||
|         return calcPopulationMeasure(pop); | ||||
|         return calculatePopulationMeasure(pop); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected double calcPopulationMeasure(PopulationInterface pop) { | ||||
|     protected double calculatePopulationMeasure(PopulationInterface pop) { | ||||
|         double[] measures = ((Population) pop).getPopulationMeasures(metric); | ||||
|         int measureIndex = criterion.ordinal(); | ||||
|         return measures[measureIndex]; | ||||
|   | ||||
| @@ -35,7 +35,7 @@ public class FitnessConvergenceTerminator extends PopulationMeasureTerminator | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected double calcPopulationMeasure(PopulationInterface pop) { | ||||
|     protected double calculatePopulationMeasure(PopulationInterface pop) { | ||||
| //		if (oldFit==null) return Double.MAX_VALUE; | ||||
| //		return EuclideanMetric.euclideanDistance(oldFit, pop.getBestFitness()); | ||||
|         return Mathematics.norm(pop.getBestFitness()); | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import eva2.problems.InterfaceMultimodalProblemKnown; | ||||
| import eva2.problems.InterfaceOptimizationProblem; | ||||
| import eva2.tools.EVAERROR; | ||||
| import eva2.util.annotation.Description; | ||||
| import eva2.util.annotation.Parameter; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.util.logging.Level; | ||||
| @@ -25,8 +26,7 @@ public class KnownOptimaFoundTerminator implements InterfaceTerminator, Serializ | ||||
|     private int reqOptima = 1; | ||||
|     private String msg = ""; | ||||
|  | ||||
|     public KnownOptimaFoundTerminator() { | ||||
|     } | ||||
|     public KnownOptimaFoundTerminator() {} | ||||
|  | ||||
|     @Override | ||||
|     public void initialize(InterfaceOptimizationProblem prob) throws IllegalArgumentException { | ||||
| @@ -71,21 +71,18 @@ public class KnownOptimaFoundTerminator implements InterfaceTerminator, Serializ | ||||
|     /** | ||||
|      * @return the reqOptima | ||||
|      */ | ||||
|     public int getReqOptima() { | ||||
|     public int getRequiredOptima() { | ||||
|         return reqOptima; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param reqOptima the reqOptima to set | ||||
|      */ | ||||
|     public void setReqOptima(int reqOptima) { | ||||
|     @Parameter(description = "The number of optima that need to be found to terminate the optimization.") | ||||
|     public void setRequiredOptima(int reqOptima) { | ||||
|         this.reqOptima = reqOptima; | ||||
|     } | ||||
|  | ||||
|     public String reqOptimaTipText() { | ||||
|         return "The number of optima that need to be found to terminate the optimization."; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String toString() { | ||||
|         return "KnownOptimaFoundTerminator requiring " + reqOptima + " optima."; | ||||
|   | ||||
| @@ -69,7 +69,7 @@ public class ParetoMetricTerminator extends PopulationMeasureTerminator implemen | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected double calcPopulationMeasure(PopulationInterface pop) { | ||||
|     protected double calculatePopulationMeasure(PopulationInterface pop) { | ||||
|         return calculateInitialMeasure(pop); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -40,7 +40,7 @@ public class PhenotypeConvergenceTerminator extends PopulationMeasureTerminator | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected double calcPopulationMeasure(PopulationInterface pop) { | ||||
|     protected double calculatePopulationMeasure(PopulationInterface pop) { | ||||
|         return pMetric.distance(oldIndy, (AbstractEAIndividual) pop.getBestIndividual()); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -4,6 +4,7 @@ import eva2.optimization.individuals.IndividualWeightedFitnessComparator; | ||||
| import eva2.optimization.population.Population; | ||||
| import eva2.optimization.population.PopulationInterface; | ||||
| import eva2.util.annotation.Description; | ||||
| import eva2.util.annotation.Parameter; | ||||
|  | ||||
| /** | ||||
|  * Terminate if a score based on the archive of the population converges. | ||||
| @@ -19,17 +20,17 @@ public class PopulationArchiveTerminator extends PopulationMeasureTerminator { | ||||
|         if (archive == null || (archive.size() < 1)) { | ||||
|             return Double.MAX_VALUE; | ||||
|         } else { | ||||
|             return wfComp.calcScore(archive.getBestEAIndividual(wfComp)); | ||||
|             return wfComp.calculateScore(archive.getBestEAIndividual(wfComp)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected double calcPopulationMeasure(PopulationInterface pop) { | ||||
|     protected double calculatePopulationMeasure(PopulationInterface pop) { | ||||
|         Population archive = ((Population) pop).getArchive(); | ||||
|         if (archive == null || (archive.size() < 1)) { | ||||
|             return Double.MAX_VALUE; | ||||
|         } else { | ||||
|             return wfComp.calcScore(archive.getBestEAIndividual(wfComp)); | ||||
|             return wfComp.calculateScore(archive.getBestEAIndividual(wfComp)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -42,11 +43,8 @@ public class PopulationArchiveTerminator extends PopulationMeasureTerminator { | ||||
|         return wfComp.getFitWeights(); | ||||
|     } | ||||
|  | ||||
|     @Parameter(description = "Weights of the fitness values in the linear combination") | ||||
|     public void setFitWeights(double[] fWeights) { | ||||
|         wfComp.setFitWeights(fWeights); | ||||
|     } | ||||
|  | ||||
|     public String fitWeightsTipText() { | ||||
|         return wfComp.fitWeightsTipText(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -157,7 +157,7 @@ public abstract class PopulationMeasureTerminator implements InterfaceTerminator | ||||
|      * @param pop | ||||
|      */ | ||||
|     protected void saveState(PopulationInterface pop) { | ||||
|         oldMeasure = calcPopulationMeasure(pop); | ||||
|         oldMeasure = calculatePopulationMeasure(pop); | ||||
|         oldPopFitCalls = pop.getFunctionCalls(); | ||||
|         oldPopGens = pop.getGeneration(); | ||||
|         firstTime = false; | ||||
| @@ -170,7 +170,7 @@ public abstract class PopulationMeasureTerminator implements InterfaceTerminator | ||||
|      * @param pop | ||||
|      * @return | ||||
|      */ | ||||
|     protected abstract double calcPopulationMeasure(PopulationInterface pop); | ||||
|     protected abstract double calculatePopulationMeasure(PopulationInterface pop); | ||||
|  | ||||
|     /** | ||||
|      * Return true if the population measure did not exceed the | ||||
| @@ -180,7 +180,7 @@ public abstract class PopulationMeasureTerminator implements InterfaceTerminator | ||||
|      * @return | ||||
|      */ | ||||
|     protected boolean isStillConverged(PopulationInterface pop) { | ||||
|         double measure = calcPopulationMeasure(pop); | ||||
|         double measure = calculatePopulationMeasure(pop); | ||||
|         double allowedLower = Double.NEGATIVE_INFINITY, allowedUpper = Double.POSITIVE_INFINITY; | ||||
|         boolean ret; | ||||
|         switch (changeType) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user