diff --git a/src/eva2/optimization/operator/crossover/PropertyCrossoverMixer.java b/src/eva2/optimization/operator/crossover/PropertyCrossoverMixer.java index b1a22ef9..2c773927 100644 --- a/src/eva2/optimization/operator/crossover/PropertyCrossoverMixer.java +++ b/src/eva2/optimization/operator/crossover/PropertyCrossoverMixer.java @@ -31,7 +31,7 @@ public class PropertyCrossoverMixer implements java.io.Serializable { this.m_NormalizationEnabled = d.m_NormalizationEnabled; this.m_AvailableTargets = new InterfaceCrossover[d.m_AvailableTargets.length]; for (int i = 0; i < this.m_AvailableTargets.length; i++) { - //this.m_AvailableTargets[i] = (InterfaceMutation)d.m_AvailableTargets[i].clone(); + //this.availableTargets[i] = (InterfaceMutation)d.availableTargets[i].clone(); this.m_AvailableTargets[i] = d.m_AvailableTargets[i]; } this.m_SelectedTargets = new InterfaceCrossover[d.m_SelectedTargets.length]; diff --git a/src/eva2/optimization/operator/mutation/MutateEAMixer.java b/src/eva2/optimization/operator/mutation/MutateEAMixer.java index 5f57b536..9e2c4430 100644 --- a/src/eva2/optimization/operator/mutation/MutateEAMixer.java +++ b/src/eva2/optimization/operator/mutation/MutateEAMixer.java @@ -10,18 +10,14 @@ import java.util.ArrayList; /** - * Created by IntelliJ IDEA. - * User: streiche - * Date: 20.05.2005 - * Time: 13:53:46 - * To change this template use File | Settings | File Templates. + * */ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { - private PropertyMutationMixer m_Mutators; - private boolean m_UseSelfAdaption = false; - protected double m_Tau1 = 0.15; - protected double m_LowerLimitChance = 0.05; + private PropertyMutationMixer mutationMixer; + private boolean useSelfAdaption = false; + protected double tau1 = 0.15; + protected double lowerLimitChance = 0.05; public MutateEAMixer() { InterfaceMutation[] tmpList; @@ -41,14 +37,14 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { System.out.println("Illegal access exception for " + (String) mutators.get(i)); } } - this.m_Mutators = new PropertyMutationMixer(tmpList, false); + this.mutationMixer = new PropertyMutationMixer(tmpList, false); tmpList = new InterfaceMutation[2]; tmpList[0] = new MutateGINominal(); tmpList[1] = new MutateGIOrdinal(); - this.m_Mutators.setSelectedMutators(tmpList); - this.m_Mutators.normalizeWeights(); - this.m_Mutators.setDescriptiveString("Combining alternative mutation operators, please norm the weights!"); - this.m_Mutators.setWeightsLabel("Weigths"); + this.mutationMixer.setSelectedMutators(tmpList); + this.mutationMixer.normalizeWeights(); + this.mutationMixer.setDescriptiveString("Combining alternative mutation operators, please norm the weights!"); + this.mutationMixer.setWeightsLabel("Weigths"); } @@ -58,7 +54,7 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { * @param mutators */ public MutateEAMixer(InterfaceMutation... mutators) { - this.m_Mutators = new PropertyMutationMixer(mutators, true); + this.mutationMixer = new PropertyMutationMixer(mutators, true); } public MutateEAMixer(InterfaceMutation m1, InterfaceMutation m2) { @@ -70,10 +66,10 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { } public MutateEAMixer(MutateEAMixer mutator) { - this.m_Mutators = (PropertyMutationMixer) mutator.m_Mutators.clone(); - this.m_UseSelfAdaption = mutator.m_UseSelfAdaption; - this.m_Tau1 = mutator.m_Tau1; - this.m_LowerLimitChance = mutator.m_LowerLimitChance; + this.mutationMixer = (PropertyMutationMixer) mutator.mutationMixer.clone(); + this.useSelfAdaption = mutator.useSelfAdaption; + this.tau1 = mutator.tau1; + this.lowerLimitChance = mutator.lowerLimitChance; } /** @@ -111,7 +107,7 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { */ @Override public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) { - InterfaceMutation[] mutators = this.m_Mutators.getSelectedMutators(); + InterfaceMutation[] mutators = this.mutationMixer.getSelectedMutators(); for (int i = 0; i < mutators.length; i++) { mutators[i].init(individual, opt); } @@ -125,22 +121,22 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { */ @Override public void mutate(AbstractEAIndividual individual) { - this.m_Mutators.normalizeWeights(); - double[] probs = this.m_Mutators.getWeights(); - if (this.m_UseSelfAdaption) { + this.mutationMixer.normalizeWeights(); + double[] probs = this.mutationMixer.getWeights(); + if (this.useSelfAdaption) { for (int i = 0; i < probs.length; i++) { - probs[i] *= Math.exp(this.m_Tau1 * RNG.gaussianDouble(1)); - if (probs[i] <= this.m_LowerLimitChance) { - probs[i] = this.m_LowerLimitChance; + probs[i] *= Math.exp(this.tau1 * RNG.gaussianDouble(1)); + if (probs[i] <= this.lowerLimitChance) { + probs[i] = this.lowerLimitChance; } if (probs[i] >= 1) { probs[i] = 1; } } - this.m_Mutators.normalizeWeights(); + this.mutationMixer.normalizeWeights(); } - InterfaceMutation[] mutators = this.m_Mutators.getSelectedMutators(); + InterfaceMutation[] mutators = this.mutationMixer.getSelectedMutators(); double pointer = RNG.randomFloat(0, 1); double dum = probs[0]; int index = 0; @@ -168,8 +164,8 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { */ @Override public void crossoverOnStrategyParameters(AbstractEAIndividual indy1, Population partners) { - for (int i = 0; i < this.m_Mutators.getSelectedMutators().length; i++) { - this.m_Mutators.getSelectedMutators()[i].crossoverOnStrategyParameters(indy1, partners); + for (int i = 0; i < this.mutationMixer.getSelectedMutators().length; i++) { + this.mutationMixer.getSelectedMutators()[i].crossoverOnStrategyParameters(indy1, partners); } } @@ -212,11 +208,11 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { * @param d The mutation operators. */ public void setMutators(PropertyMutationMixer d) { - this.m_Mutators = d; + this.mutationMixer = d; } public PropertyMutationMixer getMutators() { - return this.m_Mutators; + return this.mutationMixer; } public String mutatorsTipText() { @@ -229,11 +225,11 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { * @param d The mutation operator. */ public void setUseSelfAdaption(boolean d) { - this.m_UseSelfAdaption = d; + this.useSelfAdaption = d; } public boolean getUseSelfAdaption() { - return this.m_UseSelfAdaption; + return this.useSelfAdaption; } public String useSelfAdaptionTipText() { @@ -249,11 +245,11 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { if (d < 0) { d = 0; } - this.m_LowerLimitChance = d; + this.lowerLimitChance = d; } public double getLowerLimitChance() { - return this.m_LowerLimitChance; + return this.lowerLimitChance; } public String lowerLimitChanceTipText() { @@ -269,11 +265,11 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { if (d < 0) { d = 0; } - this.m_Tau1 = d; + this.tau1 = d; } public double getTau1() { - return this.m_Tau1; + return this.tau1; } public String tau1TipText() { diff --git a/src/eva2/optimization/operator/mutation/MutateESCorrVector.java b/src/eva2/optimization/operator/mutation/MutateESCorrVector.java index 9bfd96b6..18e33687 100644 --- a/src/eva2/optimization/operator/mutation/MutateESCorrVector.java +++ b/src/eva2/optimization/operator/mutation/MutateESCorrVector.java @@ -23,12 +23,12 @@ import java.util.ArrayList; * between successive mutation steps. */ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializable { - protected double m_scalingDev = 0.05; - protected double m_initialVelocity = 0.02; - protected double m_LowerLimitStepSize = 0.0000001; - protected double m_UpperLimitStepSize = 0.5; - protected double m_rotationDev = 15.; - protected boolean m_checkConstraints = true; + protected double scalingDev = 0.05; + protected double initialVelocity = 0.02; + protected double lowerLimitStepSize = 0.0000001; + protected double upperLimitStepSize = 0.5; + protected double rotationDev = 15.; + protected boolean checkConstraints = true; public static final String vectorKey = "MutateESCorrVectorVector"; public static final boolean TRACE = false; @@ -51,10 +51,10 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab } public MutateESCorrVector(MutateESCorrVector mutator) { - this.m_scalingDev = mutator.m_scalingDev; - this.m_initialVelocity = mutator.m_initialVelocity; - this.m_LowerLimitStepSize = mutator.m_LowerLimitStepSize; - this.m_rotationDev = mutator.m_rotationDev; + this.scalingDev = mutator.scalingDev; + this.initialVelocity = mutator.initialVelocity; + this.lowerLimitStepSize = mutator.lowerLimitStepSize; + this.rotationDev = mutator.rotationDev; } /** @@ -77,13 +77,13 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab public boolean equals(Object mutator) { if (mutator instanceof MutateESCorrVector) { MutateESCorrVector mut = (MutateESCorrVector) mutator; - if (this.m_scalingDev != mut.m_scalingDev) { + if (this.scalingDev != mut.scalingDev) { return false; } - if (this.m_initialVelocity != m_initialVelocity) { + if (this.initialVelocity != initialVelocity) { return false; } - if (this.m_LowerLimitStepSize != mut.m_LowerLimitStepSize) { + if (this.lowerLimitStepSize != mut.lowerLimitStepSize) { return false; } return true; @@ -100,7 +100,7 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab */ @Override public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) { - double[] initVelocity = calcInitialVel(m_initialVelocity, ((InterfaceESIndividual) individual).getDoubleRange()); + double[] initVelocity = calcInitialVel(initialVelocity, ((InterfaceESIndividual) individual).getDoubleRange()); individual.putData(vectorKey, initVelocity); } @@ -139,22 +139,22 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab double[] vel = (double[]) individual.getData(vectorKey); // mutate the velocity vector and write it back - if ((m_scalingDev > 0) || (m_rotationDev > 0)) { + if ((scalingDev > 0) || (rotationDev > 0)) { // for (int i = 0; i < vel.length; i++) { // vel[i] += ((range[i][1] -range[i][0])/2)*RNG.gaussianDouble(this.mutationStepSize); // } - double rotateRad = m_rotationDev * (Math.PI / 360.) * RNG.gaussianDouble(1.); + double rotateRad = rotationDev * (Math.PI / 360.) * RNG.gaussianDouble(1.); // rotate with a gaussian distribution of deviation rotationDeg Mathematics.rotateAllAxes(vel, rotateRad, false); // rotate - double rScale = Math.exp(RNG.gaussianDouble(m_scalingDev)); + double rScale = Math.exp(RNG.gaussianDouble(scalingDev)); - if ((m_LowerLimitStepSize > 0) || (m_UpperLimitStepSize > 0)) { + if ((lowerLimitStepSize > 0) || (upperLimitStepSize > 0)) { double stepLen = Mathematics.norm(vel); - if (m_LowerLimitStepSize > 0) { - rScale = Math.max(rScale, m_LowerLimitStepSize / stepLen); + if (lowerLimitStepSize > 0) { + rScale = Math.max(rScale, lowerLimitStepSize / stepLen); } - if (m_UpperLimitStepSize > 0) { - rScale = Math.min(rScale, m_UpperLimitStepSize / stepLen); + if (upperLimitStepSize > 0) { + rScale = Math.min(rScale, upperLimitStepSize / stepLen); } } @@ -173,7 +173,7 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab Mathematics.vvAdd(genes, vel, genes); // check the range - if (m_checkConstraints) { + if (checkConstraints) { Mathematics.projectToRange(genes, range); } @@ -195,11 +195,11 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab public void crossoverOnStrategyParameters(AbstractEAIndividual indy1, Population partners) { ArrayList tmpList = new ArrayList(); if (indy1.getMutationOperator() instanceof MutateESCorrVector) { - tmpList.add(new Double(((MutateESCorrVector) indy1.getMutationOperator()).m_scalingDev)); + tmpList.add(new Double(((MutateESCorrVector) indy1.getMutationOperator()).scalingDev)); } for (int i = 0; i < partners.size(); i++) { if (((AbstractEAIndividual) partners.get(i)).getMutationOperator() instanceof MutateESCorrVector) { - tmpList.add(new Double(((MutateESCorrVector) ((AbstractEAIndividual) partners.get(i)).getMutationOperator()).m_scalingDev)); + tmpList.add(new Double(((MutateESCorrVector) ((AbstractEAIndividual) partners.get(i)).getMutationOperator()).scalingDev)); } } double[] list = new double[tmpList.size()]; @@ -210,7 +210,7 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab return; } // discreete mutation for step size - this.m_scalingDev = list[RNG.randomInt(0, list.length - 1)]; + this.scalingDev = list[RNG.randomInt(0, list.length - 1)]; } /** @@ -252,11 +252,11 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab * @param d The mutation operator. */ public void setScalingDev(double d) { - this.m_scalingDev = d; + this.scalingDev = d; } public double getScalingDev() { - return this.m_scalingDev; + return this.scalingDev; } public String scalingDevTipText() { @@ -272,11 +272,11 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab if (d < 0) { d = 0; } - this.m_LowerLimitStepSize = d; + this.lowerLimitStepSize = d; } public double getLowerLimitStepSize() { - return this.m_LowerLimitStepSize; + return this.lowerLimitStepSize; } public String lowerLimitStepSizeTipText() { @@ -284,11 +284,11 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab } public double getRotationDev() { - return m_rotationDev; + return rotationDev; } public void setRotationDev(double rotationDeg) { - this.m_rotationDev = rotationDeg; + this.rotationDev = rotationDeg; } public String rotationDevTipText() { @@ -296,19 +296,19 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab } public double getInitialVelocity() { - return m_initialVelocity; + return initialVelocity; } public void setInitialVelocity(double velocity) { - m_initialVelocity = velocity; + initialVelocity = velocity; } public double getUpperLimitStepSize() { - return m_UpperLimitStepSize; + return upperLimitStepSize; } public void setUpperLimitStepSize(double upperLimitStepSize) { - m_UpperLimitStepSize = upperLimitStepSize; + this.upperLimitStepSize = upperLimitStepSize; } public String upperLimitStepSizeTipText() { diff --git a/src/eva2/optimization/operator/mutation/MutateESCorrolated.java b/src/eva2/optimization/operator/mutation/MutateESCorrolated.java index 5b2edcde..a95cb184 100644 --- a/src/eva2/optimization/operator/mutation/MutateESCorrolated.java +++ b/src/eva2/optimization/operator/mutation/MutateESCorrolated.java @@ -132,70 +132,6 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab } } - /** - * This method will mutate a given AbstractEAIndividual. If the individual - * doesn't implement InterfaceGAIndividual nothing happens. - * - * @param individual The individual that is to be mutated - */ -// public void mutate(AbstractEAIndividual individual) { -// if (individual instanceof InterfaceESIndividual) { -// double[] x = ((InterfaceESIndividual)individual).getDGenotype(); -// double[] xCopy = ((InterfaceESIndividual)individual).getDGenotype(); -// double[][] range = ((InterfaceESIndividual)individual).getDoubleRange(); -// double tmpR = RNG.gaussianDouble(1); -// if (this.sigmas == null) { -// // init the Sigmas -// this.sigmas = new double[x.length]; -// for (int i = 0; i < this.sigmas.length; i++) this.sigmas[i] = this.mutationStepSize; -// } -// -// //Mutate Sigmas -// for (int i = 0; i < x.length; i++) { -// this.sigmas[i] = this.sigmas[i] * Math.exp(this.tau1 * tmpR + this.tau2 * RNG.gaussianDouble(1)); -// if (this.sigmas[i] < this.lowerLimitStepSize) this.sigmas[i] = this.lowerLimitStepSize; -// } -// -//// if (this.alphas == null) { -//// // init the Alphas -//// this.alphas = new double[(x.length*(x.length-1))/2]; -//// for (int i = 0; i < this.alphas.length; i++) this.alphas[i] = 0.0; -//// } -// -//// //Mutate Alphas -//// for (int i = 0; i < this.alphas.length; i++) { -//// this.alphas[i] = this.alphas[i] + RNG.gaussianDouble(0.01); -//// if (this.alphas[i] < -m_PI/2) this.alphas[i] = -m_PI/2; -//// if (this.alphas[i] > m_PI/2) this.alphas[i] = m_PI/2; -//// } -// -// //Generate mutationvector in unitspace modified by sigmas -// for (int i = 0; i < x.length; i++) { -// xCopy[i] = RNG.gaussianDouble(this.sigmas[i]); -// } -// -// //modify genotype -// for (int i = 0; i < x.length; i++) { -// x[i] += ((range[i][1] -range[i][0])/2)*xCopy[i]; -// if (range[i][0] > x[i]) x[i] = range[i][0]; -// if (range[i][1] < x[i]) x[i] = range[i][1]; -// } -// -// ((InterfaceESIndividual)individual).setDGenotype(x); -// -// //turn mutationvector with alphas -//// for (int i = 0; i < x.length-1; i++) { -//// for (int j = i+1; j < x.length; j++) { -//// double alpha=this.getAlpha(i,j, x.length); -//// double xX=java.lang.Math.cos(alpha)*xCopy[i]-java.lang.Math.sin(alpha)*xCopy[j]; -//// double xY=java.lang.Math.sin(alpha)*xCopy[i]+java.lang.Math.cos(alpha)*xCopy[j]; -//// xCopy[i]=xX; -//// xCopy[j]=xY; -//// } -//// } -// -// } -// } @Override public void mutate(AbstractEAIndividual individual) { if (individual instanceof InterfaceESIndividual) { diff --git a/src/eva2/optimization/operator/mutation/MutateESCovarianceMatrixAdaption.java b/src/eva2/optimization/operator/mutation/MutateESCovarianceMatrixAdaption.java index 6c057459..7e9aa319 100644 --- a/src/eva2/optimization/operator/mutation/MutateESCovarianceMatrixAdaption.java +++ b/src/eva2/optimization/operator/mutation/MutateESCovarianceMatrixAdaption.java @@ -19,39 +19,39 @@ import eva2.tools.math.RNG; public class MutateESCovarianceMatrixAdaption implements InterfaceMutation, java.io.Serializable { - protected int m_D; - protected double[] m_Z; - protected double m_SigmaGlobal = 1; - protected double m_InitSigmaScalar = -1; - protected double m_c; + protected int D; + protected double[] Z; + protected double sigmaGlobal = 1; + protected double initSigmaScalar = -1; + protected double c; protected double cu; protected double cov; protected double Beta; protected double[] s_N; - protected double[] m_PathS; + protected double[] pathS; protected double[] Bz; protected double xi_dach; - protected Matrix m_C; + protected Matrix C; protected Matrix B; - protected boolean m_CheckConstraints = false; - protected int m_constraintMaxTries = 50; - protected int m_Counter; - protected int m_frequency = 1; - protected double[] m_Eigenvalues; + protected boolean checkConstraints = false; + protected int constraintMaxTries = 50; + protected int counter; + protected int frequency = 1; + protected double[] eigenValues; public MutateESCovarianceMatrixAdaption() { } public MutateESCovarianceMatrixAdaption(MutateESCovarianceMatrixAdaption mutator) { - this.m_Counter = mutator.m_Counter; - this.m_frequency = mutator.m_frequency; - this.m_InitSigmaScalar = mutator.m_InitSigmaScalar; - this.m_constraintMaxTries = mutator.m_constraintMaxTries; - this.m_CheckConstraints = mutator.m_CheckConstraints; - this.m_D = mutator.m_D; - this.m_SigmaGlobal = mutator.m_SigmaGlobal; - this.m_c = mutator.m_c; + this.counter = mutator.counter; + this.frequency = mutator.frequency; + this.initSigmaScalar = mutator.initSigmaScalar; + this.constraintMaxTries = mutator.constraintMaxTries; + this.checkConstraints = mutator.checkConstraints; + this.D = mutator.D; + this.sigmaGlobal = mutator.sigmaGlobal; + this.c = mutator.c; this.cu = mutator.cu; this.cov = mutator.cov; this.Beta = mutator.Beta; @@ -59,23 +59,23 @@ public class MutateESCovarianceMatrixAdaption implements InterfaceMutation, java if (mutator.s_N != null) { this.s_N = (double[]) mutator.s_N.clone(); } - if (mutator.m_PathS != null) { - this.m_PathS = (double[]) mutator.m_PathS.clone(); + if (mutator.pathS != null) { + this.pathS = (double[]) mutator.pathS.clone(); } if (mutator.Bz != null) { this.Bz = (double[]) mutator.Bz.clone(); } - if (mutator.m_C != null) { - this.m_C = (Matrix) mutator.m_C.clone(); + if (mutator.C != null) { + this.C = (Matrix) mutator.C.clone(); } if (mutator.B != null) { this.B = (Matrix) mutator.B.clone(); } - if (mutator.m_Z != null) { - this.m_Z = (double[]) mutator.m_Z.clone(); + if (mutator.Z != null) { + this.Z = (double[]) mutator.Z.clone(); } - if (mutator.m_Eigenvalues != null) { - this.m_Eigenvalues = (double[]) mutator.m_Eigenvalues.clone(); + if (mutator.eigenValues != null) { + this.eigenValues = (double[]) mutator.eigenValues.clone(); } } @@ -113,11 +113,11 @@ public class MutateESCovarianceMatrixAdaption implements InterfaceMutation, java MutateESCovarianceMatrixAdaption mut = (MutateESCovarianceMatrixAdaption) mutator; // i assume if the C Matrix is equal then the mutation operators are equal try { - if (this.m_C == mut.m_C) { + if (this.C == mut.C) { return true; } - double[][] c1 = this.m_C.getArray(); - double[][] c2 = mut.m_C.getArray(); + double[][] c1 = this.C.getArray(); + double[][] c2 = mut.C.getArray(); if (c1 == c2) { return true; } @@ -151,32 +151,32 @@ public class MutateESCovarianceMatrixAdaption implements InterfaceMutation, java double[] x = ((InterfaceESIndividual) individual).getDGenotype(); double[][] ranges = ((InterfaceESIndividual) individual).getDoubleRange(); - this.m_Counter = this.m_frequency; - if (m_InitSigmaScalar > 0) { - this.m_SigmaGlobal = this.m_InitSigmaScalar; + this.counter = this.frequency; + if (initSigmaScalar > 0) { + this.sigmaGlobal = this.initSigmaScalar; } else { double avgRange = Mathematics.getAvgRange(ranges); - this.m_SigmaGlobal = 0.25 * avgRange; + this.sigmaGlobal = 0.25 * avgRange; } - System.out.println("Init sigma: " + m_SigmaGlobal); - this.m_D = x.length; - this.m_C = Matrix.identity(this.m_D, this.m_D); - EigenvalueDecomposition helper = new EigenvalueDecomposition(this.m_C); + System.out.println("Init sigma: " + sigmaGlobal); + this.D = x.length; + this.C = Matrix.identity(this.D, this.D); + EigenvalueDecomposition helper = new EigenvalueDecomposition(this.C); this.B = helper.getV(); - this.m_c = Math.sqrt(1.0 / (double) this.m_D); - this.cu = Math.sqrt((2.0 - this.m_c) / this.m_c); - this.Beta = this.m_c; - this.cov = 2.0 / ((double) this.m_D * (double) this.m_D); - this.m_Z = new double[this.m_D]; - this.s_N = new double[this.m_D]; - this.Bz = new double[this.m_D]; - this.m_PathS = new double[this.m_D]; - for (int i = 0; i < this.m_D; i++) { + this.c = Math.sqrt(1.0 / (double) this.D); + this.cu = Math.sqrt((2.0 - this.c) / this.c); + this.Beta = this.c; + this.cov = 2.0 / ((double) this.D * (double) this.D); + this.Z = new double[this.D]; + this.s_N = new double[this.D]; + this.Bz = new double[this.D]; + this.pathS = new double[this.D]; + for (int i = 0; i < this.D; i++) { this.s_N[i] = 0; this.Bz[i] = 0; - this.m_PathS[i] = 0; + this.pathS[i] = 0; } - this.xi_dach = Math.sqrt(this.m_D - 0.5); + this.xi_dach = Math.sqrt(this.D - 0.5); evaluateNewObjectX(x, ranges); } @@ -223,36 +223,36 @@ public class MutateESCovarianceMatrixAdaption implements InterfaceMutation, java double Cij; double Bz_d; double pathLen = 0.0; - for (int i = 0; i < this.m_D; i++) { - this.s_N[i] = (1.0 - this.m_c) * this.s_N[i] + this.m_c * this.cu * this.Bz[i]; + for (int i = 0; i < this.D; i++) { + this.s_N[i] = (1.0 - this.c) * this.s_N[i] + this.c * this.cu * this.Bz[i]; } // System.out.println("C bef:\n" + c.toString()); // ADAPT COVARIANCE - for (int i = 0; i < this.m_D; i++) { - for (int j = i; j < this.m_D; j++) { - Cij = (1.0 - this.cov) * this.m_C.get(i, j) + this.cov * this.s_N[i] * this.s_N[j]; - this.m_C.set(i, j, Cij); - this.m_C.set(j, i, Cij); + for (int i = 0; i < this.D; i++) { + for (int j = i; j < this.D; j++) { + Cij = (1.0 - this.cov) * this.C.get(i, j) + this.cov * this.s_N[i] * this.s_N[j]; + this.C.set(i, j, Cij); + this.C.set(j, i, Cij); } } // System.out.println("C aft:\n" + c.toString()); // ADAPT GLOBAL STEPSIZE - for (int i = 0; i < this.m_D; i++) { + for (int i = 0; i < this.D; i++) { Bz_d = 0.0; - for (int j = 0; j < this.m_D; j++) { - Bz_d += this.B.get(i, j) * this.m_Z[j]; + for (int j = 0; j < this.D; j++) { + Bz_d += this.B.get(i, j) * this.Z[j]; } - this.m_PathS[i] = (1.0 - this.m_c) * this.m_PathS[i] + this.m_c * this.cu * Bz_d; - pathLen += this.m_PathS[i] * this.m_PathS[i]; + this.pathS[i] = (1.0 - this.c) * this.pathS[i] + this.c * this.cu * Bz_d; + pathLen += this.pathS[i] * this.pathS[i]; } - this.m_SigmaGlobal *= Math.exp(this.Beta * this.m_c * (Math.sqrt(pathLen) - this.xi_dach)); + this.sigmaGlobal *= Math.exp(this.Beta * this.c * (Math.sqrt(pathLen) - this.xi_dach)); } protected void evaluateNewObjectX(double[] x, double[][] range) { // if (Double.isNaN((x[0]))) System.out.println("treffer in cma "+ x[0]); // if (Double.isNaN((c.get(0,0)))) System.out.println("treffer in cma"); // for (int i=0;irange[i][1])) constraint = false; // } @@ -283,42 +283,42 @@ public class MutateESCovarianceMatrixAdaption implements InterfaceMutation, java // } // for (int i = 0; i < N; i++) x[i] = tmpD[i]; // conservation of mutation direction: - //double[] oldZ = (double[]) this.m_Z.clone(); + //double[] oldZ = (double[]) this.Z.clone(); double[] oldX = (double[]) x.clone(); - for (int i = 0; i < this.m_D; i++) { - this.m_Z[i] = RNG.gaussianDouble(1.0); + for (int i = 0; i < this.D; i++) { + this.Z[i] = RNG.gaussianDouble(1.0); } - this.m_C = (this.m_C.plus(this.m_C.transpose()).times(0.5)); // MAKE C SYMMETRIC - this.m_Counter++; - if (this.m_Counter >= this.m_frequency) { + this.C = (this.C.plus(this.C.transpose()).times(0.5)); // MAKE C SYMMETRIC + this.counter++; + if (this.counter >= this.frequency) { EigenvalueDecomposition helper; - this.m_Counter = 0; - helper = new EigenvalueDecomposition(this.m_C); + this.counter = 0; + helper = new EigenvalueDecomposition(this.C); this.B = helper.getV(); - this.m_Eigenvalues = helper.getRealEigenvalues(); + this.eigenValues = helper.getRealEigenvalues(); } boolean isNewPosFeasible = false; int counter = 0; - while (!isNewPosFeasible && counter < this.m_constraintMaxTries) { - for (int i = 0; i < this.m_D; i++) { + while (!isNewPosFeasible && counter < this.constraintMaxTries) { + for (int i = 0; i < this.D; i++) { this.Bz[i] = 0; - for (int j = 0; j < this.m_D; j++) { - this.Bz[i] += Math.sqrt(Math.abs(this.m_Eigenvalues[j])) * this.B.get(i, j) * this.m_Z[j]; + for (int j = 0; j < this.D; j++) { + this.Bz[i] += Math.sqrt(Math.abs(this.eigenValues[j])) * this.B.get(i, j) * this.Z[j]; } - x[i] += this.m_SigmaGlobal * this.Bz[i]; // here is the new value + x[i] += this.sigmaGlobal * this.Bz[i]; // here is the new value } isNewPosFeasible = true; - if (this.m_CheckConstraints == true) { - for (int i = 0; i < m_D; i++) { + if (this.checkConstraints == true) { + for (int i = 0; i < D; i++) { if (x[i] < range[i][0] || x[i] > range[i][1]) { // undo the step and try new Z - for (int j = 0; j < this.m_D; j++) { - x[j] = oldX[j] - this.m_SigmaGlobal * this.Bz[j]; + for (int j = 0; j < this.D; j++) { + x[j] = oldX[j] - this.sigmaGlobal * this.Bz[j]; } - this.m_SigmaGlobal *= 0.5; + this.sigmaGlobal *= 0.5; isNewPosFeasible = false; counter++; break; @@ -331,7 +331,7 @@ public class MutateESCovarianceMatrixAdaption implements InterfaceMutation, java // if (counter > 15) System.out.println(BeanInspector.toString(x)); // else System.out.println(); } - if (this.m_CheckConstraints && !isNewPosFeasible) { // use force + if (this.checkConstraints && !isNewPosFeasible) { // use force Mathematics.projectToRange(x, range); // System.err.println("PROJECTING BY FORCE"); } @@ -375,11 +375,11 @@ public class MutateESCovarianceMatrixAdaption implements InterfaceMutation, java * @param bit The new representation for the inner constants. */ public void setCheckConstraints(boolean bit) { - this.m_CheckConstraints = bit; + this.checkConstraints = bit; } public boolean getCheckConstraints() { - return this.m_CheckConstraints; + return this.checkConstraints; } public String checkConstraintsTipText() { @@ -392,11 +392,11 @@ public class MutateESCovarianceMatrixAdaption implements InterfaceMutation, java * @param d The initial sigma value. */ public void setInitSigmaScalar(double d) { - this.m_InitSigmaScalar = d; + this.initSigmaScalar = d; } public double getInitSigmaScalar() { - return this.m_InitSigmaScalar; + return this.initSigmaScalar; } public String initSigmaScalarTipText() { diff --git a/src/eva2/optimization/operator/mutation/MutateESCovarianceMatrixAdaptionPlus.java b/src/eva2/optimization/operator/mutation/MutateESCovarianceMatrixAdaptionPlus.java index c631c620..0a79dacd 100644 --- a/src/eva2/optimization/operator/mutation/MutateESCovarianceMatrixAdaptionPlus.java +++ b/src/eva2/optimization/operator/mutation/MutateESCovarianceMatrixAdaptionPlus.java @@ -9,12 +9,12 @@ import eva2.tools.math.Jama.Matrix; public class MutateESCovarianceMatrixAdaptionPlus extends MutateESCovarianceMatrixAdaption implements InterfaceMutation, InterfaceAdaptOperatorGenerational { - protected double m_psuccess; - protected double m_cp; - protected double m_psuccesstarget = 0.44; - protected double m_stepd; - protected double m_pthresh; - protected int m_lambda = 1; + protected double psuccess; + protected double cp; + protected double psuccesstarget = 0.44; + protected double stepd; + protected double pthresh; + protected int lambda = 1; public MutateESCovarianceMatrixAdaptionPlus() { super(); @@ -23,12 +23,12 @@ public class MutateESCovarianceMatrixAdaptionPlus extends public MutateESCovarianceMatrixAdaptionPlus( MutateESCovarianceMatrixAdaptionPlus mutator) { super(mutator); - m_psuccess = mutator.m_psuccess; - m_cp = mutator.m_cp; - m_psuccesstarget = mutator.m_psuccesstarget; - m_lambda = mutator.m_lambda; - m_pthresh = mutator.m_pthresh; - m_stepd = mutator.m_stepd; + psuccess = mutator.psuccess; + cp = mutator.cp; + psuccesstarget = mutator.psuccesstarget; + lambda = mutator.lambda; + pthresh = mutator.pthresh; + stepd = mutator.stepd; } /** @@ -55,14 +55,14 @@ public class MutateESCovarianceMatrixAdaptionPlus extends return; } super.init(individual, opt); - m_psuccesstarget = 1.0 / (5 + Math.sqrt(m_lambda) / 2); - m_psuccess = m_psuccesstarget; - m_stepd = 1.0 + m_D / (2.0 * m_lambda); - m_cp = m_psuccesstarget * m_lambda / (2 + m_psuccesstarget * m_lambda); - m_c = 2.0 / (2.0 + m_D); - this.cov = 2.0 / (6.0 + Math.pow(m_D, 2)); // ATTN: differs from the + psuccesstarget = 1.0 / (5 + Math.sqrt(lambda) / 2); + psuccess = psuccesstarget; + stepd = 1.0 + D / (2.0 * lambda); + cp = psuccesstarget * lambda / (2 + psuccesstarget * lambda); + c = 2.0 / (2.0 + D); + this.cov = 2.0 / (6.0 + Math.pow(D, 2)); // ATTN: differs from the // standard CMA-ES - m_pthresh = 0.44; + pthresh = 0.44; } @@ -82,8 +82,8 @@ public class MutateESCovarianceMatrixAdaptionPlus extends */ public void updateCovariance(AbstractEAIndividual child, AbstractEAIndividual parent) { - double[] step = new double[m_D]; - for (int i = 0; i < m_D; i++) { + double[] step = new double[D]; + for (int i = 0; i < D; i++) { step[i] = ((InterfaceESIndividual) parent).getDGenotype()[i] - ((InterfaceESIndividual) child).getDGenotype()[i]; } @@ -91,8 +91,8 @@ public class MutateESCovarianceMatrixAdaptionPlus extends } public void updateCovariance() { - double[] step = new double[m_D]; - for (int i = 0; i < m_D; i++) { + double[] step = new double[D]; + for (int i = 0; i < D; i++) { step[i] = Bz[i]; } updateCovariance(step); @@ -102,23 +102,23 @@ public class MutateESCovarianceMatrixAdaptionPlus extends * @param step */ public void updateCovariance(double[] step) { - for (int i = 0; i < m_D; i++) { - if (m_psuccess < m_pthresh) { - m_PathS[i] = (1.0 - m_c) * m_PathS[i] - + Math.sqrt(m_c * (2.0 - m_c)) * (step[i]) - / m_SigmaGlobal; + for (int i = 0; i < D; i++) { + if (psuccess < pthresh) { + pathS[i] = (1.0 - c) * pathS[i] + + Math.sqrt(c * (2.0 - c)) * (step[i]) + / sigmaGlobal; } else { - m_PathS[i] = (1.0 - m_c) * m_PathS[i]; + pathS[i] = (1.0 - c) * pathS[i]; } } - if (m_psuccess < m_pthresh) { - m_C = m_C.multi((1.0 - cov)); - m_C.plusEquals(Matrix.outer(m_PathS, m_PathS).multi(cov)); + if (psuccess < pthresh) { + C = C.multi((1.0 - cov)); + C.plusEquals(Matrix.outer(pathS, pathS).multi(cov)); } else { - m_C = m_C.multi((1.0 - cov)).plus( - (Matrix.outer(m_PathS, m_PathS).plus( - m_C.multi(m_c * (2.0 - m_c))).multi(cov))); + C = C.multi((1.0 - cov)).plus( + (Matrix.outer(pathS, pathS).plus( + C.multi(c * (2.0 - c))).multi(cov))); } } @@ -127,11 +127,11 @@ public class MutateESCovarianceMatrixAdaptionPlus extends } public int getLambda() { - return m_lambda; + return lambda; } public void setLambda(int mLambda) { - m_lambda = mLambda; + lambda = mLambda; } @Override @@ -203,13 +203,13 @@ public class MutateESCovarianceMatrixAdaptionPlus extends } public double getPSuccess() { - return m_psuccess; + return psuccess; } public void updateStepSize(double psuccess) { - this.m_psuccess = (1 - m_cp) * m_psuccess + m_cp * psuccess; - m_SigmaGlobal *= Math.exp(1 / m_stepd * (m_psuccess - m_psuccesstarget) - / (1 - m_psuccesstarget)); + this.psuccess = (1 - cp) * this.psuccess + cp * psuccess; + sigmaGlobal *= Math.exp(1 / stepd * (this.psuccess - psuccesstarget) + / (1 - psuccesstarget)); } @Override diff --git a/src/eva2/optimization/operator/mutation/MutateESMainVectorAdaption.java b/src/eva2/optimization/operator/mutation/MutateESMainVectorAdaption.java index d7f49899..107dfd26 100644 --- a/src/eva2/optimization/operator/mutation/MutateESMainVectorAdaption.java +++ b/src/eva2/optimization/operator/mutation/MutateESMainVectorAdaption.java @@ -205,10 +205,10 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se // boolean constraint = false; // int counter = 0; // while (constraint == false) { -// for (int i = 0; i < x.length; i++) x[i] = x[i] + m_SigmaScalar * (m_Z[i] + Z1 * w_v * m_main_v[i]); +// for (int i = 0; i < x.length; i++) x[i] = x[i] + m_SigmaScalar * (Z[i] + Z1 * w_v * m_main_v[i]); // constraint = true; // if (counter++ > 30) break; -// if (m_CheckConstraints == true) { +// if (checkConstraints == true) { // for (int i = 0; i < x.length; i++) { // if (x[i] < range[i][0]) x[i] = range[i][0]; // if (x[i] > range[i][1]) x[i] = range[i][1]; diff --git a/src/eva2/optimization/operator/mutation/MutateESPathLengthAdaption.java b/src/eva2/optimization/operator/mutation/MutateESPathLengthAdaption.java index 6448f031..36b36af2 100644 --- a/src/eva2/optimization/operator/mutation/MutateESPathLengthAdaption.java +++ b/src/eva2/optimization/operator/mutation/MutateESPathLengthAdaption.java @@ -109,7 +109,7 @@ public class MutateESPathLengthAdaption implements InterfaceMutation, java.io.Se double[] x = ((InterfaceESIndividual) individual).getDGenotype(); double[][] ranges = ((InterfaceESIndividual) individual).getDoubleRange(); this.m_dim = x.length; -// if (this.m_UsePath) this.m_c = Math.sqrt(1.0 / (double) this.m_dim); +// if (this.m_UsePath) this.c = Math.sqrt(1.0 / (double) this.m_dim); this.m_randZ = new double[this.m_dim]; this.m_Path = new double[this.m_dim]; diff --git a/src/eva2/optimization/operator/mutation/MutateESRankMuCMA.java b/src/eva2/optimization/operator/mutation/MutateESRankMuCMA.java index 82ee5601..e91c919f 100644 --- a/src/eva2/optimization/operator/mutation/MutateESRankMuCMA.java +++ b/src/eva2/optimization/operator/mutation/MutateESRankMuCMA.java @@ -511,7 +511,7 @@ public class MutateESRankMuCMA implements InterfaceAdaptOperatorGenerational, In params.mC = (params.mC.plus(params.mC.transpose()).times(0.5)); // MAKE C SYMMETRIC EigenvalueDecomposition helper; -// this.m_Counter = 0; +// this.counter = 0; helper = new EigenvalueDecomposition(params.mC); params.mB = helper.getV(); // Return the eigenvector matrix params.eigenvalues = helper.getRealEigenvalues(); diff --git a/src/eva2/optimization/operator/mutation/MutateGIInsertDelete.java b/src/eva2/optimization/operator/mutation/MutateGIInsertDelete.java index aae43188..d237b63e 100644 --- a/src/eva2/optimization/operator/mutation/MutateGIInsertDelete.java +++ b/src/eva2/optimization/operator/mutation/MutateGIInsertDelete.java @@ -15,14 +15,14 @@ import eva2.tools.math.RNG; */ public class MutateGIInsertDelete implements InterfaceMutation, java.io.Serializable { - int m_MaxLengthOfInsDel = 2; + int maxLengthOfInsDel = 2; public MutateGIInsertDelete() { } public MutateGIInsertDelete(MutateGIInsertDelete mutator) { - this.m_MaxLengthOfInsDel = mutator.m_MaxLengthOfInsDel; + this.maxLengthOfInsDel = mutator.maxLengthOfInsDel; } /** @@ -45,7 +45,7 @@ public class MutateGIInsertDelete implements InterfaceMutation, java.io.Serializ public boolean equals(Object mutator) { if (mutator instanceof MutateGIInsertDelete) { MutateGIInsertDelete mut = (MutateGIInsertDelete) mutator; - if (this.m_MaxLengthOfInsDel != mut.m_MaxLengthOfInsDel) { + if (this.maxLengthOfInsDel != mut.maxLengthOfInsDel) { return false; } return true; @@ -92,7 +92,7 @@ public class MutateGIInsertDelete implements InterfaceMutation, java.io.Serializ int[][] newRange; int length, position; //this.pintInt("Before ", x); - length = RNG.randomInt(1, this.m_MaxLengthOfInsDel); + length = RNG.randomInt(1, this.maxLengthOfInsDel); boolean insert = RNG.flipCoin(0.5); if ((!insert) && (length >= x.length - 1)) { insert = true; @@ -184,11 +184,11 @@ public class MutateGIInsertDelete implements InterfaceMutation, java.io.Serializ * @param n The max length of invert */ public void setMaxLengthOfInsDel(int n) { - this.m_MaxLengthOfInsDel = n; + this.maxLengthOfInsDel = n; } public int getMaxLengthOfInsDel() { - return this.m_MaxLengthOfInsDel; + return this.maxLengthOfInsDel; } public String maxLengthOfInsDelTipText() { diff --git a/src/eva2/optimization/operator/mutation/MutateGIInvert.java b/src/eva2/optimization/operator/mutation/MutateGIInvert.java index 7676fd39..c5059631 100644 --- a/src/eva2/optimization/operator/mutation/MutateGIInvert.java +++ b/src/eva2/optimization/operator/mutation/MutateGIInvert.java @@ -15,14 +15,14 @@ import eva2.tools.math.RNG; */ public class MutateGIInvert implements InterfaceMutation, java.io.Serializable { - int m_MaxLengthOfInvert = 2; + int maxLengthOfInvert = 2; public MutateGIInvert() { } public MutateGIInvert(MutateGIInvert mutator) { - this.m_MaxLengthOfInvert = mutator.m_MaxLengthOfInvert; + this.maxLengthOfInvert = mutator.maxLengthOfInvert; } /** @@ -45,7 +45,7 @@ public class MutateGIInvert implements InterfaceMutation, java.io.Serializable { public boolean equals(Object mutator) { if (mutator instanceof MutateGIInvert) { MutateGIInvert mut = (MutateGIInvert) mutator; - if (this.m_MaxLengthOfInvert != mut.m_MaxLengthOfInvert) { + if (this.maxLengthOfInvert != mut.maxLengthOfInvert) { return false; } return true; @@ -77,7 +77,7 @@ public class MutateGIInvert implements InterfaceMutation, java.io.Serializable { int[] x = ((InterfaceGIIndividual) individual).getIGenotype(); int range, center, index = 0; //this.pintInt("Before ", x); - range = RNG.randomInt(1, this.m_MaxLengthOfInvert); + range = RNG.randomInt(1, this.maxLengthOfInvert); if (2 * range >= x.length) { return; } @@ -154,11 +154,11 @@ public class MutateGIInvert implements InterfaceMutation, java.io.Serializable { * @param n The max length of invert */ public void setMaxLengthOfInvert(int n) { - this.m_MaxLengthOfInvert = n; + this.maxLengthOfInvert = n; } public int getMaxLengthOfInvert() { - return this.m_MaxLengthOfInvert; + return this.maxLengthOfInvert; } public String maxLengthOfInvertTipText() { diff --git a/src/eva2/optimization/operator/mutation/MutateGINominal.java b/src/eva2/optimization/operator/mutation/MutateGINominal.java index 13bf61e2..9e6748b1 100644 --- a/src/eva2/optimization/operator/mutation/MutateGINominal.java +++ b/src/eva2/optimization/operator/mutation/MutateGINominal.java @@ -15,14 +15,14 @@ import eva2.tools.math.RNG; */ public class MutateGINominal implements InterfaceMutation, java.io.Serializable { - int m_NumberOfMutations = 2; + int numberOfMutations = 2; public MutateGINominal() { } public MutateGINominal(MutateGINominal mutator) { - this.m_NumberOfMutations = mutator.m_NumberOfMutations; + this.numberOfMutations = mutator.numberOfMutations; } /** @@ -45,7 +45,7 @@ public class MutateGINominal implements InterfaceMutation, java.io.Serializable public boolean equals(Object mutator) { if (mutator instanceof MutateGINominal) { MutateGINominal mut = (MutateGINominal) mutator; - if (this.m_NumberOfMutations != mut.m_NumberOfMutations) { + if (this.numberOfMutations != mut.numberOfMutations) { return false; } return true; @@ -77,7 +77,7 @@ public class MutateGINominal implements InterfaceMutation, java.io.Serializable int[] x = ((InterfaceGIIndividual) individual).getIGenotype(); int[][] range = ((InterfaceGIIndividual) individual).getIntRange(); int mutInd = 0; - for (int k = 0; k < this.m_NumberOfMutations; k++) { + for (int k = 0; k < this.numberOfMutations; k++) { try { mutInd = RNG.randomInt(0, x.length - 1); } catch (java.lang.ArithmeticException e) { @@ -140,11 +140,11 @@ public class MutateGINominal implements InterfaceMutation, java.io.Serializable * @param n The number of mutations */ public void setNumberOfMutations(int n) { - this.m_NumberOfMutations = n; + this.numberOfMutations = n; } public int getNumberOfMutations() { - return this.m_NumberOfMutations; + return this.numberOfMutations; } public String numberOfMutationsTipText() { diff --git a/src/eva2/optimization/operator/mutation/MutateGIOrdinal.java b/src/eva2/optimization/operator/mutation/MutateGIOrdinal.java index c09f7dfd..e5a82a4c 100644 --- a/src/eva2/optimization/operator/mutation/MutateGIOrdinal.java +++ b/src/eva2/optimization/operator/mutation/MutateGIOrdinal.java @@ -15,16 +15,16 @@ import eva2.tools.math.RNG; */ public class MutateGIOrdinal implements InterfaceMutation, java.io.Serializable { - double m_StepSize = 0.1; - int m_NumberOfMutations = 2; + double stepSize = 0.1; + int numberOfMutations = 2; public MutateGIOrdinal() { } public MutateGIOrdinal(MutateGIOrdinal mutator) { - this.m_StepSize = mutator.m_StepSize; - this.m_NumberOfMutations = mutator.m_NumberOfMutations; + this.stepSize = mutator.stepSize; + this.numberOfMutations = mutator.numberOfMutations; } /** @@ -47,10 +47,10 @@ public class MutateGIOrdinal implements InterfaceMutation, java.io.Serializable public boolean equals(Object mutator) { if (mutator instanceof MutateGIOrdinal) { MutateGIOrdinal mut = (MutateGIOrdinal) mutator; - if (this.m_StepSize != mut.m_StepSize) { + if (this.stepSize != mut.stepSize) { return false; } - if (this.m_NumberOfMutations != mut.m_NumberOfMutations) { + if (this.numberOfMutations != mut.numberOfMutations) { return false; } return true; @@ -83,9 +83,9 @@ public class MutateGIOrdinal implements InterfaceMutation, java.io.Serializable int[][] range = ((InterfaceGIIndividual) individual).getIntRange(); int mutInd, mut; double mutate; - for (int k = 0; k < this.m_NumberOfMutations; k++) { + for (int k = 0; k < this.numberOfMutations; k++) { mutInd = RNG.randomInt(0, x.length - 1); - mutate = RNG.gaussianDouble(this.m_StepSize); + mutate = RNG.gaussianDouble(this.stepSize); mutate *= (range[mutInd][1] - range[mutInd][1]); mut = (int) Math.round(mutate); if (mut == 0) { @@ -158,11 +158,11 @@ public class MutateGIOrdinal implements InterfaceMutation, java.io.Serializable * @param n The step size */ public void setStepSize(double n) { - this.m_StepSize = n; + this.stepSize = n; } public double getStepSize() { - return this.m_StepSize; + return this.stepSize; } public String stepSizeTipText() { @@ -175,11 +175,11 @@ public class MutateGIOrdinal implements InterfaceMutation, java.io.Serializable * @param n The number of mutations */ public void setNumberOfMutations(int n) { - this.m_NumberOfMutations = n; + this.numberOfMutations = n; } public int getNumberOfMutations() { - return this.m_NumberOfMutations; + return this.numberOfMutations; } public String numberOfMutationsTipText() { diff --git a/src/eva2/optimization/operator/mutation/MutateGITranslocate.java b/src/eva2/optimization/operator/mutation/MutateGITranslocate.java index 3081cda0..e5fc472d 100644 --- a/src/eva2/optimization/operator/mutation/MutateGITranslocate.java +++ b/src/eva2/optimization/operator/mutation/MutateGITranslocate.java @@ -16,8 +16,8 @@ import eva2.tools.math.RNG; */ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializable { - int m_MaxLengthOfTranslocate = 4; - int m_maxTransLocDistance = -1; + int maxLengthOfTranslocate = 4; + int maxTransLocDistance = -1; public MutateGITranslocate() { } @@ -34,7 +34,7 @@ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializa } public MutateGITranslocate(MutateGITranslocate mutator) { - this.m_MaxLengthOfTranslocate = mutator.m_MaxLengthOfTranslocate; + this.maxLengthOfTranslocate = mutator.maxLengthOfTranslocate; } /** @@ -57,7 +57,7 @@ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializa public boolean equals(Object mutator) { if (mutator instanceof MutateGITranslocate) { MutateGITranslocate mut = (MutateGITranslocate) mutator; - if (this.m_MaxLengthOfTranslocate != mut.m_MaxLengthOfTranslocate) { + if (this.maxLengthOfTranslocate != mut.maxLengthOfTranslocate) { return false; } return true; @@ -88,16 +88,16 @@ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializa if (individual instanceof InterfaceGIIndividual) { int[] x = ((InterfaceGIIndividual) individual).getIGenotype(); int from, to, length; - length = RNG.randomInt(1, this.m_MaxLengthOfTranslocate); + length = RNG.randomInt(1, this.maxLengthOfTranslocate); if (x.length < length + 2) { return; } from = RNG.randomInt(0, x.length - 1 - length); - if (m_maxTransLocDistance <= 0) { + if (maxTransLocDistance <= 0) { to = RNG.randomInt(0, x.length - 1 - length); } else { - int minTo = Math.max(0, from - m_maxTransLocDistance); - int maxTo = Math.min(x.length - 1 - length, from + m_maxTransLocDistance); + int minTo = Math.max(0, from - maxTransLocDistance); + int maxTo = Math.min(x.length - 1 - length, from + maxTransLocDistance); // System.out.println("min/max-to: " + minTo + ", " + maxTo); to = RNG.randomInt(minTo, maxTo); // System.out.println("to is " + to); @@ -198,11 +198,11 @@ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializa * @param n The max length of invert */ public void setMaxLengthOfTranslocate(int n) { - this.m_MaxLengthOfTranslocate = n; + this.maxLengthOfTranslocate = n; } public int getMaxLengthOfTranslocate() { - return this.m_MaxLengthOfTranslocate; + return this.maxLengthOfTranslocate; } public String maxLengthOfTranslocateTipText() { @@ -215,11 +215,11 @@ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializa * @param n The max length of invert */ public void setMaxTranslocationDist(int n) { - this.m_maxTransLocDistance = n; + this.maxTransLocDistance = n; } public int getMaxTranslocationDist() { - return this.m_maxTransLocDistance; + return this.maxTransLocDistance; } public String maxTranslocationDistTipText() { diff --git a/src/eva2/optimization/operator/mutation/MutateGPAdaptive.java b/src/eva2/optimization/operator/mutation/MutateGPAdaptive.java index d3e4efe7..a0d725c9 100644 --- a/src/eva2/optimization/operator/mutation/MutateGPAdaptive.java +++ b/src/eva2/optimization/operator/mutation/MutateGPAdaptive.java @@ -16,20 +16,20 @@ import eva2.tools.math.RNG; * To change this template use Options | File Templates. */ public class MutateGPAdaptive implements InterfaceMutation, java.io.Serializable { - protected double m_MutationStep = 1; - protected double m_Tau1 = 0.15; - protected double m_Tau2 = 0.15; - protected double m_LowerLimitStepSize = 0.0000005; + protected double mutationStep = 1; + protected double tau1 = 0.15; + protected double tau2 = 0.15; + protected double lowerLimitStepSize = 0.0000005; public MutateGPAdaptive() { } public MutateGPAdaptive(MutateGPAdaptive mutator) { - this.m_MutationStep = mutator.m_MutationStep; - this.m_Tau1 = mutator.m_Tau1; - this.m_Tau2 = mutator.m_Tau2; - this.m_LowerLimitStepSize = mutator.m_LowerLimitStepSize; + this.mutationStep = mutator.mutationStep; + this.tau1 = mutator.tau1; + this.tau2 = mutator.tau2; + this.lowerLimitStepSize = mutator.lowerLimitStepSize; } /** @@ -52,16 +52,16 @@ public class MutateGPAdaptive implements InterfaceMutation, java.io.Serializable public boolean equals(Object mutator) { if (mutator instanceof MutateGPAdaptive) { MutateGPAdaptive mut = (MutateGPAdaptive) mutator; - if (this.m_MutationStep != mut.m_MutationStep) { + if (this.mutationStep != mut.mutationStep) { return false; } - if (this.m_Tau1 != mut.m_Tau1) { + if (this.tau1 != mut.tau1) { return false; } - if (this.m_Tau2 != mut.m_Tau2) { + if (this.tau2 != mut.tau2) { return false; } - if (this.m_LowerLimitStepSize != mut.m_LowerLimitStepSize) { + if (this.lowerLimitStepSize != mut.lowerLimitStepSize) { return false; } return true; @@ -91,14 +91,14 @@ public class MutateGPAdaptive implements InterfaceMutation, java.io.Serializable public void mutate(AbstractEAIndividual individual) { //System.out.println("Before Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); if (individual instanceof InterfaceGPIndividual) { - this.m_MutationStep *= Math.exp(this.m_Tau1 * RNG.gaussianDouble(1) + this.m_Tau2 * RNG.gaussianDouble(1)); - if (this.m_MutationStep < this.m_LowerLimitStepSize) { - this.m_MutationStep = this.m_LowerLimitStepSize; + this.mutationStep *= Math.exp(this.tau1 * RNG.gaussianDouble(1) + this.tau2 * RNG.gaussianDouble(1)); + if (this.mutationStep < this.lowerLimitStepSize) { + this.mutationStep = this.lowerLimitStepSize; } - if (this.m_MutationStep > 1) { - this.m_MutationStep = 1; + if (this.mutationStep > 1) { + this.mutationStep = 1; } - if (RNG.flipCoin(this.m_MutationStep)) { + if (RNG.flipCoin(this.mutationStep)) { ((IndividualInterface) individual).defaultMutate(); } } @@ -157,13 +157,13 @@ public class MutateGPAdaptive implements InterfaceMutation, java.io.Serializable */ public void setMutationStep(double d) { if (d < 0) { - d = this.m_LowerLimitStepSize; + d = this.lowerLimitStepSize; } - this.m_MutationStep = d; + this.mutationStep = d; } public double getMutationStepSize() { - return this.m_MutationStep; + return this.mutationStep; } public String mutationStepSizeTipText() { @@ -179,11 +179,11 @@ public class MutateGPAdaptive implements InterfaceMutation, java.io.Serializable if (d < 0) { d = 0; } - this.m_LowerLimitStepSize = d; + this.lowerLimitStepSize = d; } public double getLowerLimitStepSize() { - return this.m_LowerLimitStepSize; + return this.lowerLimitStepSize; } public String lowerLimitStepSizeTipText() { @@ -199,11 +199,11 @@ public class MutateGPAdaptive implements InterfaceMutation, java.io.Serializable if (d < 0) { d = 0; } - this.m_Tau1 = d; + this.tau1 = d; } public double getTau1() { - return this.m_Tau1; + return this.tau1; } public String tau1TipText() { @@ -219,11 +219,11 @@ public class MutateGPAdaptive implements InterfaceMutation, java.io.Serializable if (d < 0) { d = 0; } - this.m_Tau2 = d; + this.tau2 = d; } public double getTau2() { - return this.m_Tau2; + return this.tau2; } public String tau2TipText() { diff --git a/src/eva2/optimization/operator/mutation/PropertyMutationMixer.java b/src/eva2/optimization/operator/mutation/PropertyMutationMixer.java index 9ed3ad58..959bc292 100644 --- a/src/eva2/optimization/operator/mutation/PropertyMutationMixer.java +++ b/src/eva2/optimization/operator/mutation/PropertyMutationMixer.java @@ -9,42 +9,42 @@ package eva2.optimization.operator.mutation; */ public class PropertyMutationMixer implements java.io.Serializable { - public InterfaceMutation[] m_AvailableTargets; - public InterfaceMutation[] m_SelectedTargets; - public double[] m_Weights; - public String m_DescriptiveString = "No Description given."; - public String m_WeightsLabel = "-"; - public boolean m_NormalizationEnabled = true; + public InterfaceMutation[] availableTargets; + public InterfaceMutation[] selectedTargets; + public double[] weights; + public String descriptiveString = "No Description given."; + public String weightsLabel = "-"; + public boolean normalizationEnabled = true; public PropertyMutationMixer(InterfaceMutation[] d, boolean selectAllOrNone) { - this.m_Weights = new double[d.length]; + this.weights = new double[d.length]; for (int i = 0; i < d.length; i++) { - this.m_Weights[i] = 1 / ((double) d.length); + this.weights[i] = 1 / ((double) d.length); } - this.m_AvailableTargets = d; + this.availableTargets = d; if (selectAllOrNone) { - this.m_SelectedTargets = d.clone(); + this.selectedTargets = d.clone(); } else { - this.m_SelectedTargets = null; + this.selectedTargets = null; } } public PropertyMutationMixer(PropertyMutationMixer d) { - this.m_DescriptiveString = d.m_DescriptiveString; - this.m_WeightsLabel = d.m_WeightsLabel; - this.m_NormalizationEnabled = d.m_NormalizationEnabled; - this.m_AvailableTargets = new InterfaceMutation[d.m_AvailableTargets.length]; - for (int i = 0; i < this.m_AvailableTargets.length; i++) { - //this.m_AvailableTargets[i] = (InterfaceMutation)d.m_AvailableTargets[i].clone(); - this.m_AvailableTargets[i] = d.m_AvailableTargets[i]; + this.descriptiveString = d.descriptiveString; + this.weightsLabel = d.weightsLabel; + this.normalizationEnabled = d.normalizationEnabled; + this.availableTargets = new InterfaceMutation[d.availableTargets.length]; + for (int i = 0; i < this.availableTargets.length; i++) { + //this.availableTargets[i] = (InterfaceMutation)d.availableTargets[i].clone(); + this.availableTargets[i] = d.availableTargets[i]; } - this.m_SelectedTargets = new InterfaceMutation[d.m_SelectedTargets.length]; - for (int i = 0; i < this.m_SelectedTargets.length; i++) { - this.m_SelectedTargets[i] = (InterfaceMutation) d.m_SelectedTargets[i].clone(); + this.selectedTargets = new InterfaceMutation[d.selectedTargets.length]; + for (int i = 0; i < this.selectedTargets.length; i++) { + this.selectedTargets[i] = (InterfaceMutation) d.selectedTargets[i].clone(); } - if (d.m_Weights != null) { - this.m_Weights = new double[d.m_Weights.length]; - System.arraycopy(d.m_Weights, 0, this.m_Weights, 0, this.m_Weights.length); + if (d.weights != null) { + this.weights = new double[d.weights.length]; + System.arraycopy(d.weights, 0, this.weights, 0, this.weights.length); } } @@ -59,32 +59,32 @@ public class PropertyMutationMixer implements java.io.Serializable { * @param d The InterfaceOptimizationTarget[] */ public void setSelectedMutators(InterfaceMutation[] d) { - this.m_SelectedTargets = d; + this.selectedTargets = d; - if (this.m_Weights == null) { - this.m_Weights = new double[d.length]; - for (int i = 0; i < this.m_Weights.length; i++) { - this.m_Weights[i] = 1 / ((double) d.length); + if (this.weights == null) { + this.weights = new double[d.length]; + for (int i = 0; i < this.weights.length; i++) { + this.weights[i] = 1 / ((double) d.length); } return; } - if (d.length == this.m_Weights.length) { + if (d.length == this.weights.length) { return; } - if (d.length > this.m_Weights.length) { + if (d.length > this.weights.length) { double[] newWeights = new double[d.length]; - for (int i = 0; i < this.m_Weights.length; i++) { - newWeights[i] = this.m_Weights[i]; + for (int i = 0; i < this.weights.length; i++) { + newWeights[i] = this.weights[i]; } - this.m_Weights = newWeights; + this.weights = newWeights; } else { double[] newWeights = new double[d.length]; for (int i = 0; i < d.length; i++) { - newWeights[i] = this.m_Weights[i]; + newWeights[i] = this.weights[i]; } - this.m_Weights = newWeights; + this.weights = newWeights; } } @@ -94,7 +94,7 @@ public class PropertyMutationMixer implements java.io.Serializable { * @return The InterfaceOptimizationTarget[]. */ public InterfaceMutation[] getSelectedMutators() { - return this.m_SelectedTargets; + return this.selectedTargets; } /** @@ -103,7 +103,7 @@ public class PropertyMutationMixer implements java.io.Serializable { * @return The InterfaceOptimizationTarget[]. */ public InterfaceMutation[] getAvailableMutators() { - return this.m_AvailableTargets; + return this.availableTargets; } /** @@ -112,13 +112,13 @@ public class PropertyMutationMixer implements java.io.Serializable { * @return the weights */ public double[] getWeights() { - return this.m_Weights; + return this.weights; } public void setWeights(double[] d) { - this.m_Weights = d; - for (int i = 0; i < this.m_Weights.length; i++) { - this.m_Weights[i] = Math.abs(this.m_Weights[i]); + this.weights = d; + for (int i = 0; i < this.weights.length; i++) { + this.weights[i] = Math.abs(this.weights[i]); } } @@ -128,11 +128,11 @@ public class PropertyMutationMixer implements java.io.Serializable { * @return the string */ public String getDescriptiveString() { - return this.m_DescriptiveString; + return this.descriptiveString; } public void setDescriptiveString(String d) { - this.m_DescriptiveString = d; + this.descriptiveString = d; } /** @@ -141,21 +141,21 @@ public class PropertyMutationMixer implements java.io.Serializable { * @return the string */ public String getWeigthsLabel() { - return this.m_WeightsLabel; + return this.weightsLabel; } public void setWeightsLabel(String d) { - this.m_WeightsLabel = d; + this.weightsLabel = d; } public void normalizeWeights() { double sum = 0; - for (int i = 0; i < this.m_Weights.length; i++) { - sum += this.m_Weights[i]; + for (int i = 0; i < this.weights.length; i++) { + sum += this.weights[i]; } if (sum > 0) { - for (int i = 0; i < this.m_Weights.length; i++) { - this.m_Weights[i] /= sum; + for (int i = 0; i < this.weights.length; i++) { + this.weights[i] /= sum; } } } @@ -166,22 +166,22 @@ public class PropertyMutationMixer implements java.io.Serializable { * @param index The index of the target to be removed. */ public void removeMutator(int index) { - if ((index < 0) || (index >= this.m_SelectedTargets.length)) { + if ((index < 0) || (index >= this.selectedTargets.length)) { return; } - InterfaceMutation[] newList = new InterfaceMutation[this.m_SelectedTargets.length - 1]; - double[] newWeights = new double[this.m_Weights.length - 1]; + InterfaceMutation[] newList = new InterfaceMutation[this.selectedTargets.length - 1]; + double[] newWeights = new double[this.weights.length - 1]; int j = 0; - for (int i = 0; i < this.m_SelectedTargets.length; i++) { + for (int i = 0; i < this.selectedTargets.length; i++) { if (index != i) { - newList[j] = this.m_SelectedTargets[i]; - newWeights[j] = this.m_Weights[i]; + newList[j] = this.selectedTargets[i]; + newWeights[j] = this.weights[i]; j++; } } - this.m_SelectedTargets = newList; - this.m_Weights = newWeights; + this.selectedTargets = newList; + this.weights = newWeights; } /** @@ -190,15 +190,15 @@ public class PropertyMutationMixer implements java.io.Serializable { * @param optTarget */ public void addMutator(InterfaceMutation optTarget) { - InterfaceMutation[] newList = new InterfaceMutation[this.m_SelectedTargets.length + 1]; - double[] newWeights = new double[this.m_Weights.length + 1]; - for (int i = 0; i < this.m_SelectedTargets.length; i++) { - newList[i] = this.m_SelectedTargets[i]; - newWeights[i] = this.m_Weights[i]; + InterfaceMutation[] newList = new InterfaceMutation[this.selectedTargets.length + 1]; + double[] newWeights = new double[this.weights.length + 1]; + for (int i = 0; i < this.selectedTargets.length; i++) { + newList[i] = this.selectedTargets[i]; + newWeights[i] = this.weights[i]; } - newList[this.m_SelectedTargets.length] = optTarget; - newWeights[this.m_SelectedTargets.length] = 1.0; - this.m_SelectedTargets = newList; - this.m_Weights = newWeights; + newList[this.selectedTargets.length] = optTarget; + newWeights[this.selectedTargets.length] = 1.0; + this.selectedTargets = newList; + this.weights = newWeights; } } \ No newline at end of file diff --git a/src/eva2/optimization/operator/mutation/PropertyMutationMixerEditor.java b/src/eva2/optimization/operator/mutation/PropertyMutationMixerEditor.java index e7ceca22..2097016e 100644 --- a/src/eva2/optimization/operator/mutation/PropertyMutationMixerEditor.java +++ b/src/eva2/optimization/operator/mutation/PropertyMutationMixerEditor.java @@ -30,73 +30,73 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito /** * Handles property change notification */ - private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); + private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); /** * The label for when we can't edit that type */ - private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); + private JLabel label = new JLabel("Can't edit", SwingConstants.CENTER); /** * The FilePath that is to be edited */ - private PropertyMutationMixer m_MutatorsWithWeights; + private PropertyMutationMixer mutatorsWithWeights; /** * The gaphix stuff */ - private JComponent m_Editor; - private JPanel m_TargetList; - private JTextField[] m_Weights; - private JComponent[] m_Targets; - private JButton[] m_Delete; - private JScrollPane m_ScrollTargets; - private GeneralOptimizationEditorProperty[] m_Editors; - private GeneralGEOFaker m_Component; - private PropertyChangeListener m_self; + private JComponent editorComponent; + private JPanel targetListPanel; + private JTextField[] weights; + private JComponent[] targets; + private JButton[] deleteButtons; + private JScrollPane scrolltargetPanel; + private GeneralOptimizationEditorProperty[] editors; + private GeneralGEOFaker component; + private PropertyChangeListener self; public PropertyMutationMixerEditor() { - m_self = this; + self = this; } /** * This method will init the CustomEditor Panel */ private void initCustomEditor() { - m_self = this; - this.m_Editor = new JPanel(); - this.m_Editor.setPreferredSize(new Dimension(450, 200)); - this.m_Editor.setMinimumSize(new Dimension(450, 200)); + self = this; + this.editorComponent = new JPanel(); + this.editorComponent.setPreferredSize(new Dimension(450, 200)); + this.editorComponent.setMinimumSize(new Dimension(450, 200)); // init the editors - InterfaceMutation[] list = this.m_MutatorsWithWeights.getSelectedMutators(); - this.m_Editors = new GeneralOptimizationEditorProperty[list.length]; + InterfaceMutation[] list = this.mutatorsWithWeights.getSelectedMutators(); + this.editors = new GeneralOptimizationEditorProperty[list.length]; for (int i = 0; i < list.length; i++) { - this.m_Editors[i] = new GeneralOptimizationEditorProperty(); - this.m_Editors[i].name = list[i].getStringRepresentation(); + this.editors[i] = new GeneralOptimizationEditorProperty(); + this.editors[i].name = list[i].getStringRepresentation(); try { - this.m_Editors[i].value = list[i]; - this.m_Editors[i].editor = PropertyEditorProvider.findEditor(this.m_Editors[i].value.getClass()); - if (this.m_Editors[i].editor == null) { - this.m_Editors[i].editor = PropertyEditorProvider.findEditor(InterfaceMutation.class); + this.editors[i].value = list[i]; + this.editors[i].editor = PropertyEditorProvider.findEditor(this.editors[i].value.getClass()); + if (this.editors[i].editor == null) { + this.editors[i].editor = PropertyEditorProvider.findEditor(InterfaceMutation.class); } - if (this.m_Editors[i].editor instanceof GenericObjectEditor) { - ((GenericObjectEditor) this.m_Editors[i].editor).setClassType(InterfaceMutation.class); + if (this.editors[i].editor instanceof GenericObjectEditor) { + ((GenericObjectEditor) this.editors[i].editor).setClassType(InterfaceMutation.class); } - this.m_Editors[i].editor.setValue(this.m_Editors[i].value); - this.m_Editors[i].editor.addPropertyChangeListener(this); - AbstractObjectEditor.findViewFor(this.m_Editors[i]); - if (this.m_Editors[i].view != null) { - this.m_Editors[i].view.repaint(); + this.editors[i].editor.setValue(this.editors[i].value); + this.editors[i].editor.addPropertyChangeListener(this); + AbstractObjectEditor.findViewFor(this.editors[i]); + if (this.editors[i].view != null) { + this.editors[i].view.repaint(); } } catch (Exception e) { System.out.println("Darn can't read the value..."); } } - this.m_TargetList = new JPanel(); + this.targetListPanel = new JPanel(); this.updateTargetList(); - this.m_ScrollTargets = new JScrollPane(this.m_TargetList); + this.scrolltargetPanel = new JScrollPane(this.targetListPanel); - this.m_Editor.setLayout(new BorderLayout()); - this.m_Editor.add(this.m_ScrollTargets, BorderLayout.CENTER); + this.editorComponent.setLayout(new BorderLayout()); + this.editorComponent.add(this.scrolltargetPanel, BorderLayout.CENTER); // The Button Panel JPanel buttonPanel = new JPanel(); @@ -109,7 +109,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito buttonPanel.add(normButton); buttonPanel.add(addButton); - this.m_Editor.add(buttonPanel, BorderLayout.SOUTH); + this.editorComponent.add(buttonPanel, BorderLayout.SOUTH); // Some description would be nice JTextArea jt = new JTextArea(); @@ -117,7 +117,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito jt.setEditable(false); jt.setLineWrap(true); jt.setWrapStyleWord(true); - jt.setText(this.m_MutatorsWithWeights.getDescriptiveString()); + jt.setText(this.mutatorsWithWeights.getDescriptiveString()); jt.setBackground(getBackground()); JPanel jp = new JPanel(); jp.setBorder(BorderFactory.createCompoundBorder( @@ -134,7 +134,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito jp.add(p2, BorderLayout.EAST); GridBagConstraints gbConstraints = new GridBagConstraints(); - this.m_Editor.add(jp, BorderLayout.NORTH); + this.editorComponent.add(jp, BorderLayout.NORTH); this.updateEditor(); } @@ -145,15 +145,15 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito private void updateTargetList() { BasicResourceLoader loader = BasicResourceLoader.instance(); byte[] bytes; - InterfaceMutation[] list = this.m_MutatorsWithWeights.getSelectedMutators(); - double[] weights = this.m_MutatorsWithWeights.getWeights(); + InterfaceMutation[] list = this.mutatorsWithWeights.getSelectedMutators(); + double[] weights = this.mutatorsWithWeights.getWeights(); - this.m_TargetList.removeAll(); - this.m_TargetList.setLayout(new GridBagLayout()); + this.targetListPanel.removeAll(); + this.targetListPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); - this.m_Weights = new JTextField[list.length]; - this.m_Targets = new JComponent[list.length]; - this.m_Delete = new JButton[list.length]; + this.weights = new JTextField[list.length]; + this.targets = new JComponent[list.length]; + this.deleteButtons = new JButton[list.length]; String[] cups = new String[8]; for (int i = 0; i < cups.length; i++) { cups[i] = "" + (i + 1); @@ -163,52 +163,52 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.weightx = 2; - this.m_TargetList.add(new JLabel(this.m_MutatorsWithWeights.getWeigthsLabel()), gbc); + this.targetListPanel.add(new JLabel(this.mutatorsWithWeights.getWeigthsLabel()), gbc); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 1; gbc.weightx = 10; - this.m_TargetList.add(new JLabel("Target"), gbc); + this.targetListPanel.add(new JLabel("Target"), gbc); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.REMAINDER; gbc.gridx = 2; gbc.weightx = 1; - this.m_TargetList.add(new JLabel("Remove"), gbc); + this.targetListPanel.add(new JLabel("Remove"), gbc); for (int i = 0; i < list.length; i++) { // the weight gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.weightx = 2; - this.m_Weights[i] = new JTextField("" + weights[i]); - this.m_Weights[i].addKeyListener(this.readDoubleArrayAction); - this.m_TargetList.add(this.m_Weights[i], gbc); + this.weights[i] = new JTextField("" + weights[i]); + this.weights[i].addKeyListener(this.readDoubleArrayAction); + this.targetListPanel.add(this.weights[i], gbc); // the status indicator gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 1; gbc.weightx = 10; - this.m_Targets[i] = this.m_Editors[i].view; - this.m_TargetList.add(this.m_Targets[i], gbc); + this.targets[i] = this.editors[i].view; + this.targetListPanel.add(this.targets[i], gbc); // The delete button gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.REMAINDER; gbc.gridx = 2; gbc.weightx = 1; bytes = loader.getBytesFromResourceLocation("images/Sub24.gif", true); - this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes))); - this.m_Delete[i].addActionListener(deleteTarget); - this.m_TargetList.add(this.m_Delete[i], gbc); + this.deleteButtons[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes))); + this.deleteButtons[i].addActionListener(deleteTarget); + this.targetListPanel.add(this.deleteButtons[i], gbc); } - this.m_TargetList.repaint(); - this.m_TargetList.validate(); - if (this.m_ScrollTargets != null) { - this.m_ScrollTargets.validate(); - this.m_ScrollTargets.repaint(); + this.targetListPanel.repaint(); + this.targetListPanel.validate(); + if (this.scrolltargetPanel != null) { + this.scrolltargetPanel.validate(); + this.scrolltargetPanel.repaint(); } - if (this.m_Editor != null) { - this.m_Editor.validate(); - this.m_Editor.repaint(); + if (this.editorComponent != null) { + this.editorComponent.validate(); + this.editorComponent.repaint(); } } @@ -228,13 +228,13 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito ActionListener addTarget = new ActionListener() { @Override public void actionPerformed(ActionEvent event) { - m_MutatorsWithWeights.addMutator((InterfaceMutation) m_MutatorsWithWeights.getAvailableMutators()[0].clone()); - int l = m_MutatorsWithWeights.getSelectedMutators().length; + mutatorsWithWeights.addMutator((InterfaceMutation) mutatorsWithWeights.getAvailableMutators()[0].clone()); + int l = mutatorsWithWeights.getSelectedMutators().length; GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l]; - for (int i = 0; i < m_Editors.length; i++) { - newEdit[i] = m_Editors[i]; + for (int i = 0; i < editors.length; i++) { + newEdit[i] = editors[i]; } - InterfaceMutation[] list = m_MutatorsWithWeights.getSelectedMutators(); + InterfaceMutation[] list = mutatorsWithWeights.getSelectedMutators(); l--; newEdit[l] = new GeneralOptimizationEditorProperty(); newEdit[l].name = list[l].getStringRepresentation(); @@ -248,7 +248,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito ((GenericObjectEditor) newEdit[l].editor).setClassType(InterfaceMutation.class); } newEdit[l].editor.setValue(newEdit[l].value); - newEdit[l].editor.addPropertyChangeListener(m_self); + newEdit[l].editor.addPropertyChangeListener(self); AbstractObjectEditor.findViewFor(newEdit[l]); if (newEdit[l].view != null) { newEdit[l].view.repaint(); @@ -256,7 +256,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito } catch (Exception e) { System.out.println("Darn can't read the value..."); } - m_Editors = newEdit; + editors = newEdit; updateTargetList(); } }; @@ -267,17 +267,17 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito ActionListener deleteTarget = new ActionListener() { @Override public void actionPerformed(ActionEvent event) { - int l = m_MutatorsWithWeights.getSelectedMutators().length, j = 0; + int l = mutatorsWithWeights.getSelectedMutators().length, j = 0; GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l - 1]; - for (int i = 0; i < m_Delete.length; i++) { - if (event.getSource().equals(m_Delete[i])) { - m_MutatorsWithWeights.removeMutator(i); + for (int i = 0; i < deleteButtons.length; i++) { + if (event.getSource().equals(deleteButtons[i])) { + mutatorsWithWeights.removeMutator(i); } else { - newEdit[j] = m_Editors[i]; + newEdit[j] = editors[i]; j++; } } - m_Editors = newEdit; + editors = newEdit; updateTargetList(); } }; @@ -288,7 +288,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito ActionListener normalizeWeights = new ActionListener() { @Override public void actionPerformed(ActionEvent event) { - m_MutatorsWithWeights.normalizeWeights(); + mutatorsWithWeights.normalizeWeights(); updateTargetList(); } }; @@ -307,18 +307,18 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito @Override public void keyReleased(KeyEvent event) { - double[] newW = m_MutatorsWithWeights.getWeights(); + double[] newW = mutatorsWithWeights.getWeights(); for (int i = 0; i < newW.length; i++) { try { double d = 0; - d = new Double(m_Weights[i].getText()).doubleValue(); + d = new Double(weights[i].getText()).doubleValue(); newW[i] = d; } catch (Exception e) { } } - m_MutatorsWithWeights.setWeights(newW); + mutatorsWithWeights.setWeights(newW); } }; @@ -326,13 +326,13 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito * The object may have changed update the editor. */ private void updateEditor() { - if (this.m_Editor != null) { - this.m_TargetList.validate(); - this.m_TargetList.repaint(); - this.m_ScrollTargets.validate(); - this.m_ScrollTargets.repaint(); - this.m_Editor.validate(); - this.m_Editor.repaint(); + if (this.editorComponent != null) { + this.targetListPanel.validate(); + this.targetListPanel.repaint(); + this.scrolltargetPanel.validate(); + this.scrolltargetPanel.repaint(); + this.editorComponent.validate(); + this.editorComponent.repaint(); } } @@ -344,7 +344,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito @Override public void setValue(Object o) { if (o instanceof PropertyMutationMixer) { - this.m_MutatorsWithWeights = (PropertyMutationMixer) o; + this.mutatorsWithWeights = (PropertyMutationMixer) o; this.updateEditor(); } } @@ -356,7 +356,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito */ @Override public Object getValue() { - return this.m_MutatorsWithWeights; + return this.mutatorsWithWeights; } @Override @@ -447,11 +447,11 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito */ @Override public Component getCustomEditor() { - if (this.m_Component == null) { + if (this.component == null) { this.initCustomEditor(); - this.m_Component = new GeneralGEOFaker((PropertyEditor) this, (JPanel) this.m_Editor); + this.component = new GeneralGEOFaker((PropertyEditor) this, (JPanel) this.editorComponent); } - return this.m_Component; + return this.component; } /** @@ -469,12 +469,12 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito @Override public void addPropertyChangeListener(PropertyChangeListener l) { - m_Support.addPropertyChangeListener(l); + propertyChangeSupport.addPropertyChangeListener(l); } @Override public void removePropertyChangeListener(PropertyChangeListener l) { - m_Support.removePropertyChangeListener(l); + propertyChangeSupport.removePropertyChangeListener(l); } /** @@ -487,35 +487,35 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito public void propertyChange(PropertyChangeEvent evt) { Object newVal = evt.getNewValue(); Object oldVal = evt.getOldValue(); - InterfaceMutation[] list = this.m_MutatorsWithWeights.getSelectedMutators(); + InterfaceMutation[] list = this.mutatorsWithWeights.getSelectedMutators(); for (int i = 0; i < list.length; i++) { if (oldVal.equals(list[i])) { list[i] = (InterfaceMutation) newVal; - this.m_Editors[i].name = list[i].getStringRepresentation(); + this.editors[i].name = list[i].getStringRepresentation(); try { - this.m_Editors[i].value = list[i]; - this.m_Editors[i].editor = PropertyEditorProvider.findEditor(this.m_Editors[i].value.getClass()); - if (this.m_Editors[i].editor == null) { - this.m_Editors[i].editor = PropertyEditorProvider.findEditor(InterfaceMutation.class); + this.editors[i].value = list[i]; + this.editors[i].editor = PropertyEditorProvider.findEditor(this.editors[i].value.getClass()); + if (this.editors[i].editor == null) { + this.editors[i].editor = PropertyEditorProvider.findEditor(InterfaceMutation.class); } - if (this.m_Editors[i].editor instanceof GenericObjectEditor) { - ((GenericObjectEditor) this.m_Editors[i].editor).setClassType(InterfaceMutation.class); + if (this.editors[i].editor instanceof GenericObjectEditor) { + ((GenericObjectEditor) this.editors[i].editor).setClassType(InterfaceMutation.class); } - this.m_Editors[i].editor.setValue(this.m_Editors[i].value); - this.m_Editors[i].editor.addPropertyChangeListener(this); - AbstractObjectEditor.findViewFor(this.m_Editors[i]); - if (this.m_Editors[i].view != null) { - this.m_Editors[i].view.repaint(); + this.editors[i].editor.setValue(this.editors[i].value); + this.editors[i].editor.addPropertyChangeListener(this); + AbstractObjectEditor.findViewFor(this.editors[i]); + if (this.editors[i].view != null) { + this.editors[i].view.repaint(); } } catch (Exception e) { System.out.println("Darn can't read the value..."); } - this.m_Targets[i] = this.m_Editors[i].view; + this.targets[i] = this.editors[i].view; i = list.length; } } //this.m_OptimizationTargets.setSelectedTargets(list); this.updateCenterComponent(evt); // Let our panel update before guys downstream - m_Support.firePropertyChange("", m_MutatorsWithWeights, m_MutatorsWithWeights); + propertyChangeSupport.firePropertyChange("", mutatorsWithWeights, mutatorsWithWeights); } } \ No newline at end of file diff --git a/src/eva2/optimization/population/Population.java b/src/eva2/optimization/population/Population.java index 1a69c036..91991e8a 100644 --- a/src/eva2/optimization/population/Population.java +++ b/src/eva2/optimization/population/Population.java @@ -80,7 +80,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea /** * Best n Individuals in the history. */ - private transient LinkedList m_History = new LinkedList(); + private transient LinkedList historyList = new LinkedList(); /** * Remember when the last sorted queue was prepared. @@ -190,8 +190,8 @@ public class Population extends ArrayList implements PopulationInterface, Clonea if (population.populationArchive != null) { this.populationArchive = (Population) population.populationArchive.clone(); } - if (population.m_History != null) { - this.m_History = (LinkedList) population.m_History.clone(); + if (population.historyList != null) { + this.historyList = (LinkedList) population.historyList.clone(); } if (population.additionalPopData != null) { this.additionalPopData = (HashMap) additionalPopData.clone(); @@ -364,7 +364,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * been inited by a problem */ public void init() { - this.m_History = new LinkedList(); + this.historyList = new LinkedList(); this.generationCount = 0; this.functionCallCount = 0; double[] popSeed = null; @@ -453,7 +453,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea /** * This method inits the population. Function and generation counters are - * reset and m_Size default Individuals are created and initialized by the + * reset and size default Individuals are created and initialized by the * GAIndividual default init() method. */ public void defaultInit(AbstractEAIndividual template) { @@ -591,18 +591,18 @@ public class Population extends ArrayList implements PopulationInterface, Clonea public int getHistoryLength() { if (historyMaxLen != 0) { - return m_History.size(); + return historyList.size(); } else { return 0; } } public LinkedList getHistory() { - return m_History; + return historyList; } public void SetHistory(LinkedList theHist) { - m_History = theHist; + historyList = theHist; } /** @@ -709,11 +709,11 @@ public class Population extends ArrayList implements PopulationInterface, Clonea */ public void incrGeneration() { if (isUsingHistory() && (this.size() >= 1)) { - if (historyMaxLen > 0 && (m_History.size() >= historyMaxLen)) { + if (historyMaxLen > 0 && (historyList.size() >= historyMaxLen)) { // oldest one must be replaced.. should be the one in front - m_History.removeFirst(); + historyList.removeFirst(); } - this.m_History.add((AbstractEAIndividual) this.getBestEAIndividual().clone()); + this.historyList.add((AbstractEAIndividual) this.getBestEAIndividual().clone()); } for (int i = 0; i < size(); i++) { ((AbstractEAIndividual) get(i)).incrAge(); @@ -2508,8 +2508,8 @@ public class Population extends ArrayList implements PopulationInterface, Clonea } public void clearHistory() { - if (m_History != null) { - m_History.clear(); + if (historyList != null) { + historyList.clear(); } } diff --git a/src/eva2/optimization/strategies/DifferentialEvolution.java b/src/eva2/optimization/strategies/DifferentialEvolution.java index 5fc3683a..5524455e 100644 --- a/src/eva2/optimization/strategies/DifferentialEvolution.java +++ b/src/eva2/optimization/strategies/DifferentialEvolution.java @@ -680,7 +680,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial @Override public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) { if (this.populationChangedEventListeners == null) { - this.populationChangedEventListeners = new Vector(); + this.populationChangedEventListeners = new Vector<>(); } this.populationChangedEventListeners.add(ea); } @@ -689,7 +689,6 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial public boolean removePopulationChangedEventListener( InterfacePopulationChangedEventListener ea) { if (populationChangedEventListeners != null && populationChangedEventListeners.removeElement(ea)) { - return true; } else { return false;