diff --git a/src/eva2/OptimizerFactory.java b/src/eva2/OptimizerFactory.java index 90ffc9f8..cfb8125b 100644 --- a/src/eva2/OptimizerFactory.java +++ b/src/eva2/OptimizerFactory.java @@ -37,11 +37,11 @@ import java.util.BitSet; import java.util.List; /** - *

The OptimizerFactory allows quickly creating some optimizers without + * The OptimizerFactory allows quickly creating some optimizers without * thinking much about parameters. You can access a runnable Optimization thread * and directly start it, or access its fully prepared OptimizationParameter instance, * change some parameters, and start it then. - *

+ *

* On the other hand this * class provides an almost complete list of all currently available * optimization procedures in EvA2. The arguments passed to the methods @@ -51,7 +51,7 @@ import java.util.List; * InterfaceOptimizer optimizer = OptimizerFactory.createCertainOptimizer(arguments); * EvaluationTerminator terminator = new EvaluationTerminator(numOfFitnessCalls); * while (!terminator.isTerminated(optimizer.getPopulation())) optimizer.optimize(); - *

+ * */ public class OptimizerFactory { diff --git a/src/eva2/gui/AboutDialog.java b/src/eva2/gui/AboutDialog.java index f0def4f3..ab1a6ba4 100644 --- a/src/eva2/gui/AboutDialog.java +++ b/src/eva2/gui/AboutDialog.java @@ -14,7 +14,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** - * @author becker + * The About dialog used in the EvA2 GUI. */ class AboutDialog extends JDialog { private JLabel imageLabel; diff --git a/src/eva2/gui/SplashScreen.java b/src/eva2/gui/SplashScreen.java index 11db5521..a96b29a1 100644 --- a/src/eva2/gui/SplashScreen.java +++ b/src/eva2/gui/SplashScreen.java @@ -28,8 +28,8 @@ class SplashScreen extends JWindow { /** * Show the splash screen to the end user. - *

- *

Once this method returns, the splash screen is realized, which means + *

+ * Once this method returns, the splash screen is realized, which means * that almost all work on the splash screen should proceed through the * event dispatch thread. In particular, any call to * dispose for the splash screen must be performed in the event diff --git a/src/eva2/optimization/go/SwingWorker.java b/src/eva2/optimization/go/SwingWorker.java index bad8bf55..b2fdea39 100644 --- a/src/eva2/optimization/go/SwingWorker.java +++ b/src/eva2/optimization/go/SwingWorker.java @@ -7,11 +7,11 @@ import javax.swing.*; * SwingWorker 3), an abstract class that you subclass to * perform GUI-related work in a dedicated thread. For * instructions on using this class, see: - *

+ *

* http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html * or * http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html - *

+ *

* Note that the API changed slightly in the 3rd version: * You must now invoke start() on the SwingWorker after * creating it. diff --git a/src/eva2/optimization/individuals/GAESIndividualBinaryDoubleData.java b/src/eva2/optimization/individuals/GAESIndividualBinaryDoubleData.java index de1dcbe3..cb96c613 100644 --- a/src/eva2/optimization/individuals/GAESIndividualBinaryDoubleData.java +++ b/src/eva2/optimization/individuals/GAESIndividualBinaryDoubleData.java @@ -299,7 +299,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme /** * ******************************************************************************************************************* * These are for InterfaceDataTypeBinary - *

+ *

* /** This method allows you to request a certain amount of binary data * * @param length The lenght of the BitSet that is to be optimized diff --git a/src/eva2/optimization/individuals/GAPIndividualProgramData.java b/src/eva2/optimization/individuals/GAPIndividualProgramData.java index b49770da..3a008557 100644 --- a/src/eva2/optimization/individuals/GAPIndividualProgramData.java +++ b/src/eva2/optimization/individuals/GAPIndividualProgramData.java @@ -192,7 +192,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In /** * ******************************************************************************************************************* * These are for InterfaceDataTypeDouble - *

+ *

* /** This method allows you to request a certain amount of double data * * @param length The lenght of the double[] that is to be optimized diff --git a/src/eva2/optimization/individuals/GIOBGAIndividualIntegerPermutationData.java b/src/eva2/optimization/individuals/GIOBGAIndividualIntegerPermutationData.java index a7a68011..96a8371c 100644 --- a/src/eva2/optimization/individuals/GIOBGAIndividualIntegerPermutationData.java +++ b/src/eva2/optimization/individuals/GIOBGAIndividualIntegerPermutationData.java @@ -196,7 +196,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual /** * ******************************************************************************************************************* * These are for InterfaceDataTypeInteger - *

+ *

* /** This method allows you to request a certain amount of int data * * @param length The lenght of the int[] that is to be optimized diff --git a/src/eva2/optimization/individuals/InterfaceOBGAIndividual.java b/src/eva2/optimization/individuals/InterfaceOBGAIndividual.java index 116937cb..4d06ecca 100644 --- a/src/eva2/optimization/individuals/InterfaceOBGAIndividual.java +++ b/src/eva2/optimization/individuals/InterfaceOBGAIndividual.java @@ -3,13 +3,6 @@ package eva2.optimization.individuals; /** * This interface gives access to a permutation genotype and should * only be used by mutation and crossover operators. - *

Title: EvA2

- *

Description:

- *

Copyright: Copyright (c) 2003

- *

Company:

- * - * @author planatsc - * @version 1.0 */ public interface InterfaceOBGAIndividual { diff --git a/src/eva2/optimization/individuals/codings/ga/GAStandardCodingDouble.java b/src/eva2/optimization/individuals/codings/ga/GAStandardCodingDouble.java index ea112fa6..9934d1a9 100644 --- a/src/eva2/optimization/individuals/codings/ga/GAStandardCodingDouble.java +++ b/src/eva2/optimization/individuals/codings/ga/GAStandardCodingDouble.java @@ -131,10 +131,8 @@ public class GAStandardCodingDouble implements InterfaceGADoubleCoding, java.io. /** * A eva2.problems.simple test function without arguments - * - * @param args */ - public static void main(String[] args) { + public static void main() { GAStandardCodingDouble t = new GAStandardCodingDouble(); String test = "01100010001000110010000011111101"; //String test = "11000000000000000000000000000000"; diff --git a/src/eva2/optimization/modules/OptimizationParameters.java b/src/eva2/optimization/modules/OptimizationParameters.java index cbca3d18..408e6d20 100644 --- a/src/eva2/optimization/modules/OptimizationParameters.java +++ b/src/eva2/optimization/modules/OptimizationParameters.java @@ -19,7 +19,7 @@ import java.util.logging.Level; /** * OptimizationParameters for configuration of an * optimization run. - *

+ *

* This class is used to generate the default GUI * configuration panel for optimizations. */ diff --git a/src/eva2/optimization/modules/Processor.java b/src/eva2/optimization/modules/Processor.java index 6b947ed1..ac222ee7 100644 --- a/src/eva2/optimization/modules/Processor.java +++ b/src/eva2/optimization/modules/Processor.java @@ -33,7 +33,7 @@ import java.util.logging.Logger; /** * The Processor may run as a thread permanently (GenericModuleAdapter) and is * then stopped and started by a switch in startOptimization/stopOptimization. - *

+ *

* Processor also handles adaptive parameter control by checking for the method * getParamControl in (so far) Optimizer and Problem instances. The return-value * may be InterfaceParameterControl or an array of Objects. If it is a control diff --git a/src/eva2/optimization/operator/cluster/ClusteringNearestBetter.java b/src/eva2/optimization/operator/cluster/ClusteringNearestBetter.java index 370e06ac..323ed94f 100644 --- a/src/eva2/optimization/operator/cluster/ClusteringNearestBetter.java +++ b/src/eva2/optimization/operator/cluster/ClusteringNearestBetter.java @@ -18,7 +18,7 @@ import java.util.Vector; /** * Hierarchical clustering after Preuss et al., "Counteracting Genetic Drift and Disruptive Recombination * in (mu+,lambda)-EA on Multimodal Fitness Landscapes", GECCO '05. - *

+ *

* A tree is produced by assigning each individual the closest individual with better fitness. * Connections with a distance above a certain threshold are cut. After that, each interconnected subtree forms a cluster. * In the paper, the threshold is deduced as 2*d_p for d_p: the mean distance in the population. diff --git a/src/eva2/optimization/operator/constraint/AbstractConstraint.java b/src/eva2/optimization/operator/constraint/AbstractConstraint.java index bd0fa5a9..c40d35cc 100644 --- a/src/eva2/optimization/operator/constraint/AbstractConstraint.java +++ b/src/eva2/optimization/operator/constraint/AbstractConstraint.java @@ -7,6 +7,7 @@ import eva2.problems.AbstractProblemDouble; import eva2.tools.EVAERROR; import java.io.Serializable; +import java.util.logging.Logger; /** * An abstract constraint contains a penalty factor with control strategy (for dynamic penalties) @@ -15,7 +16,7 @@ import java.io.Serializable; * @author mkron */ public abstract class AbstractConstraint implements InterfaceDoubleConstraint, Serializable { - // private transient GPFunctionProblem func = null; + private static final Logger LOGGER = Logger.getLogger(AbstractConstraint.class.getName()); protected ConstraintRelationEnum relation = ConstraintRelationEnum.lessEqZero; protected ConstraintHandlingEnum handling = ConstraintHandlingEnum.specificTag; @@ -104,7 +105,7 @@ public abstract class AbstractConstraint implements InterfaceDoubleConstraint, S * Some constraints require further information on the individual or work on the * raw fitness which can be requested using this method. * - * @return + * @return The individuals raw fitness */ protected double[] getIndyRawFit(String key) { return getIndyDblData(AbstractProblemDouble.rawFitKey); @@ -115,7 +116,8 @@ public abstract class AbstractConstraint implements InterfaceDoubleConstraint, S * additional individual data. This method uses getData of AbstractEAIndividual * to try to retrieve a double array. * - * @return + * @param key The key used for the data + * @return A specific double array identified by key */ protected double[] getIndyDblData(String key) { if (currentIndy != null) { @@ -123,11 +125,11 @@ public abstract class AbstractConstraint implements InterfaceDoubleConstraint, S if (dat != null && (dat instanceof double[])) { return (double[]) dat; } else { - System.err.println("Error, invalid call to AbstractConstraint.getRawFitness(). Individual had no raw fitness set."); + LOGGER.finest("Error, invalid call to AbstractConstraint.getRawFitness(). Individual had no raw fitness set."); return null; } } else { - System.err.println("Error, invalid call to AbstractConstraint.getRawFitness(). Individual was unknown."); + LOGGER.finest("Error, invalid call to AbstractConstraint.getRawFitness(). Individual was unknown."); return null; } } @@ -137,22 +139,20 @@ public abstract class AbstractConstraint implements InterfaceDoubleConstraint, S * additional individual data. This method uses getData of AbstractEAIndividual * to try to retrieve a stored object. * - * @return + * @return An object identified by the key */ protected Object getIndyData(String key) { if (currentIndy != null) { return currentIndy.getData(key); } else { - System.err.println("Error, invalid call to AbstractConstraint.getRawFitness(). Individual was unknown."); + LOGGER.finest("Error, invalid call to AbstractConstraint.getRawFitness(). Individual was unknown."); return null; } } private double getViolationConsideringRelation(double val) { -// System.out.println("Penalty is " + penaltyFactor); val *= penaltyFactor; switch (relation) { -// case linearLessEqZero: case lessEqZero: return (val <= 0.) ? 0 : val; case eqZero: diff --git a/src/eva2/optimization/operator/crossover/CrossoverESFlat.java b/src/eva2/optimization/operator/crossover/CrossoverESFlat.java index 63d9fc17..030b364f 100644 --- a/src/eva2/optimization/operator/crossover/CrossoverESFlat.java +++ b/src/eva2/optimization/operator/crossover/CrossoverESFlat.java @@ -12,7 +12,7 @@ import eva2.util.annotation.Description; * The flat crossover inits values randomly within the extreme values of * all parents, namely * c[i]=rand(min_j(p_ij), max_j(p_ij)). - *

+ *

* where c[i] is the i-th child component and p_ij is the i-th component * of parent j. */ diff --git a/src/eva2/optimization/operator/crossover/TestESCrossover.java b/src/eva2/optimization/operator/crossover/TestESCrossover.java index b79d564b..dcc44a06 100644 --- a/src/eva2/optimization/operator/crossover/TestESCrossover.java +++ b/src/eva2/optimization/operator/crossover/TestESCrossover.java @@ -240,13 +240,10 @@ public class TestESCrossover implements java.io.Serializable { /** * This method will test the crossover operator - * - * @param args */ public static void main(String[] args) { TestESCrossover t = new TestESCrossover(); t.initFrame(); - } public void setCrossover(InterfaceCrossover NumberOfCrossovers) { diff --git a/src/eva2/optimization/operator/distancemetric/DoubleIntegralMetric.java b/src/eva2/optimization/operator/distancemetric/DoubleIntegralMetric.java index 48530612..fcd7364f 100644 --- a/src/eva2/optimization/operator/distancemetric/DoubleIntegralMetric.java +++ b/src/eva2/optimization/operator/distancemetric/DoubleIntegralMetric.java @@ -10,7 +10,7 @@ import java.io.Serializable; /** * Calculate the euclidean difference between discrete integrals, which is * d(x,y)=sqrt(sum_i=1^n(((sum_j=1^i(x_j))-(sum_j=1^i(y_j)))^2)). - *

+ *

* This can be used with any individual type that implements getDoublePositionShallow. * * @see AbstractEAIndividual#getDoublePositionShallow(AbstractEAIndividual) diff --git a/src/eva2/optimization/operator/fitnessmodifier/FitnessSharing.java b/src/eva2/optimization/operator/fitnessmodifier/FitnessSharing.java index 610337bf..5628f9ff 100644 --- a/src/eva2/optimization/operator/fitnessmodifier/FitnessSharing.java +++ b/src/eva2/optimization/operator/fitnessmodifier/FitnessSharing.java @@ -5,6 +5,7 @@ import eva2.optimization.operator.distancemetric.InterfaceDistanceMetric; import eva2.optimization.operator.distancemetric.PhenotypeMetric; import eva2.optimization.population.Population; import eva2.util.annotation.Description; +import eva2.util.annotation.Parameter; /** * The fitness modifier are defunct and are to be moved to @@ -69,34 +70,28 @@ public class FitnessSharing implements java.io.Serializable, InterfaceFitnessMod /** * These methods allows you to set/get the Sharing Distance * - * @param SharingDistance + * @param sharingDistance The sharing distance */ - public void setSharingDistance(double SharingDistance) { - this.sharingDistance = SharingDistance; + @Parameter(description = "The threshold for the similarity penalty.") + public void setSharingDistance(double sharingDistance) { + this.sharingDistance = sharingDistance; } public double getSharingDistance() { return this.sharingDistance; } - public String sharingDistanceTipText() { - return "The threshold for the similarity penalty."; - } - /** * These methods allows you to set/get the type of Distance Metric. * - * @param Metric + * @param metric The distance metric to use */ - public void setMetric(InterfaceDistanceMetric Metric) { - this.distanceMetric = Metric; + @Parameter(name = "metric", description = "The distance metric used. Note: This depends on the type of EAIndividual used!") + public void setMetric(InterfaceDistanceMetric metric) { + this.distanceMetric = metric; } public InterfaceDistanceMetric getMetric() { return this.distanceMetric; } - - public String metricTipText() { - return "The distance metric used. Note: This depends on the type of EAIndividual used!"; - } } diff --git a/src/eva2/optimization/operator/initialization/GAGIInitializeSegmentwise.java b/src/eva2/optimization/operator/initialization/GAGIInitializeSegmentwise.java index e6e4dfec..998e4904 100644 --- a/src/eva2/optimization/operator/initialization/GAGIInitializeSegmentwise.java +++ b/src/eva2/optimization/operator/initialization/GAGIInitializeSegmentwise.java @@ -19,7 +19,7 @@ import java.util.BitSet; * integer individuals, it allows to control the number of occurrences of a certain integer * per segment. It may also be used to initialize with subsets of integers (by setting 0 * elements to a certain type and all to a subset of the range). - *

+ *

* The initialization may be parameterized in two ways, where each takes a fixed * segment length s. Firstly, a fixed number of bits (k<=s) is set per segment, * so each segment has equal cardinality. diff --git a/src/eva2/optimization/operator/mutation/MutateESCorrVector.java b/src/eva2/optimization/operator/mutation/MutateESCorrVector.java index be7a6ee3..d4e87559 100644 --- a/src/eva2/optimization/operator/mutation/MutateESCorrVector.java +++ b/src/eva2/optimization/operator/mutation/MutateESCorrVector.java @@ -16,7 +16,7 @@ import java.util.ArrayList; * updates the velocity by rotation and scaling, and then mutates the individual * by adding the velocity. This was used for a particle filter localization problem * and is less useful in general. - *

+ *

* Rotation vectors are normal distributed with mean zero, scaling factors are * log-normally distributed around mean 1. This means that the averaged expected change * of the mutation vector is zero. The smaller the deviations, the higher the correlations diff --git a/src/eva2/optimization/operator/mutation/MutateESRankMuCMA.java b/src/eva2/optimization/operator/mutation/MutateESRankMuCMA.java index 7d370d70..ca0f20d4 100644 --- a/src/eva2/optimization/operator/mutation/MutateESRankMuCMA.java +++ b/src/eva2/optimization/operator/mutation/MutateESRankMuCMA.java @@ -24,7 +24,7 @@ import java.io.Serializable; * - N.Hansen & S.Kern 2004: Evaluating the CMA Evolution Strategy on Multimodal Test Functions. * Parallel Problem Solving from Nature 2004. * - For the stopping criteria: Auger&Hansen, CEC '05, A Restart CMA ES with increasing population size. - *

+ *

* The implementation uses a structure for keeping all adaptive parameters, CMAParamSet, which is stored * in the populations, so that in principle, multi-modal optimization with several populations becomes possible. * This of course requires proper handling of the generational cycle, i.e., new generations should be cloned from diff --git a/src/eva2/optimization/operator/mutation/MutateOBGAInversion.java b/src/eva2/optimization/operator/mutation/MutateOBGAInversion.java index 6f1ac2f2..6066b7f5 100644 --- a/src/eva2/optimization/operator/mutation/MutateOBGAInversion.java +++ b/src/eva2/optimization/operator/mutation/MutateOBGAInversion.java @@ -10,7 +10,7 @@ import eva2.util.annotation.Description; /** - *

+ *

* Mutates a permutation by inversion a part of the permutation. *

* Example: diff --git a/src/eva2/optimization/operator/nichepso/absorption/ConsiderPBestAbsorptionStrategy.java b/src/eva2/optimization/operator/nichepso/absorption/ConsiderPBestAbsorptionStrategy.java index 9102ae7a..fcde02a1 100644 --- a/src/eva2/optimization/operator/nichepso/absorption/ConsiderPBestAbsorptionStrategy.java +++ b/src/eva2/optimization/operator/nichepso/absorption/ConsiderPBestAbsorptionStrategy.java @@ -12,11 +12,8 @@ public class ConsiderPBestAbsorptionStrategy extends StandardAbsorptionStrategy /** - * @tested true if - * the subswarm is active and - * the particle lies in the radius of the subswarm and + * True if the subswarm is active and the particle lies in the radius of the subswarm and * the particles pbest is not better than the subswarms gbest (this would "pull the subswarm away") - * (non-Javadoc) @see javaeva.server.oa.go.Operators.NichePSO.StandardAbsorptionStrategy#shouldAbsorbParticleIntoSubswarm(javaeva.server.oa.go.EAIndividuals.AbstractEAIndividual, javaeva.server.oa.go.Strategies.ParticleSubSwarmOptimization) */ @Override public boolean shouldAbsorbParticleIntoSubswarm(AbstractEAIndividual indy, ParticleSubSwarmOptimization subswarm, ParticleSubSwarmOptimization mainswarm) { @@ -30,7 +27,6 @@ public class ConsiderPBestAbsorptionStrategy extends StandardAbsorptionStrategy * @param indy * @param subswarm * @return - * @tested */ private boolean absorbtionConstraintViolation(AbstractEAIndividual indy, ParticleSubSwarmOptimization subswarm) { AbstractEAIndividual indysPBest = (AbstractEAIndividual) indy.getData("PersonalBestKey"); diff --git a/src/eva2/optimization/operator/nichepso/subswarmcreation/GenerateNeighborSubswarmCreationStrategy.java b/src/eva2/optimization/operator/nichepso/subswarmcreation/GenerateNeighborSubswarmCreationStrategy.java index a32a0d4f..68047303 100644 --- a/src/eva2/optimization/operator/nichepso/subswarmcreation/GenerateNeighborSubswarmCreationStrategy.java +++ b/src/eva2/optimization/operator/nichepso/subswarmcreation/GenerateNeighborSubswarmCreationStrategy.java @@ -19,20 +19,9 @@ public class GenerateNeighborSubswarmCreationStrategy extends private double mu = 0.1; -/********************************************************************************************************************** - * shouldCreateSubswarm - */ - - // same as in StandardSubswarmCreationStrategy - -/********************************************************************************************************************** - * createSubswarm - */ - /** * @tested creates a subswarm from the given particle and its neighbor in the mainswarm. * If the neighbors pbest is better than the particles pbest, a new neighbor is generated. - * (non-Javadoc) @see javaeva.server.oa.go.Operators.NichePSO.StandardSubswarmCreationStrategy#createSubswarm(javaeva.server.oa.go.Strategies.ParticleSubSwarmOptimization, javaeva.server.oa.go.EAIndividuals.AbstractEAIndividual, javaeva.server.oa.go.Strategies.ParticleSubSwarmOptimization) */ @Override public void createSubswarm(ParticleSubSwarmOptimization preparedSubswarm, AbstractEAIndividual indy, ParticleSubSwarmOptimization mainSwarm) { diff --git a/src/eva2/optimization/operator/paramcontrol/AbstractParameterControl.java b/src/eva2/optimization/operator/paramcontrol/AbstractParameterControl.java index d5812b04..b00d2b17 100644 --- a/src/eva2/optimization/operator/paramcontrol/AbstractParameterControl.java +++ b/src/eva2/optimization/operator/paramcontrol/AbstractParameterControl.java @@ -8,7 +8,7 @@ import eva2.optimization.population.Population; * the first one to retrieve an array of strings with the canonical names of the controlled parameters, * and the second one to produce an object array of the same length with the values to be assigned * at the iteration. If there is no iteration known, iteration counts will be set to -1. - *

+ *

* This class can be used to implement strategies to adapt multiple parameters within one strategy. * For single parameter adaption, better use the ParamAdaption inheritance tree and the ParameterControlManager class. * diff --git a/src/eva2/optimization/operator/paramcontrol/ConstraintBasedAdaption.java b/src/eva2/optimization/operator/paramcontrol/ConstraintBasedAdaption.java index 3052b1c7..77b86284 100644 --- a/src/eva2/optimization/operator/paramcontrol/ConstraintBasedAdaption.java +++ b/src/eva2/optimization/operator/paramcontrol/ConstraintBasedAdaption.java @@ -15,7 +15,7 @@ import java.util.LinkedList; * if it was always infeasible, the penalty factor is increased. For other cases, the penalty remains the same. * This is plausible for the typical case that the optimum lies near the constraint boundary, however it makes * the fitness function change dynamically based only on the positions of last best indidivuals. - *

+ *

* The authors advise to select betaInc != 1./betaDec to avoid cycling. */ @Description("Adapt a constraint's penalty factor (esp. fitness based) if the population contained only valid or only invalid individuals for some generations.") diff --git a/src/eva2/optimization/operator/paramcontrol/InterfaceParameterControl.java b/src/eva2/optimization/operator/paramcontrol/InterfaceParameterControl.java index 207036b6..4dbbac8b 100644 --- a/src/eva2/optimization/operator/paramcontrol/InterfaceParameterControl.java +++ b/src/eva2/optimization/operator/paramcontrol/InterfaceParameterControl.java @@ -8,7 +8,7 @@ import eva2.optimization.population.Population; * an update is triggered after every optimize call. This allows parameters of the object to be * adapted dynamically, such as linearly decreasing weights or control parameters. In case of PSO, * this may be the linearly decreasing inertia weight or the activation feedback control mechanism. - *

+ *

* Notice how Processor handles parameter control. For now, a controlled object must implement * the method getParamControl() which is to return either an InterfaceParameterControl or an array * of Objects which should either be instances of InterfaceParameterControl or @@ -22,7 +22,7 @@ public interface InterfaceParameterControl { /** * Make a deep copy of the object. * - * @return + * @return Deep copy */ public Object clone(); @@ -43,9 +43,10 @@ public interface InterfaceParameterControl { /** * For a given runtime (maxIteration) and current iteration, update the parameters of the object. * - * @param obj - * @param iteration - * @param maxIteration + * @param obj Object + * @param pop Population + * @param iteration Iteration + * @param maxIteration Maximum Iteration */ public void updateParameters(Object obj, Population pop, int iteration, int maxIteration); @@ -53,7 +54,7 @@ public interface InterfaceParameterControl { * If no runtime in terms of iterations can be specified, the parameter control may try to infer * the state from the object itself. * - * @param obj + * @param obj Object */ public void updateParameters(Object obj); } diff --git a/src/eva2/optimization/operator/paramcontrol/PSOActivityFeedbackControl.java b/src/eva2/optimization/operator/paramcontrol/PSOActivityFeedbackControl.java index 59b68ecc..e25c64d9 100644 --- a/src/eva2/optimization/operator/paramcontrol/PSOActivityFeedbackControl.java +++ b/src/eva2/optimization/operator/paramcontrol/PSOActivityFeedbackControl.java @@ -13,7 +13,7 @@ import java.io.Serializable; * here is simply the average relative velocity of the particles. * The target activity decreases with time, and if the current activity is too low (high), the * inertia is increased (decreased) so that the activity approximates the target activity. - *

+ *

* The original authors used an absolute velocity measure and FIPS which is not implemented in EvA2 so far. * However, after some initial tests, this version seems * to work ok, although it depends on the defined target activity. I am not convinced that in general it is diff --git a/src/eva2/optimization/operator/postprocess/PostProcess.java b/src/eva2/optimization/operator/postprocess/PostProcess.java index 308f998f..0bd3a8cb 100644 --- a/src/eva2/optimization/operator/postprocess/PostProcess.java +++ b/src/eva2/optimization/operator/postprocess/PostProcess.java @@ -641,7 +641,7 @@ public class PostProcess { * At the moment, the function calls are distributed evenly between all candidate solutions. This could be * improved by checking the convergence state in the future. The given terminator will be applied to each * candidate sub-population anew. If the terminator is null, 10*n steps will be performed on each candidate. - *

+ *

* A double value is added to each solution individual that replaces its ancestor candidate, using the key * PostProcess.movedDistanceKey. * It indicates the phenotype distance the found solution has moved relatively to the original candidate. @@ -1123,7 +1123,7 @@ public class PostProcess { * epsilon[k] and discarded. The number of solutions * which are accurate by epsilon[k] are returned in the integer array. Optionally, the refined solutions * are added to an array of histograms. - *

+ *

* For refining, either known optima are used or {@link AbstractOptimizationProblem}.extractPotentialOptima() * is called. * diff --git a/src/eva2/optimization/operator/selection/probability/SelProbStandard.java b/src/eva2/optimization/operator/selection/probability/SelProbStandard.java index 5dc5c889..8691ef8f 100644 --- a/src/eva2/optimization/operator/selection/probability/SelProbStandard.java +++ b/src/eva2/optimization/operator/selection/probability/SelProbStandard.java @@ -5,7 +5,7 @@ import eva2.util.annotation.Description; /** * A eva2.problems.simple sum to calculate the selection probability. - *

+ *

* p(i is selected) = exp(-fitness(i))/sum_j(exp(-fitness(j))) */ @Description("This is a standard normation method using the exp function.") diff --git a/src/eva2/optimization/statistics/AbstractStatistics.java b/src/eva2/optimization/statistics/AbstractStatistics.java index 8773f318..401f3f26 100644 --- a/src/eva2/optimization/statistics/AbstractStatistics.java +++ b/src/eva2/optimization/statistics/AbstractStatistics.java @@ -26,17 +26,17 @@ import java.util.*; * updated per iteration in createNextGenerationPerformed and reported to listeners in stopOptimizationPerformed. * Several different verbosity levels are regarded. * The method plotCurrentResults should be implemented to plot further results per iteration. - *

+ *

* All displayable data is now routed through a single pipeline, which consists in a * list of Objects assembled in the getOutputValues method. This allows all eva2.problems.simple data types which are * provided by the external informer instances to be handled uniformly to the internally collected data, and * thus they can be plotted and text-dumped in the same manner. * Basic fields are identified by the enum GraphSelectionEnum and are available independently of additional * informer instances. - *

+ *

* Depending on the field selection state and the informers, the list of data fields is dynamically altered, * however changes during a multi-run are ignored, since the potential of inconsistencies is too high. - *

+ *

* Listeners implementing InterfaceTextListener receive String output (human readable). * Listeners implementing InterfaceStatisticsListener receive the raw data per iteration. */ diff --git a/src/eva2/optimization/statistics/OptimizationJob.java b/src/eva2/optimization/statistics/OptimizationJob.java index 6a4b20fb..a755ed08 100644 --- a/src/eva2/optimization/statistics/OptimizationJob.java +++ b/src/eva2/optimization/statistics/OptimizationJob.java @@ -5,16 +5,17 @@ import eva2.tools.StringSelection; import java.io.Serializable; import java.util.List; +import java.util.logging.Logger; /** * An OptimizationJob is a set of optimization parameters and potential results from the statistics class. * Each job has a unique ID and may have been completely finished or not. Once finished, the * framework should guarantee that the job is removed as a statistics listener. - *

+ *

* A job contains data fields of a multi-run experiment and header strings describing the data. */ public class OptimizationJob implements Serializable, InterfaceStatisticsListener { - + private static final Logger LOGGER = Logger.getLogger(OptimizationJob.class.getName()); private InterfaceOptimizationParameters params = null; private String[] fieldHeaders = null; private List multiRunFinalObjectData = null; @@ -52,20 +53,16 @@ public class OptimizationJob implements Serializable, InterfaceStatisticsListene multiRunFinalObjectData = null; } - public InterfaceOptimizationParameters getParams() { - return params; - } - /** - * Set the GO parameters for this instance. + * Set the optimization parameters for this instance. * - * @param params + * @param params An instance of OptimizationParameters */ - public void setParams(InterfaceOptimizationParameters params) { + public void setOptimizationParameters(InterfaceOptimizationParameters params) { // how should this be treated? In case the run is already finished, changing // the parameters will be evil, so avoid that case. if (state == StateEnum.complete) { - System.err.println("Warning, ignoring changed parameters for finished job!"); + LOGGER.warning("Ignoring changed parameters for finished job!"); } else { this.params = params; } @@ -166,8 +163,8 @@ public class OptimizationJob implements Serializable, InterfaceStatisticsListene * Retrieve the index of a data field within the data lines. * Returns -1 if the field has not been found. * - * @param field - * @return + * @param field Field name + * @return The index of the field */ public int getFieldIndex(String field) { if (fieldHeaders != null) { @@ -222,8 +219,8 @@ public class OptimizationJob implements Serializable, InterfaceStatisticsListene * Retrieve a single column of data indicated by a field name. If the field is unknown * or there is no data, null is returned. * - * @param field - * @return + * @param field Field name + * @return An array of objects from the field provided */ public Object[] getDataColumn(String field) { int index = getFieldIndex(field); @@ -247,7 +244,7 @@ public class OptimizationJob implements Serializable, InterfaceStatisticsListene curSelection.setSelected(field, true); } } else { - System.err.println("Warning, empty field selection in job " + this); + LOGGER.warning("Empty field selection in job " + this); } return newSel; } diff --git a/src/eva2/optimization/statistics/OptimizationJobList.java b/src/eva2/optimization/statistics/OptimizationJobList.java index af25c999..9b5dc94c 100644 --- a/src/eva2/optimization/statistics/OptimizationJobList.java +++ b/src/eva2/optimization/statistics/OptimizationJobList.java @@ -45,8 +45,8 @@ public class OptimizationJobList extends PropertySelectableList /** * This adds a new job to the list. * - * @param params - * @param stats + * @param params Optimization parameters + * @param stats Statistics instance */ public OptimizationJob addJob(InterfaceOptimizationParameters params, AbstractStatistics stats) { OptimizationJob job = new OptimizationJob((InterfaceOptimizationParameters) Serializer.deepClone(params), stats); @@ -76,7 +76,7 @@ public class OptimizationJobList extends PropertySelectableList /** * Return the last job in the list, which is also the last one added. * - * @return + * @return The last job added */ public OptimizationJob lastJob() { OptimizationJob[] curArr = getObjects(); @@ -90,7 +90,7 @@ public class OptimizationJobList extends PropertySelectableList /** * Return a list of the currently selected jobs. * - * @return + * @return A List of selected jobs */ public ArrayList getSelectedJobs() { OptimizationJob[] selected = getSelectedObjects(); diff --git a/src/eva2/optimization/statistics/StatisticalEvaluation.java b/src/eva2/optimization/statistics/StatisticalEvaluation.java index a429c364..fcb6425b 100644 --- a/src/eva2/optimization/statistics/StatisticalEvaluation.java +++ b/src/eva2/optimization/statistics/StatisticalEvaluation.java @@ -50,7 +50,7 @@ public class StatisticalEvaluation { } textout.println(""); for (int i = 0; i < jobsToWorkWith.size(); i++) { - textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName()); + textout.print(jobsToWorkWith.get(i).getOptimizationParameters().getOptimizer().getName()); for (int j = 0; j < singleStats.length; j++) { switch (singleStats[j]) { case mean: @@ -115,7 +115,7 @@ public class StatisticalEvaluation { InterfaceTextListener textout, ArrayList jobsToWorkWith, String field) { for (int i = 0; i < jobsToWorkWith.size(); i++) { - textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName()); + textout.print(jobsToWorkWith.get(i).getOptimizationParameters().getOptimizer().getName()); for (int j = 0; j < jobsToWorkWith.size(); j++) { textout.print("\t" + calculateTTestUnEqSizeUnEqVar(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j))); } @@ -131,7 +131,7 @@ public class StatisticalEvaluation { private static void writeUnEqSizeEqVar(InterfaceTextListener textout, ArrayList jobsToWorkWith, String field) { for (int i = 0; i < jobsToWorkWith.size(); i++) { - textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName()); + textout.print(jobsToWorkWith.get(i).getOptimizationParameters().getOptimizer().getName()); for (int j = 0; j < jobsToWorkWith.size(); j++) { textout.print("\t" + calculateTTestUnEqSizeEqVar(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j))); } @@ -147,7 +147,7 @@ public class StatisticalEvaluation { private static void writeTTestEqSizeEqVar(InterfaceTextListener textout, ArrayList jobsToWorkWith, String field) { for (int i = 0; i < jobsToWorkWith.size(); i++) { - textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName()); + textout.print(jobsToWorkWith.get(i).getOptimizationParameters().getOptimizer().getName()); for (int j = 0; j < jobsToWorkWith.size(); j++) { textout.print("\t" + calculateTTestEqSizeEqVar(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j))); } @@ -157,7 +157,7 @@ public class StatisticalEvaluation { private static void writeMannWhitney(InterfaceTextListener textout, ArrayList jobsToWorkWith, String field) { for (int i = 0; i < jobsToWorkWith.size(); i++) { - textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName()); + textout.print(jobsToWorkWith.get(i).getOptimizationParameters().getOptimizer().getName()); for (int j = 0; j < jobsToWorkWith.size(); j++) { textout.print("\t" + calculateMannWhitney(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j))); } @@ -172,7 +172,7 @@ public class StatisticalEvaluation { private static void writeTwoSampleFirstLine(InterfaceTextListener textout, ArrayList jobsToWorkWith) { for (int i = 0; i < jobsToWorkWith.size(); i++) { - textout.print("\t" + jobsToWorkWith.get(i).getParams().getOptimizer().getName()); + textout.print("\t" + jobsToWorkWith.get(i).getOptimizationParameters().getOptimizer().getName()); } textout.println(""); } diff --git a/src/eva2/optimization/strategies/ANPSO.java b/src/eva2/optimization/strategies/ANPSO.java index c1971582..8c91225f 100644 --- a/src/eva2/optimization/strategies/ANPSO.java +++ b/src/eva2/optimization/strategies/ANPSO.java @@ -41,7 +41,7 @@ import java.util.Vector; * perfom a local search on its own. This results in a high exploration ability of the main swarm and * potentially leads to a good amount of identified optima. * Larger values for mainSwarmPhi2 on the other hand might help to concentrate on fewer optima with superior fitness values. - *

+ *

* To avoid further parameters and the need to specify adequate values, which are often difficult to decide, * the following adaption mechanism is employed: * ANPSO adaptively determines a threshold parameter r during every generation by computing the average @@ -53,7 +53,7 @@ import java.util.Vector; * The implemented version uses a strategy to deactivate subswarms when all containing particles converged on a solution. * Furthermore, different neighborhood topologies can be choosen for the main swarm. * In case the Multi-Swarm topology is used, the species radius is adaptively determined as well. - *

+ *

* [1] S. Bird and X. Li: * Adaptively choosing niching parameters in a PSO. * In: GECCO '06: Proceedings of the 8th annual conference on Genetic and evolutionary computation, diff --git a/src/eva2/optimization/strategies/BOA.java b/src/eva2/optimization/strategies/BOA.java index 2f2287d3..e32486d7 100644 --- a/src/eva2/optimization/strategies/BOA.java +++ b/src/eva2/optimization/strategies/BOA.java @@ -27,7 +27,7 @@ import java.util.logging.Logger; /** * Basic implementation of the Bayesian Optimization Algorithm - *

+ *

* Martin Pelikan, David E. Goldberg and Erick Cantu-Paz: 'BOA: The Bayesian * Optimization Algorithm' the works by Martin Pelikan and David E. Goldberg. * Genetic and Evolutionary Computation Conference (GECCO-99), pp. 525-532 diff --git a/src/eva2/optimization/strategies/BinaryScatterSearch.java b/src/eva2/optimization/strategies/BinaryScatterSearch.java index f7719a7e..3560b06a 100644 --- a/src/eva2/optimization/strategies/BinaryScatterSearch.java +++ b/src/eva2/optimization/strategies/BinaryScatterSearch.java @@ -22,7 +22,7 @@ import java.util.BitSet; /** * A BinaryScatterSearch implementation taken mainly from [i]. * - *

+ *

* F. Gortazar, A. Duarte, M. Laguna and R. Marti: Black Box Scatter Search for * General Classes of Binary Optimization Problems Computers and Operations * research, vol. 37, no. 11, pp. 1977-1986 (2010) diff --git a/src/eva2/optimization/strategies/ClusterBasedNichingEA.java b/src/eva2/optimization/strategies/ClusterBasedNichingEA.java index 55fe0a14..2fb2b343 100644 --- a/src/eva2/optimization/strategies/ClusterBasedNichingEA.java +++ b/src/eva2/optimization/strategies/ClusterBasedNichingEA.java @@ -34,12 +34,12 @@ import java.util.*; /** * The infamous clustering based niching EA, still under construction. It should * be able to identify and track multiple global/local optima at the same time. - *

+ *

* Notes: For std. GA, the mutation rate may have to reduced, because the * initial step size tends to be rel. large and easily disperse clustered * species (so that they fall below the minimum swarm size and the local optimum * is lost). - *

+ *

* For the CBN-PSO remember to use the IndividualDataMetric so that the * remembered positions are used for clustering (which are rel. stable - so that * species clustering actually makes sense). @@ -1179,7 +1179,7 @@ public class ClusterBasedNichingEA extends AbstractOptimizer implements Interfac * Calculate the clustering parameter in such a way that about one q-th part * of the range of the given problem is within one hyper sphere of the * clustering parameter. - *

+ *

* For certain types of parameter adaption schemes, this automatically sets * the upper limit if the clustering parameter is controlled. * diff --git a/src/eva2/optimization/strategies/ClusteringHillClimbing.java b/src/eva2/optimization/strategies/ClusteringHillClimbing.java index 869abbac..99bcf73d 100644 --- a/src/eva2/optimization/strategies/ClusteringHillClimbing.java +++ b/src/eva2/optimization/strategies/ClusteringHillClimbing.java @@ -25,7 +25,7 @@ import java.io.Serializable; * a cluster, only a subset of representatives of the cluster is taken over to * the next HC step while the rest is discarded. This means that the population * size may be reduced. - *

+ *

* As soon as the improvement by HC lies below a threshold, the mutation step * size is decreased. If the step size is decreased below a certain threshold, * the current population is stored to an archive and reinitialized. Thus, the diff --git a/src/eva2/optimization/strategies/EsDpiNiching.java b/src/eva2/optimization/strategies/EsDpiNiching.java index 2e8ddac4..dc702f83 100644 --- a/src/eva2/optimization/strategies/EsDpiNiching.java +++ b/src/eva2/optimization/strategies/EsDpiNiching.java @@ -38,7 +38,7 @@ import java.util.Formatter; * iteration. Thus, in relation to the standard ES, some new parameters are due. * On the other hand, the selection schemes are predefined. This is done * according to Shir&Bäck, Niching in Evolution Strategies, Tec.Report 2005. - *

+ *

* Unfortunately the algorithm was not described in every detail. It remained * unclear how exactly the peak population where filled and esp. what happens if * DPI returns less than q peaks. In this implementation, this is solved by @@ -46,43 +46,43 @@ import java.util.Formatter; * population, only the best muPerPeak remain and the rest is assigned to the * unclustered set. From these, pseudo-peaks are then formed until the expected * number of peak populations is produced. - *

+ *

* Also, they gave a general rule for setting the niche radius depending on the * optimizationProblem domain, however in their experiments, they were able to identify * optima which were much closer (i.e., on Ackley's), so it is unclear which * niche radius was actually used there - *

+ *

* Due to the "non-standard" environmental selection mechanism (a fixed * proportion is chosen from the children, the rest from the parents), a * preselection mechanism was implemented here, slightly breaking the ES * framework which is still used to optimize the single peak populations. - *

+ *

* This class should also cover "Dynamic niching in evolution strategies with * covariance matrix adaptation" by Shir & Bäck, CEC 2005, when employing * SelectBest as parent selection and muPerPeak=1. - *

+ *

* Some notes: - *

+ *

* If strictNiching is deactivated, niches are disappearing because they are * sometimes assigned the global opt. and in that niche are very bad so they get * thrown away due to the maximum niche count if strictNiching is activated, * niches are very small - or even empty. Why is that? This can hardly be * sensible esp. with a very small niche radius for F8. This would mean that in * the beginning, nearly all offspring are created from very few pairs of peaks. - *

+ *

* The mu/lambda information was lost on the way to the MutateESRankMuCMA * class... I added it now as additional pop.data which is only loaded if the * mu/lambda ratio deduced from the orig/selected population sizes does not make * sense. - *

+ *

* With the explorer peaks reinited every 100 generations or so, the course of * the MPR for a *single* run will not be a clear logistic function, because * "finding" additional peaks produces small steps in the MPR. - *

+ *

* The Niching ES is now using the Population to catch the generational events, * not producing it itself, similar to Tribes, ScatterSearch or IPOP-ES. Thus it * could be used with a dynamic population size without too much hassle. - *

+ *

* TODO Add adaptive niche radius. Add parameter to every indy which is adapted * after all new peaks have been found. */ diff --git a/src/eva2/optimization/strategies/EvolutionStrategyIPOP.java b/src/eva2/optimization/strategies/EvolutionStrategyIPOP.java index 5f64ad75..7fbe0622 100644 --- a/src/eva2/optimization/strategies/EvolutionStrategyIPOP.java +++ b/src/eva2/optimization/strategies/EvolutionStrategyIPOP.java @@ -24,14 +24,14 @@ import java.util.LinkedList; * Stagnation is for this implementation defined by a FitnessConvergenceTerminator instance * which terminates if the absolute change in fitness is below a threshold (default 10e-12) for a * certain number of generations (default: 10+floor(30*n/lambda) for problem dimension n). - *

+ *

* If the MutateESRankMuCMA mutation operator is used, additional criteria are used for restarts, * such as numeric conditions of the covariance matrix. * Lambda is increased multiplicatively for every restart, and typical initial values are * mu=5, lambda=10, incFact=2. * The IPOP-CMA-ES won the CEC 2005 benchmark challenge. * Refer to Auger&Hansen 05 for more details. - *

+ *

* A.Auger & N.Hansen. A Restart CMA Evolution Strategy With Increasing Population Size. CEC 2005. */ @Description("An ES with increasing population size.") diff --git a/src/eva2/optimization/strategies/FloodAlgorithm.java b/src/eva2/optimization/strategies/FloodAlgorithm.java index 1acdb31a..8065b602 100644 --- a/src/eva2/optimization/strategies/FloodAlgorithm.java +++ b/src/eva2/optimization/strategies/FloodAlgorithm.java @@ -146,10 +146,8 @@ public class FloodAlgorithm extends AbstractOptimizer implements java.io.Seriali /** * This main method will start a eva2.problems.simple hillclimber. No arguments necessary. - * - * @param args */ - public static void main(String[] args) { + public static void main() { FloodAlgorithm program = new FloodAlgorithm(); int TmpMeanCalls = 0, TmpMeanFitness = 0; for (int i = 0; i < program.multiRuns; i++) { diff --git a/src/eva2/optimization/strategies/GradientDescentAlgorithm.java b/src/eva2/optimization/strategies/GradientDescentAlgorithm.java index 4f7586c0..bc81ce52 100644 --- a/src/eva2/optimization/strategies/GradientDescentAlgorithm.java +++ b/src/eva2/optimization/strategies/GradientDescentAlgorithm.java @@ -15,7 +15,7 @@ import eva2.util.annotation.Description; /** * A gradient descent algorithm by hannes planatscher don't expect any * descriptions here... *big sigh* - *

+ *

* mkron added some! * */ diff --git a/src/eva2/optimization/strategies/IslandModelEA.java b/src/eva2/optimization/strategies/IslandModelEA.java index 3ca15c85..dc2cbe18 100644 --- a/src/eva2/optimization/strategies/IslandModelEA.java +++ b/src/eva2/optimization/strategies/IslandModelEA.java @@ -24,7 +24,7 @@ import eva2.util.annotation.Hidden; * to allow fast and reliable computation. This is still usefull, since it is * less prone to premature convergence and also an heterogenuous island model * can be used. - *

+ *

* A population of the same size is sent to all nodes and evaluated there * independently for a cycle (more precisely: for MigrationRate generations) * after which a communication step is performed according to the migration diff --git a/src/eva2/optimization/strategies/NichePSO.java b/src/eva2/optimization/strategies/NichePSO.java index e8047857..9f10c038 100644 --- a/src/eva2/optimization/strategies/NichePSO.java +++ b/src/eva2/optimization/strategies/NichePSO.java @@ -43,17 +43,17 @@ import java.util.Vector; * search space. Subswarms are formed from that main swarm to refine and * represent single niches which are assumed to correspond to local or global * optima. - *

+ *

* Different strategies are employed in order to: create subswarms from the main * swarm merge subswarms if they converge to the same solution absorb main swarm * particles into a subswarm in case a particle enters the area covered by the * subswarm deactivate subswarms when all containing particles converged on a * solution - *

+ *

* Some implementations of these strategies and the deactivation strategy itself * extend the original algorithm. As proposed in [1], NichePSO uses the * "cognition only" model of the "inertness weight" PSO to train the main swarm. - *

+ *

* mainSwarmInertness sets the inertia weight omega and weights the particles * tendency to follow its former movement. This controls exploration (favored by * larger values) against exploitation (favored by smaller values). @@ -67,7 +67,7 @@ import java.util.Vector; * NichePSO. Experiments showed a good performance for relatively small values * of maxAllowedSwarmRadius <= 0.0001 on lower dimensional problems. For higher * dimensional problems, larger values may be preferable. - *

+ *

* [1] R. Brits, A. P. Engelbrecht and B. Bergh. A Niching Particle Swarm * Optimizer In Proceedings of the 4th Asia-Pacific Conference on Simulated * Evolution and Learning (SEAL'02), 2002, 2, 692-696 [2] E. �zcan and M. @@ -594,15 +594,10 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo } /** - * ******************************************************************************************************************** - * Absorbtion - */ - /** + * Adds indy to an active subswarm, then removes indy from the mainswarm. + * * @param indy * @param subswarm - * @return - * @tested adds indy to an active subswarm, then removes indy from the - * mainswarm. */ protected void absorbtionEventFor(AbstractEAIndividual indy, ParticleSubSwarmOptimization subswarm) { if (isVerbose()) { @@ -613,7 +608,7 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo } /** - * @tested junit absorbs the mainswarm particles into the subswarm according + * junit absorbs the mainswarm particles into the subswarm according * to the absorbtion strategy */ protected void absorbParticlesIfPossible() { @@ -1999,7 +1994,7 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo * Create a Niche PSO with parameters as to Brits, Engelbrecht & Bergh: A * Niching Particle Swarm Optimizer. SEAL 2002. Exeption: the swarm size is * 200 by default, because 30 (of the orig. paper) seems way too low. - *

+ *

* The evaluation count is required currently due to the * generation-dependent intertness decay used by the std. variant. To alter * the terminator, use OptimizationParameters.setTerminator(), and mind the intertness diff --git a/src/eva2/optimization/strategies/ParticleSubSwarmOptimization.java b/src/eva2/optimization/strategies/ParticleSubSwarmOptimization.java index 30e2d760..3fa199c5 100644 --- a/src/eva2/optimization/strategies/ParticleSubSwarmOptimization.java +++ b/src/eva2/optimization/strategies/ParticleSubSwarmOptimization.java @@ -369,7 +369,7 @@ public class ParticleSubSwarmOptimization extends ParticleSwarmOptimizationGCPSO } // min.setDoubleGenotype(minValInDim); // set all dimensions to min // max.setDoubleGenotype(maxValInDim); // set all dimensions to max - this.maxPosDist = Mathematics.euclidianDist(minValInDim, maxValInDim); + this.maxPosDist = Mathematics.euclideanDist(minValInDim, maxValInDim); } // /** diff --git a/src/eva2/optimization/strategies/ParticleSwarmOptimization.java b/src/eva2/optimization/strategies/ParticleSwarmOptimization.java index 80933e7d..3aebd6bc 100644 --- a/src/eva2/optimization/strategies/ParticleSwarmOptimization.java +++ b/src/eva2/optimization/strategies/ParticleSwarmOptimization.java @@ -34,7 +34,7 @@ import java.util.Vector; * range constraints on the decision variables. I've implemented 'brakes' before * an individual is updated it is checked whether the new individual would * violate range constraints, if so the velocity vector is reduced. - *

+ *

* Possible topologies are: "Linear", "Grid", "Star", "Multi-Swarm", "Tree", * "HPSO", "Random" in that order starting by 0. */ diff --git a/src/eva2/optimization/strategies/PopulationBasedIncrementalLearning.java b/src/eva2/optimization/strategies/PopulationBasedIncrementalLearning.java index e90b268c..363ac42b 100644 --- a/src/eva2/optimization/strategies/PopulationBasedIncrementalLearning.java +++ b/src/eva2/optimization/strategies/PopulationBasedIncrementalLearning.java @@ -22,7 +22,7 @@ import java.util.logging.Logger; * also allows to simulate ant systems due to the flexible update rule of V. But * both are limited to binary genotypes. This is a eva2.problems.simple implementation of * Population Based Incremental Learning. - *

+ *

* Nicolas Monmarché , Eric Ramat , Guillaume Dromel , Mohamed Slimane , Gilles * Venturini: On the similarities between AS, BSC and PBIL: toward the birth of * a new meta-heuristic. TecReport 215. Univ. de Tours, 1999. diff --git a/src/eva2/optimization/strategies/ScatterSearch.java b/src/eva2/optimization/strategies/ScatterSearch.java index b361dd45..4441748a 100644 --- a/src/eva2/optimization/strategies/ScatterSearch.java +++ b/src/eva2/optimization/strategies/ScatterSearch.java @@ -37,7 +37,7 @@ import java.util.ArrayList; * values in the reference set or as an absolute value (in both cases only the * first fitness criterion is regarded). * - *

+ *

* [1] M.Rodiguez-Fernandez, J.Egea, J.Banga: Novel metaheuristic for parameter * estimation in nonlinear dynamic biological systems. BMC Bioinformatics 2006, * 7:483. BioMed Central 2006. diff --git a/src/eva2/optimization/strategies/Tribes.java b/src/eva2/optimization/strategies/Tribes.java index 2b2af3ea..371107d8 100644 --- a/src/eva2/optimization/strategies/Tribes.java +++ b/src/eva2/optimization/strategies/Tribes.java @@ -33,7 +33,7 @@ import java.util.List; * the CEC 2005 benchmarks (see the corresponding class) - I widely kept the * original comments, except for places I changed the code so much that they * might mislead - thats all, I think - *

+ *

* I could produce similar results as Clerc's on Rosenbrock and Griewank, (in * his book on p. 148), I couldnt reproduce the 100% success rate on Ackley, * though. @@ -43,7 +43,7 @@ import java.util.List; * {@link http://clerc.maurice.free.fr/pso/} * @version 2006-02 21 * @date 2007-09-13 - *

+ *

* Original notes: */ /* Last updates (M.Clerc) diff --git a/src/eva2/problems/AbstractDynamicOptimizationProblem.java b/src/eva2/problems/AbstractDynamicOptimizationProblem.java index 16911bcc..6a8b389b 100644 --- a/src/eva2/problems/AbstractDynamicOptimizationProblem.java +++ b/src/eva2/problems/AbstractDynamicOptimizationProblem.java @@ -245,7 +245,7 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz /** * Called to indicate a change in the problem environment. To be implemented. * - * @param problemTime + * @param problemTime The time at which the problem changes */ protected abstract void changeProblemAt(double problemTime); diff --git a/src/eva2/problems/AbstractMultiModalProblemKnown.java b/src/eva2/problems/AbstractMultiModalProblemKnown.java index d5a3590d..c87ce5e1 100644 --- a/src/eva2/problems/AbstractMultiModalProblemKnown.java +++ b/src/eva2/problems/AbstractMultiModalProblemKnown.java @@ -241,7 +241,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub * based on the full list of known optima. * This assumes that the realOpts have fitness values assigned as for maximization and the * population has fitness values assigned for minimization (mirrored by maximum fitness within realOpts). - *

+ *

* This is in analogy to the original implementation by F.Streichert. * * @param realOpts diff --git a/src/eva2/problems/AbstractProblemDouble.java b/src/eva2/problems/AbstractProblemDouble.java index f1a20b1f..2740de89 100644 --- a/src/eva2/problems/AbstractProblemDouble.java +++ b/src/eva2/problems/AbstractProblemDouble.java @@ -29,18 +29,18 @@ import eva2.util.annotation.Parameter; * {@link #getProblemDimension()} must return the problem dimension, while * {@link #evaluate(double[])} is to evaluate a single double vector into the result * fitness vector. - *

+ *

* To define the problem range, you may use the default range parameter * resulting in a symmetric double range [-defaultRange,defaulRange] in all * dimensions. Or you may implement {@link #getRangeLowerBound(int)} and * {@link #getRangeUpperBound(int)} to define an arbitrary problem range. In * that case, the default range parameter is not used. - *

+ *

* Anything you want to do before any optimization is started on the problem * should go into {@link #initializeProblem()}, but remember to call the super-method * in your implementation. The individual template will be initialized to an * ESIndividualDoubleData by then. - *

+ *

* For the GUI, it is also convenient to implement the {@link eva2.util.annotation.Description} * annotation and {@link #getName()} method to provide some distinctive information for the * user. @@ -445,7 +445,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem * Refine a candidate solution vector regarding rotations. Saves the new * solution vector in pos and returns the number of dimensions that had to * be modified after rotation due to range restrictions. - *

+ *

* The given position is expected to be unrotated! The returned solution is * unrotated as well. * diff --git a/src/eva2/problems/F20Problem.java b/src/eva2/problems/F20Problem.java index 4271f157..5eb8143d 100644 --- a/src/eva2/problems/F20Problem.java +++ b/src/eva2/problems/F20Problem.java @@ -13,7 +13,7 @@ import java.io.Serializable; * There are diagonal ridges across the search space and the optima are close to the bounds. * The minimum fitness f(x*) is close to (n-1)*r for dimension n and default range r, by which * this implementation may be shifted to the positive domain. - *

+ *

* For gnuplot: x *sin(sqrt(abs(-x+y+1)))*cos(sqrt(abs(x+y+1)))+(y+1)*cos(sqrt(abs(-x+y+1)))*sin(sqrt(abs(x+y+1))) */ @Description("The Rana function is non-separable, highly multi-modal and multi-funnel." + diff --git a/src/eva2/problems/InterfaceMultimodalProblemKnown.java b/src/eva2/problems/InterfaceMultimodalProblemKnown.java index f0837c0b..f88d8ea1 100644 --- a/src/eva2/problems/InterfaceMultimodalProblemKnown.java +++ b/src/eva2/problems/InterfaceMultimodalProblemKnown.java @@ -4,7 +4,7 @@ import eva2.optimization.population.Population; /** * A multimodal problem which has knowledge of its optima. - *

+ *

* User: streiche * Date: 23.04.2003 * Time: 10:57:47 diff --git a/src/eva2/problems/InterfaceProblemDouble.java b/src/eva2/problems/InterfaceProblemDouble.java index ded8a6a4..b7690b71 100644 --- a/src/eva2/problems/InterfaceProblemDouble.java +++ b/src/eva2/problems/InterfaceProblemDouble.java @@ -33,7 +33,7 @@ public interface InterfaceProblemDouble { * Get the upper bound of the double range in the given dimension. Override * this to implement non-symmetric ranges. User setDefaultRange for symmetric ranges. * - * @param dim + * @param dim Dimension * @return the upper bound of the double range in the given dimension * @see #makeRange() * @see #getRangeLowerBound(int dim) @@ -44,7 +44,7 @@ public interface InterfaceProblemDouble { * Get the lower bound of the double range in the given dimension. Override * this to implement non-symmetric ranges. Use setDefaultRange for symmetric ranges. * - * @param dim + * @param dim Dimension * @return the lower bound of the double range in the given dimension * @see #makeRange() * @see #getRangeUpperBound(int dim) diff --git a/src/eva2/tools/JarResources.java b/src/eva2/tools/JarResources.java index c0d6c781..e374f743 100644 --- a/src/eva2/tools/JarResources.java +++ b/src/eva2/tools/JarResources.java @@ -138,7 +138,7 @@ public final class JarResources { /** * Is a test driver. Given a jar file and a resource name, it tries to * extract the resource and then tells us whether it could or not. - *

+ *

* Example * Let's say you have a JAR file which jarred up a bunch of gif image * files. Now, by using JarResources, you could extract, create, and display diff --git a/src/eva2/tools/chart2d/DComponent.java b/src/eva2/tools/chart2d/DComponent.java index a54a0a6d..083bbf28 100644 --- a/src/eva2/tools/chart2d/DComponent.java +++ b/src/eva2/tools/chart2d/DComponent.java @@ -6,7 +6,7 @@ import java.awt.*; * DComponent is the mother of all objects which can be displayed * by a DArea object, even when it would be also enough to * implement the DElement interface to an class - *

+ *

* DComponent is abstract because the paint method has to be overridden */ public abstract class DComponent implements DElement { @@ -30,7 +30,7 @@ public abstract class DComponent implements DElement { /** - * this border respresents the additional space around the clip of the + * this border represents the additional space around the clip of the * graphics context, which is calculated by the union of all DRectangles of * the components. For example it is used by DPointIcons or DLabels. */ @@ -41,8 +41,7 @@ public abstract class DComponent implements DElement { * this constructor is necessary to avoid infinite loops in constructing * DRectangles */ - DComponent(boolean is_rect) { - } + DComponent(boolean is_rect) {} public DComponent() { rectangle = DRectangle.getEmpty(); diff --git a/src/eva2/tools/chart2d/DMeasures.java b/src/eva2/tools/chart2d/DMeasures.java index 6eee286f..ba994dca 100644 --- a/src/eva2/tools/chart2d/DMeasures.java +++ b/src/eva2/tools/chart2d/DMeasures.java @@ -202,7 +202,7 @@ public class DMeasures implements Serializable { * they differ if there are scale functions selected which are not the identity * if the given rectangle does not belong to the image area of the scale * functions, the method returns null - *

+ *

* Tuning: rect must not be empty * * @param rect the image rectangle diff --git a/src/eva2/tools/math/Jama/CholeskyDecomposition.java b/src/eva2/tools/math/Jama/CholeskyDecomposition.java index 8b6c2b63..ff214b4a 100644 --- a/src/eva2/tools/math/Jama/CholeskyDecomposition.java +++ b/src/eva2/tools/math/Jama/CholeskyDecomposition.java @@ -2,10 +2,10 @@ package eva2.tools.math.Jama; /** * Cholesky Decomposition. - *

+ *

* For a symmetric, positive definite matrix A, the Cholesky decomposition * is an lower triangular matrix L so that A = L*L'. - *

+ *

* If the matrix is not symmetric or positive definite, the constructor * returns a partial decomposition and sets an internal flag that may * be queried by the isSPD() method. diff --git a/src/eva2/tools/math/Jama/EigenvalueDecomposition.java b/src/eva2/tools/math/Jama/EigenvalueDecomposition.java index b1834352..50b03467 100644 --- a/src/eva2/tools/math/Jama/EigenvalueDecomposition.java +++ b/src/eva2/tools/math/Jama/EigenvalueDecomposition.java @@ -5,12 +5,12 @@ import eva2.tools.math.Jama.util.Maths; /** * Eigenvalues and eigenvectors of a real matrix. - *

+ *

* If A is symmetric, then A = V*D*V' where the eigenvalue matrix D is * diagonal and the eigenvector matrix V is orthogonal. * I.e. A = V.times(D.times(V.transpose())) and * V.times(V.transpose()) equals the identiCty matrix. - *

+ *

* If A is not symmetric, then the eigenvalue matrix D is block diagonal * with the real eigenvalues in 1-by-1 blocks and any complex eigenvalues, * lambda + i*mu, in 2-by-2 blocks, [lambda, mu; -mu, lambda]. The diff --git a/src/eva2/tools/math/Jama/LUDecomposition.java b/src/eva2/tools/math/Jama/LUDecomposition.java index 2dfdaf10..10c82e97 100644 --- a/src/eva2/tools/math/Jama/LUDecomposition.java +++ b/src/eva2/tools/math/Jama/LUDecomposition.java @@ -3,12 +3,12 @@ package eva2.tools.math.Jama; /** * LU Decomposition. - *

+ *

* For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n * unit lower triangular matrix L, an n-by-n upper triangular matrix U, * and a permutation vector piv of length m so that A(piv,:) = L*U. * If m < n, then L is m-by-m and U is m-by-n. - *

+ *

* The LU decompostion with pivoting always exists, even if the matrix is * singular, so the constructor will never fail. The primary use of the * LU decomposition is in the solution of square systems of simultaneous diff --git a/src/eva2/tools/math/Jama/Matrix.java b/src/eva2/tools/math/Jama/Matrix.java index b585eb09..6a5a2c66 100644 --- a/src/eva2/tools/math/Jama/Matrix.java +++ b/src/eva2/tools/math/Jama/Matrix.java @@ -19,7 +19,7 @@ import java.util.Vector; /** * Jama = Java Matrix class. - *

+ *

* The Java Matrix Class provides the fundamental operations of numerical * linear algebra. Various constructors create Matrices from two dimensional * arrays of double precision floating point numbers. Various "gets" and @@ -29,7 +29,7 @@ import java.util.Vector; * Methods for reading and printing matrices are also included. All the * operations in this version of the Matrix Class involve real matrices. * Complex matrices may be handled in a future version. - *

+ *

* Five fundamental matrix decompositions, which consist of pairs or triples * of matrices, permutation vectors, and the like, produce results in five * decomposition classes. These decompositions are accessed by the Matrix @@ -44,7 +44,7 @@ import java.util.Vector; * *

*
Example of use:
- *

+ *

*

Solve a linear system A x = b and compute the residual norm, ||b - A x||. *

  * double[][] vals = {{1.,2.,3},{4.,5.,6.},{7.,8.,10.}};
@@ -1428,7 +1428,7 @@ public class Matrix implements Cloneable, Serializable {
     /**
      * Given two vectors, ``[a0, a1, ..., aM]`` and ``[b0, b1, ..., bN]``,
      * the outer product becomes::
-     * 

+ *

* [[a0*b0 a0*b1 ... a0*bN ] * [a1*b0 . * [ ... . diff --git a/src/eva2/tools/math/Jama/QRDecomposition.java b/src/eva2/tools/math/Jama/QRDecomposition.java index d837cd3a..a0c19268 100644 --- a/src/eva2/tools/math/Jama/QRDecomposition.java +++ b/src/eva2/tools/math/Jama/QRDecomposition.java @@ -4,11 +4,11 @@ import eva2.tools.math.Jama.util.Maths; /** * QR Decomposition. - *

+ *

* For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n * orthogonal matrix Q and an n-by-n upper triangular matrix R so that * A = Q*R. - *

+ *

* The QR decompostion always exists, even if the matrix does not have * full rank, so the constructor will never fail. The primary use of the * QR decomposition is in the least squares solution of nonsquare systems diff --git a/src/eva2/tools/math/Jama/SingularValueDecomposition.java b/src/eva2/tools/math/Jama/SingularValueDecomposition.java index a3a12b39..75dc5e5e 100644 --- a/src/eva2/tools/math/Jama/SingularValueDecomposition.java +++ b/src/eva2/tools/math/Jama/SingularValueDecomposition.java @@ -5,14 +5,14 @@ import eva2.tools.math.Jama.util.Maths; /** * Singular Value Decomposition. - *

+ *

* For an m-by-n matrix A with m >= n, the singular value decomposition is * an m-by-n orthogonal matrix U, an n-by-n diagonal matrix S, and * an n-by-n orthogonal matrix V so that A = U*S*V'. - *

+ *

* The singular values, sigma[k] = S[k][k], are ordered so that * sigma[0] >= sigma[1] >= ... >= sigma[n-1]. - *

+ *

* The singular value decompostion always exists, so the constructor will * never fail. The matrix condition number and the effective numerical * rank can be computed from this decomposition. diff --git a/src/eva2/tools/math/Mathematics.java b/src/eva2/tools/math/Mathematics.java index c0146d4f..6cd0a73e 100644 --- a/src/eva2/tools/math/Mathematics.java +++ b/src/eva2/tools/math/Mathematics.java @@ -117,10 +117,9 @@ public final class Mathematics { * @return the distance of x and y * @throws Exception if x and y have different dimensions an exception is thrown. */ - public static double euclidianDist(double[] x, double[] y) { + public static double euclideanDist(double[] x, double[] y) { if (x.length != y.length) { - throw new RuntimeException( - "The vectors x and y must have the same dimension"); + throw new IllegalArgumentException("The vectors x and y must have the same dimension"); } double d = 0; for (int i = 0; i < x.length; i++) { @@ -647,7 +646,7 @@ public final class Mathematics { } /** - * Performs two-sample unpaired t test and returns t critical value. + * Performs two-sample unpaired t test and returns t value. * * Both samples have to have the same size and equal variance. * @@ -662,8 +661,7 @@ public final class Mathematics { double stdDev1 = stdDev(vector1); double stdDev2 = stdDev(vector2); double sX1X2 = Math.sqrt((Math.pow(stdDev1, 2) + Math.pow(stdDev2, 2)) / 2); - double result = (mean1 - mean2) / (Math.sqrt(2 / n) * sX1X2); - return result; + return (mean1 - mean2) / (Math.sqrt(2 / n) * sX1X2); } public static double tTestUnEqSizeEqVar(double[] vector1, double[] vector2) { @@ -674,8 +672,7 @@ public final class Mathematics { double stdDev1 = stdDev(vector1); double stdDev2 = stdDev(vector2); double sX1X2 = Math.sqrt(((n1 - 1) * Math.pow(stdDev1, 2) + (n2 - 1) * Math.pow(stdDev2, 2)) / (n1 + n2 - 2)); - double result = (mean1 - mean2) / (sX1X2 * Math.sqrt(1 / n1 + 1 / n2)); - return result; + return (mean1 - mean2) / (sX1X2 * Math.sqrt(1 / n1 + 1 / n2)); } public static double tTestUnEqSizeUnEqVar(double[] vector1, double[] vector2) { @@ -686,8 +683,7 @@ public final class Mathematics { double stdDev1 = stdDev(vector1); double stdDev2 = stdDev(vector2); double sX1X2 = Math.sqrt((Math.pow(stdDev1, 2) / n1) + (Math.pow(stdDev2, 2) / n2)); - double result = (mean1 - mean2) / sX1X2; - return result; + return (mean1 - mean2) / sX1X2; } public static double min(double[] vals) { @@ -706,8 +702,8 @@ public final class Mathematics { */ public static double norm(double[] d) { double sqSum = 0; - for (int i = 0; i < d.length; i++) { - sqSum += d[i] * d[i]; + for (double value : d) { + sqSum += value * value; } return Math.sqrt(sqSum); } @@ -716,7 +712,7 @@ public final class Mathematics { * Normalizes the doubles in the array by their sum, so that they add up to * one. * - * @param d the array of double + * @param v the array of double * @throws IllegalArgumentException if sum is Zero or NaN */ public static double[] normalizeSum(double[] v) { @@ -784,8 +780,7 @@ public final class Mathematics { public static int projectToRange(double[] x, double[][] range) { int viols = 0; if (x.length > range.length) { - System.err - .println("Invalid vector length, x is longer than range! (Mathematics.projectToRange)"); + System.err.println("Invalid vector length, x is longer than range! (Mathematics.projectToRange)"); } for (int i = 0; i < x.length; i++) { if (x[i] < range[i][0]) { @@ -845,7 +840,7 @@ public final class Mathematics { */ public static int reflectBounds(double[] x, double[][] range) { int viols = 0; - double d = 0.; + double d; for (int i = 0; i < x.length; i++) { double dimLen = range[i][1] - range[i][0]; if (dimLen <= 0.) { @@ -1121,8 +1116,8 @@ public final class Mathematics { */ public static double sum(double[] doubles) { double sum = 0; - for (int i = 0; i < doubles.length; i++) { - sum += doubles[i]; + for (double value : doubles) { + sum += value; } return sum; } @@ -1137,8 +1132,8 @@ public final class Mathematics { int sum = 0; - for (int i = 0; i < ints.length; i++) { - sum += ints[i]; + for (int value : ints) { + sum += value; } return sum; } diff --git a/src/eva2/tools/math/SpecialFunction.java b/src/eva2/tools/math/SpecialFunction.java index 913280ea..eed576c3 100644 --- a/src/eva2/tools/math/SpecialFunction.java +++ b/src/eva2/tools/math/SpecialFunction.java @@ -36,7 +36,7 @@ package eva2.tools.math; * Like the java.lang.Math class this class is final and cannot be * subclassed. * All physical constants are in cgs units. - *

+ *

* NOTE: These special functions do not necessarily use the fastest * or most accurate algorithms. * @@ -527,7 +527,7 @@ public final class SpecialFunction { /** * @param x a double value * @return the Gamma function of the value. - *

+ *

* * Converted to Java from
* Cephes Math Library Release 2.2: July, 1992
@@ -662,7 +662,7 @@ public final class SpecialFunction { * @param a double value * @param x double value * @return the Complemented Incomplete Gamma function. - *

+ *

* * Converted to Java from
* Cephes Math Library Release 2.2: July, 1992
@@ -737,7 +737,7 @@ public final class SpecialFunction { * @param a double value * @param x double value * @return the Incomplete Gamma function. - *

+ *

* * Converted to Java from
* Cephes Math Library Release 2.2: July, 1992
@@ -811,7 +811,7 @@ public final class SpecialFunction { * @param df degrees of freedom * @param x double value * @return the Chi-Square function. - *

+ *

*/ static public double chisqc(double df, double x) @@ -893,7 +893,7 @@ public final class SpecialFunction { /** * @param a double value * @return The complementary Error function - *

+ *

* * Converted to Java from
* Cephes Math Library Release 2.2: July, 1992
@@ -997,7 +997,7 @@ public final class SpecialFunction { /** * @param a double value * @return The Error function - *

+ *

* * Converted to Java from
* Cephes Math Library Release 2.2: July, 1992
@@ -1174,7 +1174,7 @@ Direct inquiries to 30 Frost Street, Cambridge, MA 02140 * @param bb double value * @param xx double value * @return The Incomplete Beta Function evaluated from zero to xx. - *

+ *

* * Converted to Java from
* Cephes Math Library Release 2.3: July, 1995
diff --git a/src/eva2/tools/math/StatisticUtils.java b/src/eva2/tools/math/StatisticUtils.java index 87353147..3ea7c1e6 100644 --- a/src/eva2/tools/math/StatisticUtils.java +++ b/src/eva2/tools/math/StatisticUtils.java @@ -67,7 +67,6 @@ public final class StatisticUtils { double seA = 0.0; double seB = 0.0; double seAB = 0.0; - double c = 0.0; int AB; int allSum = countsSum1 + countsSum2; for (int i = 0; i < n; i++) { @@ -77,9 +76,7 @@ public final class StatisticUtils { seAB -= xlogx(((double) AB) / ((double) allSum)); } - c = seAB - 0.5 * (seA + seB); - - return c; + return seAB - 0.5 * (seA + seB); } /** @@ -124,7 +121,6 @@ public final class StatisticUtils { * @param a a double */ public static double log2(double a) { - return Math.log(a) / log2; } @@ -230,9 +226,9 @@ public final class StatisticUtils { if (n <= 1) { return 0; } - for (int i = 0; i < n; i++) { - sum += vector[i]; - sumSquared += (vector[i] * vector[i]); + for (double value : vector) { + sum += value; + sumSquared += (value * value); } double denom; if (finiteSet) { @@ -240,14 +236,7 @@ public final class StatisticUtils { } else { denom = (n - 1); } - double result = (sumSquared - (sum * sum / (double) n)) / denom; - - // We don't like negative variance - if (result < 0) { - return 0; - } else { - return result; - } + return (sumSquared - (sum * sum / (double) n)) / denom; } /** @@ -354,7 +343,7 @@ public final class StatisticUtils { /** * Returns the correlation coefficient r^2. - *

+ *

* Correlation ("Statistik", 7 Aufl., Hartung, 1989, Kapitel 9 und 10, S.546-608): * a=yMess[i]; * b=yWahr[i]; @@ -364,8 +353,6 @@ public final class StatisticUtils { * numerator=sumAB-(sumA*sumB/n); * denominator=sqrt[(sumAA-(sumA*sumA/n))*(sumBB-(sumB*sumB/n))]; * R=correlationcoefficient=numerator/denominator; - * - * @author Joerg K. Wegner */ public static double getCorrelationCoefficient(double array1[], double array2[]) { if ((array1 == null) || (array2 == null)) { diff --git a/src/eva2/tools/matlab/JMatLink.java b/src/eva2/tools/matlab/JMatLink.java index f34e74c7..8db3f82d 100644 --- a/src/eva2/tools/matlab/JMatLink.java +++ b/src/eva2/tools/matlab/JMatLink.java @@ -250,12 +250,12 @@ public class JMatLink extends Thread { /** * This is the constructor for the JMatLink library. - *

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   JMatLink engine = new JMatLink();
@@ -297,14 +297,14 @@ public class JMatLink extends Thread {
 
     /**
      * Open engine. This command is used to open a single connection
-     * 

+ *

* to matlab. - *

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   JMatLink engine = new JMatLink();
@@ -330,18 +330,18 @@ public class JMatLink extends Thread {
 
     /**
      * Open engine. This command is used to open a single connection
-     * 

+ *

* to matlab. - *

+ *

* This command is only useful on unix systems. On windows - *

+ *

* the optional parameter must be NULL. - *

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   JMatLink engine = new JMatLink();
@@ -382,14 +382,14 @@ public class JMatLink extends Thread {
 
     /**
      * Open engine for single use. This command is used to open
-     * 

+ *

* multiple connections to matlab. - *

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   int a,b;
@@ -424,14 +424,14 @@ public class JMatLink extends Thread {
 
     /**
      * Open engine for single use. This command is used to open
-     * 

+ *

* multiple connections to matlab. - *

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   int a,b;
@@ -478,12 +478,12 @@ public class JMatLink extends Thread {
 
     /**
      * Close the connection to matlab.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *  JMatLink engine = new JMatLink();
@@ -510,12 +510,12 @@ public class JMatLink extends Thread {
 
     /**
      * Close a specified connection to an instance of matlab.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *  int a,b;
@@ -564,11 +564,11 @@ public class JMatLink extends Thread {
 
     /**
      * Evaluate an expression in matlab's workspace.
-     * 

- *

- *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   JMatLink engine = new JMatLink();
@@ -595,12 +595,12 @@ public class JMatLink extends Thread {
 
     /**
      * Evaluate an expression in a specified workspace.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *  int a,b;
@@ -653,12 +653,12 @@ public class JMatLink extends Thread {
 
     /**
      * Get a scalar value from matlab's workspace.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *  double a;
@@ -689,12 +689,12 @@ public class JMatLink extends Thread {
 
     /**
      * Get a scalar value from a specified workspace.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   double a;
@@ -749,12 +749,12 @@ public class JMatLink extends Thread {
 
     /**
      * Get an array (1 * n) from matlab's workspace.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   double[] array;
@@ -785,12 +785,12 @@ public class JMatLink extends Thread {
 
     /**
      * Get an array (1 * n) from a specified workspace.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   int b;
@@ -839,12 +839,12 @@ public class JMatLink extends Thread {
 
     /**
      * Get an array from matlab's workspace.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   int b;
@@ -877,12 +877,12 @@ public class JMatLink extends Thread {
 
     /**
      * Get an array from a specified instance/workspace of matlab.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   int b;
@@ -931,12 +931,12 @@ public class JMatLink extends Thread {
 
     /**
      * Get an 'char' array (string) from matlab's workspace.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   String array;
@@ -983,12 +983,12 @@ public class JMatLink extends Thread {
 
     /**
      * Put an array into a specified workspace.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   int array = 1;
@@ -1027,12 +1027,12 @@ public class JMatLink extends Thread {
 
     /**
      * Put an array into matlab's workspace.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   double array = 1;
@@ -1061,12 +1061,12 @@ public class JMatLink extends Thread {
 
     /**
      * Put an array into a specified instance/workspace of matlab.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   int b;
@@ -1101,14 +1101,14 @@ public class JMatLink extends Thread {
 
     /**
      * Put an array (1 dimensional) into a specified instance/workspace of
-     * 

+ *

* matlab. - *

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   double[] array = {1.0 , 2.0 , 3.0};
@@ -1137,14 +1137,14 @@ public class JMatLink extends Thread {
 
     /**
      * Put an array (1 dimensional) into a specified instance/workspace of
-     * 

+ *

* matlab. - *

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   int b;
@@ -1184,12 +1184,12 @@ public class JMatLink extends Thread {
 
     /**
      * Put an array (2 dimensional) into matlab's workspace.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   double[][] array={{1.0 , 2.0 , 3.0},
@@ -1220,14 +1220,14 @@ public class JMatLink extends Thread {
 
     /**
      * Put an array (2 dimensional) into a specified instance/workspace of
-     * 

+ *

* matlab. - *

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      * int b;
@@ -1279,12 +1279,12 @@ public class JMatLink extends Thread {
 
     /**
      * Return the outputs of previous commands from matlab's workspace.
-     * 

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   String buffer;
@@ -1317,14 +1317,14 @@ public class JMatLink extends Thread {
 
     /**
      * Return the outputs of previous commands from a specified instance/
-     * 

+ *

* workspace form matlab. - *

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   String buffer;
@@ -1357,16 +1357,16 @@ public class JMatLink extends Thread {
 
     /**
      * Return the ouputs of previous commands in matlab's workspace.
-     * 

- *

- *

+ *

+ *

+ *

* Right now the parameter buflen is not supported. - *

- *

- *

- *

+ *

+ *

+ *

+ *

* E.g.:
- *

+ *

*

      *
      *   String buffer;
diff --git a/test/eva2/tools/math/MathematicsTest.java b/test/eva2/tools/math/MathematicsTest.java
index 5d7a21a8..dc2cbcd3 100644
--- a/test/eva2/tools/math/MathematicsTest.java
+++ b/test/eva2/tools/math/MathematicsTest.java
@@ -8,8 +8,12 @@ import static org.junit.Assert.assertTrue;
 public class MathematicsTest {
 
     @Test
-    public void testEuclidianDist() throws Exception {
+    public void testEuclideanDist() throws Exception {
+        double[] values1 = {6.0, 51.0, 3.0};
+        double[] values2 = {1.9, 99.0, 2.9};
 
+        assertEquals(48.174889, Mathematics.euclideanDist(values1, values2), 0.00001);
+        assertEquals(48.174889, Mathematics.euclideanDist(values2, values1), 0.00001);
     }
 
     @Test