JavaDoc fixes and larger code cleanup.
This commit is contained in:
parent
7c896fea8d
commit
837c4fea32
@ -37,11 +37,11 @@ import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p> 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.
|
||||
* </p> <p>
|
||||
* <p>
|
||||
* 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();
|
||||
* </code> </p>
|
||||
* </code>
|
||||
*/
|
||||
public class OptimizerFactory {
|
||||
|
||||
|
@ -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;
|
||||
|
@ -28,8 +28,8 @@ class SplashScreen extends JWindow {
|
||||
|
||||
/**
|
||||
* Show the splash screen to the end user.
|
||||
* <p/>
|
||||
* <P>Once this method returns, the splash screen is realized, which means
|
||||
* <p>
|
||||
* 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
|
||||
* <code>dispose</code> for the splash screen must be performed in the event
|
||||
|
@ -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:
|
||||
* </p><p>
|
||||
* <p>
|
||||
* http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html
|
||||
* or
|
||||
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
|
||||
* </p><p>
|
||||
* <p>
|
||||
* Note that the API changed slightly in the 3rd version:
|
||||
* You must now invoke start() on the SwingWorker after
|
||||
* creating it.
|
||||
|
@ -299,7 +299,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
/**
|
||||
* *******************************************************************************************************************
|
||||
* These are for InterfaceDataTypeBinary
|
||||
* <p/>
|
||||
* <p>
|
||||
* /** This method allows you to request a certain amount of binary data
|
||||
*
|
||||
* @param length The lenght of the BitSet that is to be optimized
|
||||
|
@ -192,7 +192,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
|
||||
/**
|
||||
* *******************************************************************************************************************
|
||||
* These are for InterfaceDataTypeDouble
|
||||
* <p/>
|
||||
* <p>
|
||||
* /** This method allows you to request a certain amount of double data
|
||||
*
|
||||
* @param length The lenght of the double[] that is to be optimized
|
||||
|
@ -196,7 +196,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
|
||||
/**
|
||||
* *******************************************************************************************************************
|
||||
* These are for InterfaceDataTypeInteger
|
||||
* <p/>
|
||||
* <p>
|
||||
* /** This method allows you to request a certain amount of int data
|
||||
*
|
||||
* @param length The lenght of the int[] that is to be optimized
|
||||
|
@ -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.
|
||||
* <p>Title: EvA2</p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: </p>
|
||||
*
|
||||
* @author planatsc
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface InterfaceOBGAIndividual {
|
||||
|
@ -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";
|
||||
|
@ -19,7 +19,7 @@ import java.util.logging.Level;
|
||||
/**
|
||||
* OptimizationParameters for configuration of an
|
||||
* optimization run.
|
||||
* </p><p>
|
||||
* <p>
|
||||
* This class is used to generate the default GUI
|
||||
* configuration panel for optimizations.
|
||||
*/
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
|
@ -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:
|
||||
|
@ -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)).
|
||||
* </p><p>
|
||||
* <p>
|
||||
* where c[i] is the i-th child component and p_ij is the i-th component
|
||||
* of parent j.
|
||||
*/
|
||||
|
@ -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) {
|
||||
|
@ -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)).
|
||||
* <p/>
|
||||
* <p>
|
||||
* This can be used with any individual type that implements getDoublePositionShallow.
|
||||
*
|
||||
* @see AbstractEAIndividual#getDoublePositionShallow(AbstractEAIndividual)
|
||||
|
@ -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!";
|
||||
}
|
||||
}
|
||||
|
@ -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).
|
||||
* </p><p>
|
||||
* <p>
|
||||
* 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.
|
||||
|
@ -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.
|
||||
* </p><p>
|
||||
* <p>
|
||||
* 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
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
|
@ -10,7 +10,7 @@ import eva2.util.annotation.Description;
|
||||
|
||||
|
||||
/**
|
||||
* <p/>
|
||||
* <p>
|
||||
* Mutates a permutation by inversion a part of the permutation.
|
||||
* <br><br>
|
||||
* <b>Example: </b>
|
||||
|
@ -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");
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
*
|
||||
|
@ -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.
|
||||
* </p><p>
|
||||
* <p>
|
||||
* 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.")
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* For refining, either known optima are used or {@link AbstractOptimizationProblem}.extractPotentialOptima()
|
||||
* is called.
|
||||
*
|
||||
|
@ -5,7 +5,7 @@ import eva2.util.annotation.Description;
|
||||
|
||||
/**
|
||||
* A eva2.problems.simple sum to calculate the selection probability.
|
||||
* <p/>
|
||||
* <p>
|
||||
* p(i is selected) = exp(-fitness(i))/sum_j(exp(-fitness(j)))
|
||||
*/
|
||||
@Description("This is a standard normation method using the exp function.")
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* Listeners implementing InterfaceTextListener receive String output (human readable).
|
||||
* Listeners implementing InterfaceStatisticsListener receive the raw data per iteration.
|
||||
*/
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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<Object[]> 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;
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ public class OptimizationJobList extends PropertySelectableList<OptimizationJob>
|
||||
/**
|
||||
* 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<OptimizationJob>
|
||||
/**
|
||||
* 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<OptimizationJob>
|
||||
/**
|
||||
* Return a list of the currently selected jobs.
|
||||
*
|
||||
* @return
|
||||
* @return A List of selected jobs
|
||||
*/
|
||||
public ArrayList<OptimizationJob> getSelectedJobs() {
|
||||
OptimizationJob[] selected = getSelectedObjects();
|
||||
|
@ -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<OptimizationJob> 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<OptimizationJob> 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<OptimizationJob> 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<OptimizationJob> 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<OptimizationJob> 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("");
|
||||
}
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* [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,
|
||||
|
@ -27,7 +27,7 @@ import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Basic implementation of the Bayesian Optimization Algorithm
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ import java.util.BitSet;
|
||||
/**
|
||||
* A BinaryScatterSearch implementation taken mainly from [i].
|
||||
*
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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)
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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).
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* For certain types of parameter adaption schemes, this automatically sets
|
||||
* the upper limit if the clustering parameter is controlled.
|
||||
*
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* Some notes:
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* TODO Add adaptive niche radius. Add parameter to every indy which is adapted
|
||||
* after all new peaks have been found.
|
||||
*/
|
||||
|
@ -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).
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* A.Auger & N.Hansen. A Restart CMA Evolution Strategy With Increasing Population Size. CEC 2005.
|
||||
*/
|
||||
@Description("An ES with increasing population size.")
|
||||
|
@ -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++) {
|
||||
|
@ -15,7 +15,7 @@ import eva2.util.annotation.Description;
|
||||
/**
|
||||
* A gradient descent algorithm by hannes planatscher don't expect any
|
||||
* descriptions here... *big sigh*
|
||||
* <p/>
|
||||
* <p>
|
||||
* mkron added some!
|
||||
*
|
||||
*/
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* [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. <EFBFBD>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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
// /**
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* Possible topologies are: "Linear", "Grid", "Star", "Multi-Swarm", "Tree",
|
||||
* "HPSO", "Random" in that order starting by 0.
|
||||
*/
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
|
@ -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).
|
||||
*
|
||||
* <p/>
|
||||
* <p>
|
||||
* [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.
|
||||
|
@ -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
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
* <p/>
|
||||
* <p>
|
||||
* Original notes:
|
||||
*/
|
||||
/* Last updates (M.Clerc)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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).
|
||||
* <p/>
|
||||
* <p>
|
||||
* This is in analogy to the original implementation by F.Streichert.
|
||||
*
|
||||
* @param realOpts
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* The given position is expected to be unrotated! The returned solution is
|
||||
* unrotated as well.
|
||||
*
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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." +
|
||||
|
@ -4,7 +4,7 @@ import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* A multimodal problem which has knowledge of its optima.
|
||||
* <p/>
|
||||
* <p>
|
||||
* User: streiche
|
||||
* Date: 23.04.2003
|
||||
* Time: 10:57:47
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* <strong>Example</strong>
|
||||
* 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
|
||||
|
@ -6,7 +6,7 @@ import java.awt.*;
|
||||
* <code>DComponent</code> is the mother of all objects which can be displayed
|
||||
* by a <code>DArea</code> object, even when it would be also enough to
|
||||
* implement the <code>DElement</code> interface to an class
|
||||
* </p>
|
||||
* <p>
|
||||
* 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();
|
||||
|
@ -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 <code>null</code>
|
||||
* <p/>
|
||||
* <p>
|
||||
* Tuning: rect must not be empty
|
||||
*
|
||||
* @param rect the image rectangle
|
||||
|
@ -2,10 +2,10 @@ package eva2.tools.math.Jama;
|
||||
|
||||
/**
|
||||
* Cholesky Decomposition.
|
||||
* <p/>
|
||||
* <p>
|
||||
* For a symmetric, positive definite matrix A, the Cholesky decomposition
|
||||
* is an lower triangular matrix L so that A = L*L'.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
|
@ -5,12 +5,12 @@ import eva2.tools.math.Jama.util.Maths;
|
||||
|
||||
/**
|
||||
* Eigenvalues and eigenvectors of a real matrix.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
|
@ -3,12 +3,12 @@ package eva2.tools.math.Jama;
|
||||
|
||||
/**
|
||||
* LU Decomposition.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
|
@ -19,7 +19,7 @@ import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Jama = Java Matrix class.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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;
|
||||
* </UL>
|
||||
* <DL>
|
||||
* <DT><B>Example of use:</B></DT>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <DD>Solve a linear system A x = b and compute the residual norm, ||b - A x||.
|
||||
* <P><PRE>
|
||||
* 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::
|
||||
* <p/>
|
||||
* <p>
|
||||
* [[a0*b0 a0*b1 ... a0*bN ]
|
||||
* [a1*b0 .
|
||||
* [ ... .
|
||||
|
@ -4,11 +4,11 @@ import eva2.tools.math.Jama.util.Maths;
|
||||
|
||||
/**
|
||||
* QR Decomposition.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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
|
||||
|
@ -5,14 +5,14 @@ import eva2.tools.math.Jama.util.Maths;
|
||||
|
||||
/**
|
||||
* Singular Value Decomposition.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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'.
|
||||
* <p/>
|
||||
* <p>
|
||||
* The singular values, sigma[k] = S[k][k], are ordered so that
|
||||
* sigma[0] >= sigma[1] >= ... >= sigma[n-1].
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* <B>NOTE:</B> 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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* <FONT size=2>
|
||||
* Converted to Java from<BR>
|
||||
* Cephes Math Library Release 2.2: July, 1992<BR>
|
||||
@ -662,7 +662,7 @@ public final class SpecialFunction {
|
||||
* @param a double value
|
||||
* @param x double value
|
||||
* @return the Complemented Incomplete Gamma function.
|
||||
* <p/>
|
||||
* <p>
|
||||
* <FONT size=2>
|
||||
* Converted to Java from<BR>
|
||||
* Cephes Math Library Release 2.2: July, 1992<BR>
|
||||
@ -737,7 +737,7 @@ public final class SpecialFunction {
|
||||
* @param a double value
|
||||
* @param x double value
|
||||
* @return the Incomplete Gamma function.
|
||||
* <p/>
|
||||
* <p>
|
||||
* <FONT size=2>
|
||||
* Converted to Java from<BR>
|
||||
* Cephes Math Library Release 2.2: July, 1992<BR>
|
||||
@ -811,7 +811,7 @@ public final class SpecialFunction {
|
||||
* @param df degrees of freedom
|
||||
* @param x double value
|
||||
* @return the Chi-Square function.
|
||||
* <p/>
|
||||
* <p>
|
||||
*/
|
||||
|
||||
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
|
||||
* <p/>
|
||||
* <p>
|
||||
* <FONT size=2>
|
||||
* Converted to Java from<BR>
|
||||
* Cephes Math Library Release 2.2: July, 1992<BR>
|
||||
@ -997,7 +997,7 @@ public final class SpecialFunction {
|
||||
/**
|
||||
* @param a double value
|
||||
* @return The Error function
|
||||
* <p/>
|
||||
* <p>
|
||||
* <FONT size=2>
|
||||
* Converted to Java from<BR>
|
||||
* Cephes Math Library Release 2.2: July, 1992<BR>
|
||||
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* <FONT size=2>
|
||||
* Converted to Java from<BR>
|
||||
* Cephes Math Library Release 2.3: July, 1995<BR>
|
||||
|
@ -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.
|
||||
* <p/>
|
||||
* <p>
|
||||
* 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)) {
|
||||
|
@ -250,12 +250,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* This is the constructor for the JMatLink library.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* <b>JMatLink</b> engine = new <b>JMatLink()</b>;
|
||||
@ -297,14 +297,14 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Open engine. This command is used to open a <b>single</b> connection
|
||||
* <p/>
|
||||
* <p>
|
||||
* to matlab.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* JMatLink engine = new JMatLink();
|
||||
@ -330,18 +330,18 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Open engine. This command is used to open a <b>single</b> connection
|
||||
* <p/>
|
||||
* <p>
|
||||
* to matlab.
|
||||
* <p/>
|
||||
* <p>
|
||||
* This command is only useful on unix systems. On windows
|
||||
* <p/>
|
||||
* <p>
|
||||
* the optional parameter <b>must</b> be NULL.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* JMatLink engine = new JMatLink();
|
||||
@ -382,14 +382,14 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Open engine for single use. This command is used to open
|
||||
* <p/>
|
||||
* <p>
|
||||
* <b>multiple</b> connections to matlab.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* int a,b;
|
||||
@ -424,14 +424,14 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Open engine for single use. This command is used to open
|
||||
* <p/>
|
||||
* <p>
|
||||
* <b>multiple</b> connections to matlab.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* int a,b;
|
||||
@ -478,12 +478,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Close the connection to matlab.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* JMatLink engine = new JMatLink();
|
||||
@ -510,12 +510,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Close a specified connection to an instance of matlab.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* int a,b;
|
||||
@ -564,11 +564,11 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Evaluate an expression in matlab's workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* JMatLink engine = new JMatLink();
|
||||
@ -595,12 +595,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Evaluate an expression in a specified workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* int a,b;
|
||||
@ -653,12 +653,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Get a scalar value from matlab's workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* double a;
|
||||
@ -689,12 +689,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Get a scalar value from a specified workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* double a;
|
||||
@ -749,12 +749,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Get an array (1 * n) from matlab's workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* double[] array;
|
||||
@ -785,12 +785,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Get an array (1 * n) from a specified workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* int b;
|
||||
@ -839,12 +839,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Get an array from matlab's workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* int b;
|
||||
@ -877,12 +877,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Get an array from a specified instance/workspace of matlab.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* int b;
|
||||
@ -931,12 +931,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Get an 'char' array (string) from matlab's workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* String array;
|
||||
@ -983,12 +983,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Put an array into a specified workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* int array = 1;
|
||||
@ -1027,12 +1027,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Put an array into matlab's workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* double array = 1;
|
||||
@ -1061,12 +1061,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Put an array into a specified instance/workspace of matlab.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* int b;
|
||||
@ -1101,14 +1101,14 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Put an array (1 dimensional) into a specified instance/workspace of
|
||||
* <p/>
|
||||
* <p>
|
||||
* matlab.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* 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
|
||||
* <p/>
|
||||
* <p>
|
||||
* matlab.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* int b;
|
||||
@ -1184,12 +1184,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Put an array (2 dimensional) into matlab's workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* 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
|
||||
* <p/>
|
||||
* <p>
|
||||
* matlab.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* int b;
|
||||
@ -1279,12 +1279,12 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Return the outputs of previous commands from matlab's workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* String buffer;
|
||||
@ -1317,14 +1317,14 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Return the outputs of previous commands from a specified instance/
|
||||
* <p/>
|
||||
* <p>
|
||||
* workspace form matlab.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* String buffer;
|
||||
@ -1357,16 +1357,16 @@ public class JMatLink extends Thread {
|
||||
|
||||
/**
|
||||
* Return the ouputs of previous commands in matlab's workspace.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* Right now the parameter <i>buflen</i> is not supported.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* E.g.:<br>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <pre>
|
||||
*
|
||||
* String buffer;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user