diff --git a/ea/project/EaVolleyballProject/.classpath b/ea/project/EaVolleyballProject/.classpath new file mode 100644 index 0000000..49acc1f --- /dev/null +++ b/ea/project/EaVolleyballProject/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ea/project/EaVolleyballProject/.project b/ea/project/EaVolleyballProject/.project new file mode 100644 index 0000000..d13b6b1 --- /dev/null +++ b/ea/project/EaVolleyballProject/.project @@ -0,0 +1,17 @@ + + + EaVolleyballProject + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/ea/project/EaVolleyballProject/.settings/org.eclipse.jdt.core.prefs b/ea/project/EaVolleyballProject/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..7341ab1 --- /dev/null +++ b/ea/project/EaVolleyballProject/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/ea/project/EaVolleyballProject/EvA2.jar b/ea/project/EaVolleyballProject/EvA2.jar new file mode 100644 index 0000000..5ce9a70 --- /dev/null +++ b/ea/project/EaVolleyballProject/EvA2.jar Binary files differ diff --git a/ea/project/EaVolleyballProject/OptimizationParameters.yml b/ea/project/EaVolleyballProject/OptimizationParameters.yml new file mode 100644 index 0000000..cb18ee1 --- /dev/null +++ b/ea/project/EaVolleyballProject/OptimizationParameters.yml @@ -0,0 +1,252 @@ +!!eva2.optimization.modules.OptimizationParameters +optimizer: !!eva2.optimization.strategies.EvolutionStrategies + environmentSelection: !!eva2.optimization.operator.selection.SelectBestIndividuals { + obeyDebsConstViolationPrinciple: true} + lambda: 20 + mu: 5 + numberOfPartners: 1 + parentSelection: !!eva2.optimization.operator.selection.SelectRandom {obeyDebsConstViolationPrinciple: false} + partnerSelection: !!eva2.optimization.operator.selection.SelectRandom {obeyDebsConstViolationPrinciple: false} + plusStrategy: false + population: + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: &id001 !!eva2.optimization.operator.crossover.CrossoverESDefault {} + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.1297485159812414, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.0958088606270435, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.10272532610948962, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.07526296515212202, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.09584497608040886, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.09980168632548005, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.11863413316848513, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.12849025565315003, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.11568110968515462, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.14338098383253595, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.08734977687266793, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.1098773972777742, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.1021572608823929, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.0847210377938867, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.08853603244786161, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.07472246902143609, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.09278219055003001, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.09941360830188067, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.08851303873387742, tau1: 0.15} + mutationProbability: 1.0 + - !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.12157528956545222, tau1: 0.15} + mutationProbability: 1.0 +postProcessParams: !!eva2.optimization.operator.postprocess.PostProcessParams + PPMethod: nelderMead + accAssumeConv: 1.0E-8 + accMaxEval: -1 + accuracies: [0.01] + doPostProcessing: false + postProcessClusterSigma: 0.05 + postProcessSteps: 5000 + printNBest: 10 + withPlot: false +problem: !!eva2.problems.SimpleProblemWrapper + defaultAccuracy: 0.001 + defaultRange: 10.0 + individualTemplate: !!eva2.optimization.individuals.ESIndividualDoubleData + areaConst4ParallelViolated: false + crossoverOperator: *id001 + crossoverProbability: 0.5 + initOperator: !!eva2.optimization.operator.initialization.DefaultInitialization {} + isMarked: false + isPenalized: false + mutationOperator: !!eva2.optimization.operator.mutation.MutateESGlobal {crossoverType: intermediate, + lowerLimitStepSize: 5.0E-7, mutationStepSize: 0.2, tau1: 0.15} + mutationProbability: 1.0 + noise: 0.0 + parallelThreads: 1 + simpleProblem: !!eva2.problems.simple.HyperVolleyballProblem + dimension: 3 + playerSigma: 0.5 + players: + - position: [4.5, 4.5] + sigma: 1.0 + - position: [2.25, 2.25] + sigma: 1.0 + - position: [2.25, 6.75] + sigma: 1.0 + - position: [6.75, 2.25] + sigma: 1.0 + - position: [6.75, 6.75] + sigma: 1.0 +randomSeed: 0 +terminator: !!eva2.optimization.operator.terminators.EvaluationTerminator {fitnessCalls: 500} diff --git a/ea/project/EaVolleyballProject/Statistics.ser b/ea/project/EaVolleyballProject/Statistics.ser new file mode 100644 index 0000000..b929201 --- /dev/null +++ b/ea/project/EaVolleyballProject/Statistics.ser Binary files differ diff --git a/ea/project/EaVolleyballProject/bin/eva2/problems/simple/ExampleProblem$EvaluateFunction.class b/ea/project/EaVolleyballProject/bin/eva2/problems/simple/ExampleProblem$EvaluateFunction.class new file mode 100644 index 0000000..aa01e09 --- /dev/null +++ b/ea/project/EaVolleyballProject/bin/eva2/problems/simple/ExampleProblem$EvaluateFunction.class Binary files differ diff --git a/ea/project/EaVolleyballProject/bin/eva2/problems/simple/ExampleProblem.class b/ea/project/EaVolleyballProject/bin/eva2/problems/simple/ExampleProblem.class new file mode 100644 index 0000000..f61dd78 --- /dev/null +++ b/ea/project/EaVolleyballProject/bin/eva2/problems/simple/ExampleProblem.class Binary files differ diff --git a/ea/project/EaVolleyballProject/bin/eva2/problems/simple/HyperVolleyballProblem$Player.class b/ea/project/EaVolleyballProject/bin/eva2/problems/simple/HyperVolleyballProblem$Player.class new file mode 100644 index 0000000..47b8269 --- /dev/null +++ b/ea/project/EaVolleyballProject/bin/eva2/problems/simple/HyperVolleyballProblem$Player.class Binary files differ diff --git a/ea/project/EaVolleyballProject/bin/eva2/problems/simple/HyperVolleyballProblem.class b/ea/project/EaVolleyballProject/bin/eva2/problems/simple/HyperVolleyballProblem.class new file mode 100644 index 0000000..f50fb06 --- /dev/null +++ b/ea/project/EaVolleyballProject/bin/eva2/problems/simple/HyperVolleyballProblem.class Binary files differ diff --git a/ea/project/EaVolleyballProject/src/eva2/problems/simple/ExampleProblem.java b/ea/project/EaVolleyballProject/src/eva2/problems/simple/ExampleProblem.java new file mode 100644 index 0000000..4a448e3 --- /dev/null +++ b/ea/project/EaVolleyballProject/src/eva2/problems/simple/ExampleProblem.java @@ -0,0 +1,185 @@ +package eva2.problems.simple; + +import eva2.util.annotation.Description; +import eva2.util.annotation.Parameter; + +/** + * This is a simple example for adding problems to EvA2. The EvA2.jar is + * required for this class! The jar file is available from + * http://www.ra.cs.uni-tuebingen.de/software/EvA2/downloads/2.2.0-rc1/EvA2.jar
+ *
+ * To be found by EvA2, this class must remain in the package + * eva2.problems.simple!
+ *
+ * Depending on your representation of a solution, you must extend either the + * class SimpleProblemDouble or SimpleProblemBinary!
+ *
+ * To optimize this problem, start EvA2 (use the eva2.gui.Main class) and select + * as Problem: SimpleProblemWrapper. Next select as Simple Problem: + * eva2.problems.simple.ExampleProblem and customize any parameters. You can now + * try different optimization algorithms!
+ *
+ * To launch EvA2 from the command line with this custom problem:
+ * 1. extract the EvA2.jar (NOT EvA2Base.jar!)
+ * 2. place this class file in the directory eva2/problems/simple/
+ * 3. compile this class with: javac eva2/problems/simple/ExampleProblem.java
+ * 4. start EvA2 with: java eva2.gui.Main
+ *
+ * Some tips: - Look at the function setAbs, setDimension, and + * setEvaluateFunction to see how EvA2 recognizes changeable inputs! Note that + * getX() and setX() must be present to correctly provide the input! + * + * @author mroemer + * + */ +@Description("An example problem for including new problems in EvA2.") +public class ExampleProblem extends SimpleProblemDouble { + + /** + * + */ + private static final long serialVersionUID = 2796213693976730841L; + + /** + * Possible functions to evaluate the fitness + */ + public enum EvaluateFunction { + SUM, MIN, MAX, MEAN + } + + /** + * Problem dimension + */ + private int dimension = 10; + /** + * Fitness evaluation function + */ + private EvaluateFunction evalFun = EvaluateFunction.SUM; + /** + * Use absolute values for evaluation? + */ + private boolean useAbs = true; + + public ExampleProblem() { + // Here you can read files you need (i.e., input data) or set default values + // for parameters + } + + /** + * Evaluate a double vector representing a possible problem solution as part + * of an individual in the EvA framework. This makes up the target function to + * be evaluated. + * + * @param x + * a double vector to be evaluated + * @return the fitness vector assigned to x as to the target function (the + * return value is actually a array with only one entry!) + */ + @Override + public double[] evaluate(double[] individual) { + double fitness = 0; + switch (evalFun) { + case SUM: + fitness = 0; + for (int i = 0; i < individual.length; i++) { + fitness += evalAt(individual, i); + } + break; + case MIN: + fitness = Double.POSITIVE_INFINITY; + for (int i = 0; i < individual.length; i++) { + fitness = Math.min(fitness, evalAt(individual, i)); + } + break; + case MAX: + fitness = Double.NEGATIVE_INFINITY; + for (int i = 0; i < individual.length; i++) { + fitness = Math.max(fitness, evalAt(individual, i)); + } + break; + case MEAN: + fitness = 0; + for (int i = 0; i < individual.length; i++) { + fitness += evalAt(individual, i); + } + fitness = fitness / dimension; + break; + default: + break; + } + return new double[] { fitness }; + } + + // Evaluates an individual at a single point + // This is a abstraction to simplify incorporation of useAbs... + private double evalAt(double[] individual, int i) { + return useAbs ? Math.abs(individual[i]) : individual[i]; + } + + /* + * Below are parameters that can be set at runtime! See the class comment for + * more information... + */ + + /** + * Return the problem dimension. + * + * @return the problem dimension + */ + @Override + public int getProblemDimension() { + return dimension; + } + + /** + * This method allows you to toggle the usage of absolute values. + * + * @param show + * Whether to use absolute values or not + */ + @Parameter(description = "Use absolute values for evaluation?") + public void setAbs(boolean useAbs) { + this.useAbs = useAbs; + } + + public boolean getAbs() { + return this.useAbs; + } + + /** + * Set the problem dimension. + * + * @param d + * The dimension. + */ + @Parameter(description = "Set 1 <= Dimension <= 1000.") + public void setDimension(int d) { + if (d < 1) { + d = 1; + } + if (d > 1000) { + d = 1000; + } + this.dimension = d; + } + + public int getDimension() { + return this.dimension; + } + + /** + * Set the evaluation function. + * + * @param f + * The evaluation function. + */ + @Parameter(description = "Choose the timeinterval type.") + public void setEvaluateFunction(EvaluateFunction f) { + this.evalFun = f; + } + + public EvaluateFunction getEvaluateFunction() { + return this.evalFun; + } + +} diff --git a/ea/project/EaVolleyballProject/src/eva2/problems/simple/HyperVolleyballProblem.java b/ea/project/EaVolleyballProject/src/eva2/problems/simple/HyperVolleyballProblem.java new file mode 100644 index 0000000..27a6b10 --- /dev/null +++ b/ea/project/EaVolleyballProject/src/eva2/problems/simple/HyperVolleyballProblem.java @@ -0,0 +1,245 @@ +package eva2.problems.simple; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +import eva2.util.annotation.Description; +import eva2.util.annotation.Parameter; + +/** + * @author Maximus Mutschler & Jan-Peter Hohloch + * + */ + +@Description("Getting an Ass in Hypervolleyball.") +public class HyperVolleyballProblem extends SimpleProblemDouble { + private static final long serialVersionUID = 2796213693976730881L; + /** + * Problem dimension + */ + private int dimension = 4; + + private int spaceDimension = dimension - 1; + + private Random r = new Random(); + + /** + * Regular court's side's size. + */ + private final double courtSize = 9; + + /** + * 2^(n)+1 players on the court. Where n is the number of space dimensions. + * This means, in a two dimensional court, there are 5 players arranged like + * a cross. + */ + private int numberOfPlayers = getNumberOfPlayers(); + + public List players = new ArrayList(); + + /** + * same range for all players + */ + private double sigma = 1; + + public HyperVolleyballProblem() { + calcPlayers(); + } + + private void calcPlayers() { + players.clear(); + double[] position = new double[spaceDimension]; + Arrays.fill(position, courtSize / 2); + players.add(new Player(position, sigma)); + + double[][] positions = new double[numberOfPlayers - 1][spaceDimension]; + playerPositions(0, numberOfPlayers - 1, positions, 0); + + for (double[] p : positions) { + players.add(new Player(p, sigma)); + } + } + + /** + * + * @param begin + * index + * @param end + * index + * @param positions + * will get filled with the positions of the players + * @param index + * current dimension. + */ + private void playerPositions(int begin, int end, double[][] positions, + int index) { + if (index == positions[0].length) { + return; + } + int center = (((end - begin) / 2) + begin); + for (int i = begin; i < center; i++) { + positions[i][index] = courtSize / 4; + } + for (int i = center; i < end; i++) { + positions[i][index] = (courtSize * 3) / 4; + } + playerPositions(begin, center, positions, index + 1); + playerPositions(center, end, positions, index + 1); + } + + private double density(double[] position) { + double dens = 0; + for (Player p : players) { + dens += normDistribution(distance(position, p.getPosition()), 0, + p.getSigma()); + } + return dens; + } + + private double distance(double[] a, double[] b) { + double dist = 0; + for (int i = 0; i < b.length; i++) { + dist += (a[i] - b[i]) * (a[i] - b[i]); + } + return Math.sqrt(dist); + } + + private double normDistribution(double x, double mu, double sigma) { + return (1 / (Math.sqrt(2 * Math.PI) * sigma)) + * Math.exp((-0.5 * (x - mu) * (x - mu)) / (sigma * sigma)); + } + + @Override + public double[] evaluate(double[] individual) { + double force = individual[0]; + int penalty = 1; + if (force <= 0) { + return new double[] { penalty - force }; + } + double[] position = Arrays + .copyOfRange(individual, 1, individual.length); + + for (int i = 0; i < position.length; i++) { + position[i] += r.nextGaussian() * force; + } + + for (double p : position) { + if ((p > courtSize) || (p < 0)) { + return new double[] { p < 0 ? penalty - p + : (penalty - courtSize) + p };// abweichung + // vom + // feld + // nehmen + } + } + + return new double[] { density(position) // individual[0] = velocity. + / force }; + } + + @Override + public int getProblemDimension() { + return dimension; + } + + public int getDimension() { + return this.dimension; + } + + /** + * Set the problem dimension. + * + * @param d + * The dimension. + */ + @Parameter(description = "Set 2 <= Dimension <= 100.") + public void setDimension(int d) { + if (d < 2) { + d = 2; + } + if (d > 100) { + d = 100; + } + dimension = d; + spaceDimension = dimension - 1; + numberOfPlayers = getNumberOfPlayers(); + calcPlayers(); + + } + + private int getNumberOfPlayers() { + return (int) Math.pow(2, (spaceDimension)) + 1; + } + + @Parameter(description = "Set 0 < Sigma (Players \"range\")") + public void setPlayerSigma(double sigma) { + if (sigma != 0) { + this.sigma = Math.abs(sigma); + } + } + + public double getPlayerSigma() { + return sigma; + } + + public class Player { + private static final long serialVersionUID = 2796413693976730841L; + private double[] position; + private double sigma; + + public Player() { + setPosition(new double[] { 0, 0, 0 }); + setSigma(1); + } + + public Player(double[] position, double sigma) { + this.setPosition(position); + this.setSigma(sigma); + } + + @Override + public String toString() { + return Arrays.toString(getPosition()) + " sigma:" + getSigma(); + } + + /** + * @return the position + */ + public double[] getPosition() { + return position; + } + + /** + * @param position + * the position to set + */ + public void setPosition(double[] position) { + this.position = position; + } + + /** + * @return the sigma + */ + public double getSigma() { + return sigma; + } + + /** + * @param sigma + * the sigma to set + */ + public void setSigma(double sigma) { + this.sigma = sigma; + } + + } + + // public static void main(String[] args) { + // HyperVolleyballProblem p = new HyperVolleyballProblem(); + // for (Player pl : p.players) { + // System.out.println(pl); + // } + // } +} diff --git a/ea/project/EvA2.jar b/ea/project/EvA2.jar deleted file mode 100644 index 5ce9a70..0000000 --- a/ea/project/EvA2.jar +++ /dev/null Binary files differ