diff --git a/.classpath b/.classpath index bdb2412f..9cc7882c 100644 --- a/.classpath +++ b/.classpath @@ -2,5 +2,9 @@ + + + + diff --git a/ant/build.xml b/ant/build.xml index 1c76844f..3cfbb381 100644 --- a/ant/build.xml +++ b/ant/build.xml @@ -1,6 +1,6 @@ - + + + @@ -89,7 +94,7 @@ binaryDist - will create a complete binary distribution clean - will clean up files, except the source files and the api documentation - run - will start JavaEvA + run - will start EvA2 use 'ant -projecthelp' for further Main targets @@ -148,29 +153,15 @@ + - - - - - - - - - - - - + - + - - + + - - - - - - - - - - - - - - - - - + @@ -292,13 +236,13 @@ - + - + - + @@ -308,7 +252,7 @@ - + @@ -317,16 +261,15 @@ Binary Distribution +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--> - + - + - - - + + @@ -379,17 +322,17 @@ --> - + - - + + - + @@ -404,7 +347,7 @@ - + @@ -445,13 +388,13 @@ - - - + + - + @@ -467,50 +410,50 @@ - - + + - + - + - + - + - + @@ -518,49 +461,49 @@ - + - + - + - + - + - + - + @@ -571,9 +514,9 @@ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--> - Test]]>
- JavaEvA + EvA2 ]]>
+ + whether pop will be reinitialized. - boolean postProcessOnly = false; - InterfaceTextListener listener = null; + private Processor proc; + private boolean isFinished = false; + private boolean doRestart = false; // indicate whether start or restart should be done --> whether pop will be reinitialized. + private boolean postProcessOnly = false; + private InterfaceTextListener listener = null; public OptimizerRunnable(GOParameters params, String outputFilePrefix) { this(params, outputFilePrefix, false); diff --git a/src/eva2/client/EvAClient.java b/src/eva2/client/EvAClient.java index 8465d96e..a4a6d6c5 100644 --- a/src/eva2/client/EvAClient.java +++ b/src/eva2/client/EvAClient.java @@ -78,6 +78,7 @@ public class EvAClient implements RemoteStateListener, Serializable { private static Properties EVA_PROPERTIES; public static final String iconLocation = "resources/images/icon3.gif"; private static final String splashLocation = "resources/images/splashScreen2.png"; + private static final String infoTitle = "EvA2 Information"; final int splashScreenTime = 1500; public static boolean TRACE = false; @@ -510,7 +511,7 @@ public class EvAClient implements RemoteStateListener, Serializable { if (selectedModule == null) { // show a dialog and ask for a module String[] ModuleNameList = m_ComAdapter.getModuleNameList(); if (ModuleNameList == null) { - JOptionPane.showMessageDialog(m_Frame.getContentPane(), "No modules available on " + m_ComAdapter.getHostName(), "EvA2 Information", 1); + JOptionPane.showMessageDialog(m_Frame.getContentPane(), "No modules available on " + m_ComAdapter.getHostName(), infoTitle, 1); } else { String LastModuleName = Serializer.loadString("lastmodule.ser"); if (LastModuleName == null) LastModuleName = ModuleNameList[0]; @@ -643,7 +644,7 @@ public class EvAClient implements RemoteStateListener, Serializable { } private void showPleaseWaitDialog() { - JOptionPane.showMessageDialog(m_Frame.getContentPane(), "Please wait one moment.", "EvA2 Information", 1); + JOptionPane.showMessageDialog(m_Frame.getContentPane(), "Please wait one moment.", infoTitle, 1); } private void showAboutDialog() { @@ -651,11 +652,11 @@ public class EvAClient implements RemoteStateListener, Serializable { (m_Frame, m_ProductName + "\n University of Tuebingen\n Computer Architecture\n H. Ulmer & F. Streichert & H. Planatscher & M. de Paly & M. Kronfeld\n Prof. Dr. Andreas Zell \n (c) 2008 \n Version " + - EvAServer.Version + " \n http://www.ra.cs.uni-tuebingen.de/software/EvA2", "EvA2 Information", 1); + EvAServer.Version + " \n http://www.ra.cs.uni-tuebingen.de/software/EvA2", infoTitle, 1); } private void showNoHostFoundDialog() { - JOptionPane.showMessageDialog(m_Frame.getContentPane(), "No host with running EVASERVER found. Please start one or \nadd the correct address to the properties list.", "EvA2 Information", 1); + JOptionPane.showMessageDialog(m_Frame.getContentPane(), "No host with running EVASERVER found. Please start one or \nadd the correct address to the properties list.", infoTitle, 1); } /** diff --git a/src/eva2/gui/BeanInspector.java b/src/eva2/gui/BeanInspector.java index 3d5cbdf9..c53478e0 100644 --- a/src/eva2/gui/BeanInspector.java +++ b/src/eva2/gui/BeanInspector.java @@ -431,7 +431,8 @@ public class BeanInspector { continue; } - StringBuffer memberInfoBf = new StringBuffer("Member:\t"); + StringBuffer memberInfoBf = new StringBuffer(40); + memberInfoBf.append("Member:\t"); memberInfoBf.append(name); memberInfoBf.append("\tType: "); @@ -530,7 +531,7 @@ public class BeanInspector { public static Object doubleToPrimitive(Double d, Class destType) { if ((destType == Double.class) || (destType == double.class)) return d; if ((destType == Integer.class) || (destType == int.class)) return new Integer(d.intValue()); - else if ((destType == Boolean.class) || (destType == boolean.class)) return new Boolean(d != 0); + else if ((destType == Boolean.class) || (destType == boolean.class)) return (d!=0) ? Boolean.TRUE : Boolean.FALSE; else if ((destType == Byte.class) || (destType == byte.class)) return new Byte(d.byteValue()); else if ((destType == Short.class) || (destType == short.class)) return new Short(d.shortValue()); else if ((destType == Long.class) || (destType == long.class)) return new Long(d.longValue()); diff --git a/src/eva2/gui/PropertyRemoteServers.java b/src/eva2/gui/PropertyRemoteServers.java index 024a10fe..f4692772 100644 --- a/src/eva2/gui/PropertyRemoteServers.java +++ b/src/eva2/gui/PropertyRemoteServers.java @@ -121,9 +121,9 @@ public class PropertyRemoteServers implements java.io.Serializable { */ public String[] getServerNodes() { String[] result; - ArrayList tmpList = new ArrayList(); + ArrayList tmpList = new ArrayList(); for (int i = 0; i < this.m_AvailableNodes.length; i++) { - for (int j = 0; j < this.m_AvailableNodes[i].m_CPUs; i++) { + for (int j = 0; j < this.m_AvailableNodes[i].m_CPUs; j++) { tmpList.add(this.m_AvailableNodes[i].m_ServerName); } } diff --git a/src/eva2/server/go/GOStandaloneVersion.java b/src/eva2/server/go/GOStandaloneVersion.java index 995f4612..cedf89e6 100644 --- a/src/eva2/server/go/GOStandaloneVersion.java +++ b/src/eva2/server/go/GOStandaloneVersion.java @@ -25,6 +25,8 @@ import javax.swing.JProgressBar; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; +import wsi.ra.jproxy.ThreadProxy; +import wsi.ra.math.RNG; import eva2.client.EvAClient; import eva2.gui.JParaPanel; import eva2.server.go.individuals.AbstractEAIndividual; @@ -42,12 +44,9 @@ import eva2.server.go.problems.F1Problem; import eva2.server.go.strategies.EvolutionStrategies; import eva2.server.go.strategies.GeneticAlgorithm; import eva2.server.go.strategies.InterfaceOptimizer; -import eva2.server.go.tools.RandomNumberGenerator; import eva2.server.modules.GOParameters; import eva2.tools.TokenHolder; -import wsi.ra.jproxy.ThreadProxy; - /** * Created by IntelliJ IDEA. * User: streiche @@ -113,7 +112,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu this.m_GO = GOParameters.getInstance(); this.m_ExperimentName = this.m_GO.getOptimizer().getName()+"-"+this.m_PerformedRuns.size(); this.m_GO.addPopulationChangedEventListener(this); - RandomNumberGenerator.setRandomSeed(m_GO.getSeed()); + RNG.setRandomSeed(m_GO.getSeed()); } /** This method allows you to get the current GO parameters @@ -370,7 +369,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu this.m_GO.saveInstance(); if (this.show) this.m_StatusField.setText("Optimizing..."); - RandomNumberGenerator.setRandomSeed(m_GO.getSeed()); + RNG.setRandomSeed(m_GO.getSeed()); // opening output file... if (!this.m_OutputFileName.equalsIgnoreCase("none")) { String name = ""; @@ -541,7 +540,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu app.setShow(false); } else { GOStandaloneVersion program = new GOStandaloneVersion(); - RandomNumberGenerator.setRandomSeed(1); + RNG.setRandomSeed(1); program.initFrame(); program.setShow(true); } @@ -646,10 +645,10 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu */ // MK: These methods have nothing to do with the seed parameter from the m_GO object which is actually used, so I comment them out // public void setSeed(long seed) { -// RandomNumberGenerator.setseed(seed); +// RNG.setseed(seed); // } // public long getSeed() { -// return RandomNumberGenerator.getRandomSeed(); +// return RNG.getRandomSeed(); // } // public String seedTipText() { // return "Choose the seed for the random number generator."; diff --git a/src/eva2/server/go/individuals/AbstractEAIndividual.java b/src/eva2/server/go/individuals/AbstractEAIndividual.java index 5797ed1a..a40e4341 100644 --- a/src/eva2/server/go/individuals/AbstractEAIndividual.java +++ b/src/eva2/server/go/individuals/AbstractEAIndividual.java @@ -6,6 +6,7 @@ import java.util.BitSet; import java.util.LinkedList; import java.util.List; +import wsi.ra.math.RNG; import eva2.gui.BeanInspector; import eva2.server.go.IndividualInterface; import eva2.server.go.individuals.codings.gp.InterfaceProgram; @@ -16,8 +17,6 @@ import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.operators.mutation.NoMutation; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.GONamingBox; -import eva2.server.go.tools.RandomNumberGenerator; /** This is the abstract EA individual implementing the most important methods giving * access to mutation and crossover rates and operators, fitness values and selection @@ -243,7 +242,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. /** This method will mutate the individual randomly */ public void mutate() { - if (RandomNumberGenerator.flipCoin(this.m_MutationProbability)) this.m_MutationOperator.mutate(this); + if (RNG.flipCoin(this.m_MutationProbability)) this.m_MutationOperator.mutate(this); } /** @@ -257,7 +256,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. */ public AbstractEAIndividual[] mateWith(Population partners) { AbstractEAIndividual[] result; - if (RandomNumberGenerator.flipCoin(this.m_CrossoverProbability)) { + if (RNG.flipCoin(this.m_CrossoverProbability)) { result = this.m_CrossoverOperator.mate(this, partners); if (logParentLen > 0) { for (int i = 0; i < result.length; i++) { diff --git a/src/eva2/server/go/individuals/ESIndividualBinaryData.java b/src/eva2/server/go/individuals/ESIndividualBinaryData.java index 14c68979..550026f7 100644 --- a/src/eva2/server/go/individuals/ESIndividualBinaryData.java +++ b/src/eva2/server/go/individuals/ESIndividualBinaryData.java @@ -2,12 +2,11 @@ package eva2.server.go.individuals; import java.util.BitSet; -import eva2.server.go.IndividualInterface; +import wsi.ra.math.RNG; import eva2.server.go.operators.crossover.CrossoverESDefault; import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.operators.mutation.MutateESGlobal; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; /** This individual uses a real-valued genotype to code for binary values, either @@ -127,7 +126,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte } else { // in this case the value of the genotype is interpreted as a probability for (int i = 0; i < this.m_Genotype.length; i++) { - if (RandomNumberGenerator.flipCoin(this.m_Genotype[i])) { + if (RNG.flipCoin(this.m_Genotype[i])) { this.m_Phenotype.set(i); } else { this.m_Phenotype.clear(i); @@ -159,8 +158,8 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte this.SetBinaryData(binaryData); for (int i = 0; i < this.m_Genotype.length; i++) { if (this.m_UseHardSwitch) { - if (binaryData.get(i)) this.m_Genotype[i] = RandomNumberGenerator.randomDouble(0.55,1.0); - else this.m_Genotype[i] = RandomNumberGenerator.randomDouble(0.0,0.45); + if (binaryData.get(i)) this.m_Genotype[i] = RNG.randomDouble(0.55,1.0); + else this.m_Genotype[i] = RNG.randomDouble(0.0,0.45); } else { if (binaryData.get(i)) this.m_Genotype[i] = 0.9; else this.m_Genotype[i] = 0.1; @@ -258,8 +257,8 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte /** This method performs a simple one element mutation on the double vector */ public void defaultMutate() { - int mutationIndex = RandomNumberGenerator.randomInt(0, this.m_Genotype.length-1); - this.m_Genotype[mutationIndex] += ((this.m_Range[mutationIndex][1] - this.m_Range[mutationIndex][0])/2)*RandomNumberGenerator.gaussianDouble(0.05f); + int mutationIndex = RNG.randomInt(0, this.m_Genotype.length-1); + this.m_Genotype[mutationIndex] += ((this.m_Range[mutationIndex][1] - this.m_Range[mutationIndex][0])/2)*RNG.gaussianDouble(0.05f); if (this.m_Genotype[mutationIndex] < this.m_Range[mutationIndex][0]) this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][0]; if (this.m_Genotype[mutationIndex] > this.m_Range[mutationIndex][1]) this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][1]; } @@ -268,7 +267,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte */ public void defaultInit() { for (int i = 0; i < this.m_Genotype.length; i++) { - this.m_Genotype[i] = RandomNumberGenerator.randomDouble(this.m_Range[i][0], this.m_Range[i][1]); + this.m_Genotype[i] = RNG.randomDouble(this.m_Range[i][0], this.m_Range[i][1]); } } /********************************************************************************************************************** diff --git a/src/eva2/server/go/individuals/ESIndividualDoubleData.java b/src/eva2/server/go/individuals/ESIndividualDoubleData.java index 3e577c42..10b2104c 100644 --- a/src/eva2/server/go/individuals/ESIndividualDoubleData.java +++ b/src/eva2/server/go/individuals/ESIndividualDoubleData.java @@ -8,7 +8,7 @@ import eva2.server.go.operators.crossover.CrossoverESDefault; import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.operators.mutation.MutateESGlobal; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual uses a real-valued genotype to code for double values. * Created by IntelliJ IDEA. @@ -279,8 +279,8 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte /** This method performs a simple one element mutation on the double vector */ public void defaultMutate() { - int mutationIndex = RandomNumberGenerator.randomInt(0, this.m_Genotype.length-1); - this.m_Genotype[mutationIndex] += ((this.m_Range[mutationIndex][1] - this.m_Range[mutationIndex][0])/2)*RandomNumberGenerator.gaussianDouble(0.05f); + int mutationIndex = RNG.randomInt(0, this.m_Genotype.length-1); + this.m_Genotype[mutationIndex] += ((this.m_Range[mutationIndex][1] - this.m_Range[mutationIndex][0])/2)*RNG.gaussianDouble(0.05f); if (this.m_Genotype[mutationIndex] < this.m_Range[mutationIndex][0]) this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][0]; if (this.m_Genotype[mutationIndex] > this.m_Range[mutationIndex][1]) this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][1]; } @@ -289,7 +289,7 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte */ public void defaultInit() { for (int i = 0; i < this.m_Genotype.length; i++) { - this.m_Genotype[i] = RandomNumberGenerator.randomDouble(this.m_Range[i][0], this.m_Range[i][1]); + this.m_Genotype[i] = RNG.randomDouble(this.m_Range[i][0], this.m_Range[i][1]); } } diff --git a/src/eva2/server/go/individuals/ESIndividualIntegerData.java b/src/eva2/server/go/individuals/ESIndividualIntegerData.java index 488ff628..94cff982 100644 --- a/src/eva2/server/go/individuals/ESIndividualIntegerData.java +++ b/src/eva2/server/go/individuals/ESIndividualIntegerData.java @@ -8,7 +8,7 @@ import eva2.server.go.operators.crossover.CrossoverESDefault; import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.operators.mutation.MutateESGlobal; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual uses a real-valued genotype to code for integer values. * Created by IntelliJ IDEA. @@ -255,8 +255,8 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int /** This method performs a simple one element mutation on the double vector */ public void defaultMutate() { - int mutationIndex = RandomNumberGenerator.randomInt(0, this.m_Genotype.length-1); - this.m_Genotype[mutationIndex] += ((this.m_Range[mutationIndex][1] - this.m_Range[mutationIndex][0])/2)*RandomNumberGenerator.gaussianDouble(0.05f); + int mutationIndex = RNG.randomInt(0, this.m_Genotype.length-1); + this.m_Genotype[mutationIndex] += ((this.m_Range[mutationIndex][1] - this.m_Range[mutationIndex][0])/2)*RNG.gaussianDouble(0.05f); if (this.m_Genotype[mutationIndex] < this.m_Range[mutationIndex][0]) this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][0]; if (this.m_Genotype[mutationIndex] > this.m_Range[mutationIndex][1]) this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][1]; } @@ -277,7 +277,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int */ public void defaultInit() { for (int i = 0; i < this.m_Genotype.length; i++) { - this.m_Genotype[i] = RandomNumberGenerator.randomInt(this.m_Range[i][0], this.m_Range[i][1]); + this.m_Genotype[i] = RNG.randomInt(this.m_Range[i][0], this.m_Range[i][1]); } } /********************************************************************************************************************** diff --git a/src/eva2/server/go/individuals/ESIndividualPermutationData.java b/src/eva2/server/go/individuals/ESIndividualPermutationData.java index 36c489ae..330c40ab 100644 --- a/src/eva2/server/go/individuals/ESIndividualPermutationData.java +++ b/src/eva2/server/go/individuals/ESIndividualPermutationData.java @@ -5,7 +5,7 @@ import eva2.server.go.operators.crossover.CrossoverESDefault; import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.operators.mutation.MutateESGlobal; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual uses a real-valued genotype to code for a permutations, * the sorting of the real-valued genotype gives the permutation. @@ -180,7 +180,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements for (int j = 0; j < this.m_Genotype[p].length; j++) { if ((i != j) && (this.m_Genotype[p][i] == this.m_Genotype[p][j])) { notValid = true; - this.m_Genotype[p][j] = RandomNumberGenerator.randomDouble(0, 1); + this.m_Genotype[p][j] = RNG.randomDouble(0, 1); } } } @@ -320,8 +320,8 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements */ public void defaultMutate() { for (int i = 0; i < m_Genotype.length; i++) { - int mutationIndex = RandomNumberGenerator.randomInt(0, this.m_Genotype[i].length-1); - this.m_Genotype[i][mutationIndex] += ((this.m_Range[i][mutationIndex][1] - this.m_Range[i][mutationIndex][0])/2)*RandomNumberGenerator.gaussianDouble(0.05f); + int mutationIndex = RNG.randomInt(0, this.m_Genotype[i].length-1); + this.m_Genotype[i][mutationIndex] += ((this.m_Range[i][mutationIndex][1] - this.m_Range[i][mutationIndex][0])/2)*RNG.gaussianDouble(0.05f); if (this.m_Genotype[i][mutationIndex] < this.m_Range[i][mutationIndex][0]) this.m_Genotype[i][mutationIndex] = this.m_Range[i][mutationIndex][0]; if (this.m_Genotype[i][mutationIndex] > this.m_Range[i][mutationIndex][1]) this.m_Genotype[i][mutationIndex] = this.m_Range[i][mutationIndex][1]; } @@ -333,7 +333,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements public void defaultInit() { for (int i = 0; i < this.m_Genotype.length; i++) { for (int j = 0; j < this.m_Genotype[i].length; j++) { - this.m_Genotype[i][j] = RandomNumberGenerator.randomDouble(this.m_Range[i][j][0], this.m_Range[i][j][1]); + this.m_Genotype[i][j] = RNG.randomDouble(this.m_Range[i][j][0], this.m_Range[i][j][1]); } } } diff --git a/src/eva2/server/go/individuals/GAESIndividualBinaryDoubleData.java b/src/eva2/server/go/individuals/GAESIndividualBinaryDoubleData.java index ae6e75c9..712be6ee 100644 --- a/src/eva2/server/go/individuals/GAESIndividualBinaryDoubleData.java +++ b/src/eva2/server/go/individuals/GAESIndividualBinaryDoubleData.java @@ -6,7 +6,7 @@ import java.util.BitSet; import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual combines a binary and a real-valued phenotype. * Created by IntelliJ IDEA. @@ -99,8 +99,8 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme /** This method will mutate the individual randomly */ public void mutate() { - if (RandomNumberGenerator.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Numbers).mutate(); - if (RandomNumberGenerator.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_BitSet).mutate(); + if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Numbers).mutate(); + if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_BitSet).mutate(); } /** This method will mate the Individual with given other individuals @@ -110,7 +110,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme */ public AbstractEAIndividual[] mateWith(Population partners) { AbstractEAIndividual[] result; - if (RandomNumberGenerator.flipCoin(this.m_CrossoverProbability)) { + if (RNG.flipCoin(this.m_CrossoverProbability)) { AbstractEAIndividual[] resNum, resBin; AbstractEAIndividual numTmp, binTmp; Population numPop, binPop; diff --git a/src/eva2/server/go/individuals/GAIndividualBinaryData.java b/src/eva2/server/go/individuals/GAIndividualBinaryData.java index 6bf197ee..db2c4758 100644 --- a/src/eva2/server/go/individuals/GAIndividualBinaryData.java +++ b/src/eva2/server/go/individuals/GAIndividualBinaryData.java @@ -12,7 +12,7 @@ import eva2.server.go.operators.mutation.MutateGADefault; import eva2.server.go.operators.mutation.MutateGAStandard; import eva2.server.go.operators.mutation.NoMutation; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual uses a binary genotype to code for binary values. * Created by IntelliJ IDEA. @@ -183,7 +183,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte */ public void defaultInit() { for (int i = 0; i < this.m_GenotypeLength; i++) { - if (RandomNumberGenerator.flipCoin(0.5)) this.m_Genotype.set(i); + if (RNG.flipCoin(0.5)) this.m_Genotype.set(i); else this.m_Genotype.clear(i); } } @@ -191,7 +191,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte /** This method performs a simple one point mutation in the genotype */ public void defaultMutate() { - int mutationIndex = RandomNumberGenerator.randomInt(0, this.m_GenotypeLength); + int mutationIndex = RNG.randomInt(0, this.m_GenotypeLength); //if (mutationIndex > 28) System.out.println("Mutate: " + this.getSolutionRepresentationFor()); if (this.m_Genotype.get(mutationIndex)) this.m_Genotype.clear(mutationIndex); else this.m_Genotype.set(mutationIndex); diff --git a/src/eva2/server/go/individuals/GAIndividualDoubleData.java b/src/eva2/server/go/individuals/GAIndividualDoubleData.java index 7fe576ec..bafc251f 100644 --- a/src/eva2/server/go/individuals/GAIndividualDoubleData.java +++ b/src/eva2/server/go/individuals/GAIndividualDoubleData.java @@ -12,7 +12,7 @@ import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.operators.mutation.MutateGADefault; import eva2.server.go.operators.mutation.MutateGAStandard; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual uses a binary genotype to code for double values * using two alternative encodings. @@ -296,7 +296,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte */ public void defaultInit() { for (int i = 0; i < this.m_GenotypeLength; i++) { - if (RandomNumberGenerator.flipCoin(0.5)) this.m_Genotype.set(i); + if (RNG.flipCoin(0.5)) this.m_Genotype.set(i); else this.m_Genotype.clear(i); } } @@ -304,7 +304,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte /** This method performs a simple one point mutation in the genotype */ public void defaultMutate() { - int mutationIndex = RandomNumberGenerator.randomInt(0, this.m_GenotypeLength); + int mutationIndex = RNG.randomInt(0, this.m_GenotypeLength); if (this.m_Genotype.get(mutationIndex)) this.m_Genotype.clear(mutationIndex); else this.m_Genotype.set(mutationIndex); } diff --git a/src/eva2/server/go/individuals/GAIndividualIntegerData.java b/src/eva2/server/go/individuals/GAIndividualIntegerData.java index e2872604..62466df8 100644 --- a/src/eva2/server/go/individuals/GAIndividualIntegerData.java +++ b/src/eva2/server/go/individuals/GAIndividualIntegerData.java @@ -11,7 +11,7 @@ import eva2.server.go.operators.crossover.CrossoverGANPoint; import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.operators.mutation.MutateGAStandard; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual uses a binary genotype to code for binary values using * two alternative encodings. @@ -313,7 +313,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int int overallLength = 0; for (int i = 0; i < this.m_CodingLenghts.length; i++) overallLength += this.m_CodingLenghts[i]; for (int i = 0; i < overallLength; i++) { - if (RandomNumberGenerator.flipCoin(0.5)) this.m_Genotype.set(i); + if (RNG.flipCoin(0.5)) this.m_Genotype.set(i); else this.m_Genotype.clear(i); } } @@ -323,7 +323,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int public void defaultMutate() { int overallLength = 0; for (int i = 0; i < this.m_CodingLenghts.length; i++) overallLength += this.m_CodingLenghts[i]; - int mutationIndex = RandomNumberGenerator.randomInt(0, overallLength); + int mutationIndex = RNG.randomInt(0, overallLength); if (this.m_Genotype.get(mutationIndex)) this.m_Genotype.clear(mutationIndex); else this.m_Genotype.set(mutationIndex); } @@ -350,7 +350,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int System.out.println(tmp+"}"); tmp = "Setting {"; for (int i = 0; i < data.length; i++) { - data[i] = RandomNumberGenerator.randomInt(range[i][0], range[i][1]); + data[i] = RNG.randomInt(range[i][0], range[i][1]); tmp += data[i] + "; "; } System.out.println(tmp+"}"); diff --git a/src/eva2/server/go/individuals/GAPIndividualProgramData.java b/src/eva2/server/go/individuals/GAPIndividualProgramData.java index 87e0e42c..4434e1c8 100644 --- a/src/eva2/server/go/individuals/GAPIndividualProgramData.java +++ b/src/eva2/server/go/individuals/GAPIndividualProgramData.java @@ -14,7 +14,7 @@ import eva2.server.go.operators.mutation.MutateESDefault; import eva2.server.go.operators.mutation.MutateGPDefault; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual combines a real-valued phenotype with a tree-based phenotype. * Created by IntelliJ IDEA. @@ -107,8 +107,8 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In /** This method will mutate the individual randomly */ public void mutate() { - if (RandomNumberGenerator.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Numbers).mutate(); - if (RandomNumberGenerator.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Program).mutate(); + if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Numbers).mutate(); + if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Program).mutate(); } /** This method will mate the Individual with given other individuals @@ -118,7 +118,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In */ public AbstractEAIndividual[] mateWith(Population partners) { AbstractEAIndividual[] result; - if (RandomNumberGenerator.flipCoin(this.m_CrossoverProbability)) { + if (RNG.flipCoin(this.m_CrossoverProbability)) { AbstractEAIndividual[] resNum, resBin; AbstractEAIndividual numTmp, binTmp; Population numPop, binPop; diff --git a/src/eva2/server/go/individuals/GEIndividualProgramData.java b/src/eva2/server/go/individuals/GEIndividualProgramData.java index ec93abb4..3c6303c7 100644 --- a/src/eva2/server/go/individuals/GEIndividualProgramData.java +++ b/src/eva2/server/go/individuals/GEIndividualProgramData.java @@ -11,7 +11,7 @@ import eva2.server.go.operators.crossover.CrossoverGADefault; import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.operators.mutation.MutateGADefault; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual uses a binary genotype to code for a tree-based representation * using a BNF grammar, see also Grammatical Evolution. @@ -578,7 +578,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int */ public void defaultInit() { for (int i = 0; i < this.m_GenotypeLengthPerProgram*this.m_Area.length; i++) { - if (RandomNumberGenerator.flipCoin(0.5)) this.m_Genotype.set(i); + if (RNG.flipCoin(0.5)) this.m_Genotype.set(i); else this.m_Genotype.clear(i); } } @@ -586,7 +586,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int /** This method performs a simple one point mutation in the genotype */ public void defaultMutate() { - int mutationIndex = RandomNumberGenerator.randomInt(0, this.m_GenotypeLengthPerProgram*this.m_Area.length); + int mutationIndex = RNG.randomInt(0, this.m_GenotypeLengthPerProgram*this.m_Area.length); //if (mutationIndex > 28) System.out.println("Mutate: " + this.getSolutionRepresentationFor()); if (this.m_Genotype.get(mutationIndex)) this.m_Genotype.clear(mutationIndex); else this.m_Genotype.set(mutationIndex); diff --git a/src/eva2/server/go/individuals/GIIndividualIntegerData.java b/src/eva2/server/go/individuals/GIIndividualIntegerData.java index e2646436..be541130 100644 --- a/src/eva2/server/go/individuals/GIIndividualIntegerData.java +++ b/src/eva2/server/go/individuals/GIIndividualIntegerData.java @@ -4,7 +4,7 @@ import eva2.server.go.operators.crossover.CrossoverGIDefault; import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.operators.mutation.MutateGIDefault; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual uses a integer genotype to code for integer values. * Created by IntelliJ IDEA. @@ -275,15 +275,15 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int /** This method performs a simple one point mutation in the genotype */ public void defaultMutate() { - int mutationIndex = RandomNumberGenerator.randomInt(0, this.m_Genotype.length-1); - this.m_Genotype[mutationIndex] = RandomNumberGenerator.randomInt(this.m_Range[mutationIndex][0], this.m_Range[mutationIndex][1]); + int mutationIndex = RNG.randomInt(0, this.m_Genotype.length-1); + this.m_Genotype[mutationIndex] = RNG.randomInt(this.m_Range[mutationIndex][0], this.m_Range[mutationIndex][1]); } /** This method initializes the GA genotype randomly */ public void defaultInit() { for (int i = 0; i < this.m_Genotype.length; i++) { - this.m_Genotype[i] = RandomNumberGenerator.randomInt(this.m_Range[i][0], this.m_Range[i][1]); + this.m_Genotype[i] = RNG.randomInt(this.m_Range[i][0], this.m_Range[i][1]); } } diff --git a/src/eva2/server/go/individuals/GIOBGAIndividualIntegerPermutationData.java b/src/eva2/server/go/individuals/GIOBGAIndividualIntegerPermutationData.java index c322a051..d693de2d 100644 --- a/src/eva2/server/go/individuals/GIOBGAIndividualIntegerPermutationData.java +++ b/src/eva2/server/go/individuals/GIOBGAIndividualIntegerPermutationData.java @@ -6,7 +6,7 @@ import java.util.BitSet; import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual combines a binary and a real-valued phenotype. * Created by IntelliJ IDEA. @@ -99,8 +99,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual /** This method will mutate the individual randomly */ public void mutate() { - if (RandomNumberGenerator.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Integer).mutate(); - if (RandomNumberGenerator.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Permutation).mutate(); + if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Integer).mutate(); + if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Permutation).mutate(); } /** This method will mate the Individual with given other individuals @@ -110,7 +110,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual */ public AbstractEAIndividual[] mateWith(Population partners) { AbstractEAIndividual[] result; - if (RandomNumberGenerator.flipCoin(this.m_CrossoverProbability)) { + if (RNG.flipCoin(this.m_CrossoverProbability)) { AbstractEAIndividual[] resNum, resBin; AbstractEAIndividual numTmp, binTmp; Population numPop, binPop; diff --git a/src/eva2/server/go/individuals/GPIndividualProgramData.java b/src/eva2/server/go/individuals/GPIndividualProgramData.java index a16fd841..56392eff 100644 --- a/src/eva2/server/go/individuals/GPIndividualProgramData.java +++ b/src/eva2/server/go/individuals/GPIndividualProgramData.java @@ -10,7 +10,7 @@ import eva2.server.go.operators.crossover.CrossoverGPDefault; import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.operators.mutation.MutateGPDefault; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import eva2.tools.EVAERROR; import eva2.tools.EVAHELP; @@ -270,7 +270,7 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int ArrayList allNodes = new ArrayList(); for (int i = 0; i < this.m_Genotype.length; i++) { this.m_Genotype[i].addNodesTo(allNodes); - AbstractGPNode nodeToMutate = (AbstractGPNode) allNodes.get(RandomNumberGenerator.randomInt(0, allNodes.size()-1)); + AbstractGPNode nodeToMutate = (AbstractGPNode) allNodes.get(RNG.randomInt(0, allNodes.size()-1)); if (nodeToMutate.getParent() == null) { this.defaultInit(); } else { @@ -292,8 +292,8 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int } else { this.m_Genotype[i] = (AbstractGPNode)(this.m_Area[i].getRandomNonTerminal()).clone(); this.m_Genotype[i].setDepth(0); - int targetDepth = RandomNumberGenerator.randomInt(1, this.m_InitDepth); - if (RandomNumberGenerator.flipCoin(this.m_InitFullGrowRatio)) + int targetDepth = RNG.randomInt(1, this.m_InitDepth); + if (RNG.flipCoin(this.m_InitFullGrowRatio)) this.m_Genotype[i].initFull(this.m_Area[i], targetDepth); else this.m_Genotype[i].initGrow(this.m_Area[i], targetDepth); diff --git a/src/eva2/server/go/individuals/OBGAIndividualPermutationData.java b/src/eva2/server/go/individuals/OBGAIndividualPermutationData.java index 1bc073d1..cd4b36cf 100644 --- a/src/eva2/server/go/individuals/OBGAIndividualPermutationData.java +++ b/src/eva2/server/go/individuals/OBGAIndividualPermutationData.java @@ -7,7 +7,7 @@ import eva2.server.go.operators.crossover.CrossoverOBGAPMX; import eva2.server.go.operators.mutation.InterfaceMutation; import eva2.server.go.operators.mutation.MutateOBGAFlip; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This individual uses a permutation based genotype to code for * permutations. @@ -170,8 +170,8 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen int[][] permmatrix = this.getPermutationData(); for (int i = 0; i < permmatrix.length; i++) { int[] perm = permmatrix[i]; - int p1 = RandomNumberGenerator.randomInt(0,perm.length-1); - int p2 = RandomNumberGenerator.randomInt(0,perm.length-1); + int p1 = RNG.randomInt(0,perm.length-1); + int p2 = RNG.randomInt(0,perm.length-1); int temp = perm[p1]; perm[p1] = perm[p2]; perm[p2] = temp; @@ -192,7 +192,7 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen } int i = 0; while (!pot.isEmpty()) { - perm[p][i] = ((Integer) (pot.remove(RandomNumberGenerator.randomInt(0, pot.size() - 1)))).intValue(); + perm[p][i] = ((Integer) (pot.remove(RNG.randomInt(0, pot.size() - 1)))).intValue(); i++; } } diff --git a/src/eva2/server/go/individuals/codings/ga/GAGrayCodingDouble.java b/src/eva2/server/go/individuals/codings/ga/GAGrayCodingDouble.java index 16c723a9..066be876 100644 --- a/src/eva2/server/go/individuals/codings/ga/GAGrayCodingDouble.java +++ b/src/eva2/server/go/individuals/codings/ga/GAGrayCodingDouble.java @@ -3,7 +3,7 @@ package eva2.server.go.individuals.codings.ga; import java.util.BitSet; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This gives the gray coding for double with a variable number of bits for coding * As far as i recall the least significant bit is to the left. @@ -86,7 +86,7 @@ public class GAGrayCodingDouble implements InterfaceGADoubleCoding, java.io.Seri range[0] = -10; range[1] = 10; for (int i = 0; i < 10; i++) { - value = RandomNumberGenerator.randomDouble(range[0], range[1]); + value = RNG.randomDouble(range[0], range[1]); tmp = value; System.out.println("Coding Value : " + value); t.codeValue(value, range, tmpBitSet, locus); diff --git a/src/eva2/server/go/individuals/codings/ga/GAStandardCodingInteger.java b/src/eva2/server/go/individuals/codings/ga/GAStandardCodingInteger.java index b7d457a6..abaaebb4 100644 --- a/src/eva2/server/go/individuals/codings/ga/GAStandardCodingInteger.java +++ b/src/eva2/server/go/individuals/codings/ga/GAStandardCodingInteger.java @@ -3,7 +3,7 @@ package eva2.server.go.individuals.codings.ga; import java.util.BitSet; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** The traditional binary coding for integer number, no variable number of bits here, sorry. * Created by IntelliJ IDEA. @@ -55,7 +55,7 @@ public class GAStandardCodingInteger implements InterfaceGAIntegerCoding, java.i //System.out.print("Korregiere: " + tmpV + " > " + u_max); if (correction) { // a new value within the bounds is generated - tmpV = RandomNumberGenerator.randomInt(u_min, u_max); + tmpV = RNG.randomInt(u_min, u_max); //System.out.println("zu: " + tmpV); codeValue((int)tmpV, range, refBitSet, locus); } else { diff --git a/src/eva2/server/go/individuals/codings/gp/GPArea.java b/src/eva2/server/go/individuals/codings/gp/GPArea.java index 87f36052..6a6f196f 100644 --- a/src/eva2/server/go/individuals/codings/gp/GPArea.java +++ b/src/eva2/server/go/individuals/codings/gp/GPArea.java @@ -3,7 +3,7 @@ package eva2.server.go.individuals.codings.gp; import java.util.ArrayList; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This class gives the area of GPNodes for a GP problem. The area gives * the range of possible nodes to select from for a GP. @@ -114,14 +114,14 @@ public class GPArea implements java.io.Serializable { if (((AbstractGPNode)this.m_ReducedList.get(i)).getArity() == targetarity) tmpArray.add(this.m_ReducedList.get(i)); } if (tmpArray.size() == 0) return null; - else return (AbstractGPNode)tmpArray.get(RandomNumberGenerator.randomInt(0, tmpArray.size()-1)); + else return (AbstractGPNode)tmpArray.get(RNG.randomInt(0, tmpArray.size()-1)); } /** This method will return a random node. */ public AbstractGPNode getRandomNode() { if (this.m_ReducedList.size() == 0) return null; - else return (AbstractGPNode)this.m_ReducedList.get(RandomNumberGenerator.randomInt(0, this.m_ReducedList.size()-1)); + else return (AbstractGPNode)this.m_ReducedList.get(RNG.randomInt(0, this.m_ReducedList.size()-1)); } /** This method will return a non terminal @@ -132,6 +132,6 @@ public class GPArea implements java.io.Serializable { if (((AbstractGPNode)this.m_ReducedList.get(i)).getArity() > 0) tmpArray.add(this.m_ReducedList.get(i)); } if (tmpArray.size() == 0) return null; - else return (AbstractGPNode)tmpArray.get(RandomNumberGenerator.randomInt(0, tmpArray.size()-1)); + else return (AbstractGPNode)tmpArray.get(RNG.randomInt(0, tmpArray.size()-1)); } } diff --git a/src/eva2/server/go/mocco/MOCCOParameterizeRefPoint.java b/src/eva2/server/go/mocco/MOCCOParameterizeRefPoint.java index 83e6ca5d..742a527b 100644 --- a/src/eva2/server/go/mocco/MOCCOParameterizeRefPoint.java +++ b/src/eva2/server/go/mocco/MOCCOParameterizeRefPoint.java @@ -13,7 +13,7 @@ import eva2.server.go.operators.moso.MOSOLpMetric; import eva2.server.go.problems.AbstractMultiObjectiveOptimizationProblem; import eva2.server.go.strategies.IslandModelEA; import eva2.server.go.tools.GeneralGOEProperty; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import java.awt.*; import java.awt.event.ActionListener; @@ -235,7 +235,7 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr for (int i = 0; i < m_Perturbations; i++) { tmpD = new double[m_RefPoint.length]; for (int j = 0; j < tmpD.length; j++) { - if (i > 0) tmpD[j] = m_RefPoint[j] + RandomNumberGenerator.gaussianDouble(m_Perturbation); + if (i > 0) tmpD[j] = m_RefPoint[j] + RNG.gaussianDouble(m_Perturbation); else tmpD[j] = m_RefPoint[j]; } tmpLPs[i] = (MOSOLpMetric)m_LpMetric.clone(); diff --git a/src/eva2/server/go/mocco/MOCCOParameterizeTchebycheff.java b/src/eva2/server/go/mocco/MOCCOParameterizeTchebycheff.java index ee7ce8ec..06706f02 100644 --- a/src/eva2/server/go/mocco/MOCCOParameterizeTchebycheff.java +++ b/src/eva2/server/go/mocco/MOCCOParameterizeTchebycheff.java @@ -13,7 +13,7 @@ import eva2.server.go.operators.moso.MOSOWeightedLPTchebycheff; import eva2.server.go.problems.AbstractMultiObjectiveOptimizationProblem; import eva2.server.go.strategies.IslandModelEA; import eva2.server.go.tools.GeneralGOEProperty; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import java.awt.*; import java.awt.event.ActionListener; @@ -257,7 +257,7 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac u = l; l = t; } - if (i > 0) tmpD[j] = RandomNumberGenerator.randomDouble(l,u); + if (i > 0) tmpD[j] = RNG.randomDouble(l,u); else tmpD[j] = 1; sum += tmpD[j]; } diff --git a/src/eva2/server/go/operators/archiving/ArchivingNSGAII.java b/src/eva2/server/go/operators/archiving/ArchivingNSGAII.java index 9b167602..5468c9a6 100644 --- a/src/eva2/server/go/operators/archiving/ArchivingNSGAII.java +++ b/src/eva2/server/go/operators/archiving/ArchivingNSGAII.java @@ -8,7 +8,7 @@ import eva2.server.go.IndividualInterface; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.ESIndividualDoubleData; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import wsi.ra.chart2d.DPoint; import wsi.ra.chart2d.DPointIcon; diff --git a/src/eva2/server/go/operators/archiving/ArchivingPESAII.java b/src/eva2/server/go/operators/archiving/ArchivingPESAII.java index bcb26f8a..31c935df 100644 --- a/src/eva2/server/go/operators/archiving/ArchivingPESAII.java +++ b/src/eva2/server/go/operators/archiving/ArchivingPESAII.java @@ -11,7 +11,7 @@ import eva2.gui.*; import eva2.server.go.IndividualInterface; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** The Pareto envelope sorting algorithm using a hybergrid and * the so called squezze factor. @@ -145,7 +145,7 @@ public class ArchivingPESAII extends AbstractArchiving implements java.io.Serial bigSqueeze = squeezeFactor[i]; index = i; } - if ((bigSqueeze == squeezeFactor[i]) && RandomNumberGenerator.flipCoin(0.5)) index = i; + if ((bigSqueeze == squeezeFactor[i]) && RNG.flipCoin(0.5)) index = i; } archive.remove(index); } diff --git a/src/eva2/server/go/operators/archiving/InformationRetrievalReplacing.java b/src/eva2/server/go/operators/archiving/InformationRetrievalReplacing.java index 5cd17ba4..b8c8091c 100644 --- a/src/eva2/server/go/operators/archiving/InformationRetrievalReplacing.java +++ b/src/eva2/server/go/operators/archiving/InformationRetrievalReplacing.java @@ -1,7 +1,7 @@ package eva2.server.go.operators.archiving; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This information retrieval method simply add the retrieved solutions * to the current population. @@ -34,7 +34,7 @@ public class InformationRetrievalReplacing implements InterfaceInformationRetrie tmp.addPopulation(archive); while (tmp.size() < archive.getPopulationSize()) { - tmp.add(pop.get(RandomNumberGenerator.randomInt(0,pop.size()-1))); + tmp.add(pop.get(RNG.randomInt(0,pop.size()-1))); } pop.clear(); diff --git a/src/eva2/server/go/operators/archiving/RemoveSurplusIndividualsDynamicHyperCube.java b/src/eva2/server/go/operators/archiving/RemoveSurplusIndividualsDynamicHyperCube.java index c787d291..13eb104a 100644 --- a/src/eva2/server/go/operators/archiving/RemoveSurplusIndividualsDynamicHyperCube.java +++ b/src/eva2/server/go/operators/archiving/RemoveSurplusIndividualsDynamicHyperCube.java @@ -2,7 +2,7 @@ package eva2.server.go.operators.archiving; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This class removes surplus individuals based on bounding * hybercube, which can be calculated in objective or decision @@ -50,7 +50,7 @@ public class RemoveSurplusIndividualsDynamicHyperCube implements InterfaceRemove if (space[i] < space[indexSmallHyperCube]) indexSmallHyperCube = i; else { // if they are equal give them a fair chance to exchange between them - if ((space[i] == space[indexSmallHyperCube]) && (RandomNumberGenerator.flipCoin(0.5))) { + if ((space[i] == space[indexSmallHyperCube]) && (RNG.flipCoin(0.5))) { indexSmallHyperCube = i; } } diff --git a/src/eva2/server/go/operators/archiving/RemoveSurplusIndividualsStaticHyperCube.java b/src/eva2/server/go/operators/archiving/RemoveSurplusIndividualsStaticHyperCube.java index 2e749aab..85f817c2 100644 --- a/src/eva2/server/go/operators/archiving/RemoveSurplusIndividualsStaticHyperCube.java +++ b/src/eva2/server/go/operators/archiving/RemoveSurplusIndividualsStaticHyperCube.java @@ -2,7 +2,7 @@ package eva2.server.go.operators.archiving; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This class removes surplus individuals based on bounding * hybercube, which can be calculated in objective or decision @@ -59,7 +59,7 @@ public class RemoveSurplusIndividualsStaticHyperCube extends RemoveSurplusIndivi indexSmallHyperCube = i; } else { // if they are equal give them a fair chance to exchange between them - if ((tmpS == smallestHyperCube) && (RandomNumberGenerator.flipCoin(0.5))) { + if ((tmpS == smallestHyperCube) && (RNG.flipCoin(0.5))) { smallestHyperCube = tmpS; indexSmallHyperCube = i; } diff --git a/src/eva2/server/go/operators/classification/ClassificationSelfOrganizingMaps.java b/src/eva2/server/go/operators/classification/ClassificationSelfOrganizingMaps.java index f530e766..91f90d93 100644 --- a/src/eva2/server/go/operators/classification/ClassificationSelfOrganizingMaps.java +++ b/src/eva2/server/go/operators/classification/ClassificationSelfOrganizingMaps.java @@ -3,7 +3,7 @@ package eva2.server.go.operators.classification; import javax.swing.*; import eva2.gui.Chart2DDPointIconCross; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import wsi.ra.chart2d.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; @@ -124,7 +124,7 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I for (int i = 0; i < this.m_SOM.length; i++) { for (int j = 0; j < this.m_SOM[0].length; j++) { for (int k = 0; k < this.m_SOM[0][0].length; k++) { - this.m_SOM[i][j][k] = 0*RandomNumberGenerator.randomDouble( + this.m_SOM[i][j][k] = 0*RNG.randomDouble( (this.m_Range[k][0] - this.m_Range[k][2])/(1+this.m_Range[k][3]), (this.m_Range[k][1] - this.m_Range[k][2])/(1+this.m_Range[k][3])); } @@ -155,7 +155,7 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I int[] winner; for (int t = 0; t < this.m_TrainingCycles; t++) { // train the full set - order = RandomNumberGenerator.randomPermutation(space.length); + order = RNG.randomPermutation(space.length); for (int i = 0; i < order.length; i++) { winner = this.findWinningNeuron(space[order[i]]); // now i got the winning neuron *puh* @@ -453,11 +453,11 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I double[][] data = new double[num*2][2]; int[] type = new int[num*2]; for (int i = 0; i < num; i++) { - data[i][0] = -0.8 + RandomNumberGenerator.gaussianDouble(0.3); - data[i][1] = -0.5 + RandomNumberGenerator.gaussianDouble(0.1); + data[i][0] = -0.8 + RNG.gaussianDouble(0.3); + data[i][1] = -0.5 + RNG.gaussianDouble(0.1); type[i] = 0; - data[i+num][0] = 0.1 + RandomNumberGenerator.gaussianDouble(0.1); - data[i+num][1] = 0.2 + RandomNumberGenerator.gaussianDouble(0.1); + data[i+num][0] = 0.1 + RNG.gaussianDouble(0.1); + data[i+num][1] = 0.2 + RNG.gaussianDouble(0.1); type[i+num] = 1; } som.init(data, type); diff --git a/src/eva2/server/go/operators/cluster/ClusteringKMeans.java b/src/eva2/server/go/operators/cluster/ClusteringKMeans.java index 5367ae93..32ec0cd3 100644 --- a/src/eva2/server/go/operators/cluster/ClusteringKMeans.java +++ b/src/eva2/server/go/operators/cluster/ClusteringKMeans.java @@ -9,7 +9,7 @@ import eva2.server.go.individuals.ESIndividualDoubleData; import eva2.server.go.individuals.InterfaceDataTypeDouble; import eva2.server.go.populations.Population; import eva2.server.go.problems.F1Problem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import wsi.ra.chart2d.DPoint; /** The k-mean clustering algorithms. I guess it is not a hierachical @@ -65,7 +65,7 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab this.m_C = new double[this.m_K][]; // now choose random initial Cs for (int i = 0; i < this.m_C.length; i++) { - this.m_C[i] = data[RandomNumberGenerator.randomInt(0, data.length-1)]; + this.m_C[i] = data[RNG.randomInt(0, data.length-1)]; //this.m_C[i] = data[i]; // This works!! // we won't check for double instances assuming that double instances // will be ironed out during clustering and to prevent infinite loops diff --git a/src/eva2/server/go/operators/cluster/ClusteringXMeans.java b/src/eva2/server/go/operators/cluster/ClusteringXMeans.java index 8e326daa..1c716272 100644 --- a/src/eva2/server/go/operators/cluster/ClusteringXMeans.java +++ b/src/eva2/server/go/operators/cluster/ClusteringXMeans.java @@ -9,7 +9,7 @@ import eva2.server.go.individuals.ESIndividualDoubleData; import eva2.server.go.individuals.InterfaceDataTypeDouble; import eva2.server.go.populations.Population; import eva2.server.go.problems.F1Problem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import wsi.ra.chart2d.DPoint; /** The x-means clustering method should be able to determine a @@ -285,28 +285,28 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab x = ((InterfaceDataTypeDouble)pop.get(i)).getDoubleData(); switch (i%k) { case 0 : { - x[0] = 0 + RandomNumberGenerator.gaussianDouble(1.2); - x[1] = -1 + RandomNumberGenerator.gaussianDouble(1.5); + x[0] = 0 + RNG.gaussianDouble(1.2); + x[1] = -1 + RNG.gaussianDouble(1.5); break; } case 1 : { - x[0] = 3 + RandomNumberGenerator.gaussianDouble(1.8); - x[1] = 8 + RandomNumberGenerator.gaussianDouble(0.9); + x[0] = 3 + RNG.gaussianDouble(1.8); + x[1] = 8 + RNG.gaussianDouble(0.9); break; } case 2 : { - x[0] = -4 + RandomNumberGenerator.gaussianDouble(1.2); - x[1] = -8 + RandomNumberGenerator.gaussianDouble(1.2); + x[0] = -4 + RNG.gaussianDouble(1.2); + x[1] = -8 + RNG.gaussianDouble(1.2); break; } case 3 : { - x[0] = 7 + RandomNumberGenerator.gaussianDouble(1.1); - x[1] = -5 + RandomNumberGenerator.gaussianDouble(1.0); + x[0] = 7 + RNG.gaussianDouble(1.1); + x[1] = -5 + RNG.gaussianDouble(1.0); break; } default : { - x[0] = -2 + RandomNumberGenerator.gaussianDouble(1.2); - x[1] = 5 + RandomNumberGenerator.gaussianDouble(1.2); + x[0] = -2 + RNG.gaussianDouble(1.2); + x[1] = 5 + RNG.gaussianDouble(1.2); } } if (i == 0) { diff --git a/src/eva2/server/go/operators/crossover/CrossoverEAMixer.java b/src/eva2/server/go/operators/crossover/CrossoverEAMixer.java index eecbfd14..4b9bc77d 100644 --- a/src/eva2/server/go/operators/crossover/CrossoverEAMixer.java +++ b/src/eva2/server/go/operators/crossover/CrossoverEAMixer.java @@ -6,7 +6,7 @@ import eva2.gui.GenericObjectEditor; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** @@ -119,7 +119,7 @@ public class CrossoverEAMixer implements InterfaceCrossover, java.io.Serializabl double[] probs = this.m_Crossers.getWeights(); if (this.m_UseSelfAdaption) { for (int i = 0; i < probs.length; i++) { - probs[i] = probs[i] * Math.exp(this.m_Tau1 * RandomNumberGenerator.gaussianDouble(1)); + probs[i] = probs[i] * Math.exp(this.m_Tau1 * RNG.gaussianDouble(1)); if (probs[i] <= this.m_LowerLimitChance) probs[i] = this.m_LowerLimitChance; if (probs[i] >= 1) probs[i] = 1; } @@ -127,14 +127,14 @@ public class CrossoverEAMixer implements InterfaceCrossover, java.io.Serializabl } InterfaceCrossover[] crossover = this.m_Crossers.getSelectedCrossers(); - double pointer = RandomNumberGenerator.randomFloat(0, 1); + double pointer = RNG.randomFloat(0, 1); double dum = probs[0]; int index = 0; while ((pointer > dum) && (index < probs.length-1)) { index++; dum += probs[index]; } - if (index == probs.length) index = RandomNumberGenerator.randomInt(0, probs.length-1); + if (index == probs.length) index = RNG.randomInt(0, probs.length-1); // System.out.println("Using : " + mutators[index].getStringRepresentation()); // for (int i = 0; i < probs.length; i++) { // System.out.println(""+mutators[i].getStringRepresentation()+" : "+ probs[i]); diff --git a/src/eva2/server/go/operators/crossover/CrossoverESArithmetical.java b/src/eva2/server/go/operators/crossover/CrossoverESArithmetical.java index e04b7289..4bdfad3f 100644 --- a/src/eva2/server/go/operators/crossover/CrossoverESArithmetical.java +++ b/src/eva2/server/go/operators/crossover/CrossoverESArithmetical.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -61,7 +61,7 @@ public class CrossoverESArithmetical implements InterfaceCrossover, java.io.Seri for (int i = 0; i < children.length; i++) { sum = 0; for (int j = 0; j < alpha.length; j++) { - alpha[j] = RandomNumberGenerator.randomDouble(0,1); + alpha[j] = RNG.randomDouble(0,1); sum += alpha[j]; } for (int j = 0; j i) && (tmpInts[1][j].length > i)) { diff --git a/src/eva2/server/go/operators/crossover/CrossoverGPDefault.java b/src/eva2/server/go/operators/crossover/CrossoverGPDefault.java index acbb9e8a..e2a7ea8d 100644 --- a/src/eva2/server/go/operators/crossover/CrossoverGPDefault.java +++ b/src/eva2/server/go/operators/crossover/CrossoverGPDefault.java @@ -8,7 +8,7 @@ import eva2.server.go.individuals.InterfaceGPIndividual; import eva2.server.go.individuals.codings.gp.AbstractGPNode; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -53,7 +53,7 @@ public class CrossoverGPDefault implements InterfaceCrossover, java.io.Serializa for (int t = 0; t < nodes.length; t++) { allNodes = new ArrayList(); ((InterfaceGPIndividual)result[0]).getPGenotype()[t].addNodesTo(allNodes); - AbstractGPNode oldNode = (AbstractGPNode) allNodes.get(RandomNumberGenerator.randomInt(0, allNodes.size()-1)); + AbstractGPNode oldNode = (AbstractGPNode) allNodes.get(RNG.randomInt(0, allNodes.size()-1)); AbstractGPNode newNode, memorizingNode = oldNode, tmpNode; AbstractGPNode oldParent, newParent; oldParent = oldNode.getParent(); @@ -61,7 +61,7 @@ public class CrossoverGPDefault implements InterfaceCrossover, java.io.Serializa // choose Node from i and add it to i-1 allNodes = new ArrayList(); ((InterfaceGPIndividual)result[i]).getPGenotype()[t].addNodesTo(allNodes); - newNode = (AbstractGPNode) allNodes.get(RandomNumberGenerator.randomInt(0, allNodes.size()-1)); + newNode = (AbstractGPNode) allNodes.get(RNG.randomInt(0, allNodes.size()-1)); tmpNode = newNode; newParent = tmpNode.getParent(); if (oldParent == null) ((InterfaceGPIndividual)result[i-1]).SetPGenotype(newNode, t); diff --git a/src/eva2/server/go/operators/crossover/CrossoverOBGAPMX.java b/src/eva2/server/go/operators/crossover/CrossoverOBGAPMX.java index 27a006d0..cd07e27b 100644 --- a/src/eva2/server/go/operators/crossover/CrossoverOBGAPMX.java +++ b/src/eva2/server/go/operators/crossover/CrossoverOBGAPMX.java @@ -6,7 +6,7 @@ import eva2.server.go.individuals.InterfaceOBGAIndividual; import eva2.server.go.operators.crossover.InterfaceCrossover; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** *

Title: The JavaEvA

@@ -47,8 +47,8 @@ public class CrossoverOBGAPMX implements InterfaceCrossover, java.io.Serializabl int[] perm1 = (int[])((InterfaceOBGAIndividual) result[0]).getOBGenotype()[i].clone(); int[] perm2 = (int[])((InterfaceOBGAIndividual) result[1]).getOBGenotype()[i].clone(); - int begin = RandomNumberGenerator.randomInt(0,perm1.length-2); - int end = RandomNumberGenerator.randomInt(begin,perm1.length-1); + int begin = RNG.randomInt(0,perm1.length-2); + int end = RNG.randomInt(begin,perm1.length-1); for (int pos = begin; pos <= end; pos++) { int crosspoint = pos; int p1inp2 = 0; diff --git a/src/eva2/server/go/operators/crossover/CrossoverOBGAPMXUniform.java b/src/eva2/server/go/operators/crossover/CrossoverOBGAPMXUniform.java index 38763ea5..c8a11aa7 100644 --- a/src/eva2/server/go/operators/crossover/CrossoverOBGAPMXUniform.java +++ b/src/eva2/server/go/operators/crossover/CrossoverOBGAPMXUniform.java @@ -5,7 +5,7 @@ import eva2.server.go.individuals.InterfaceOBGAIndividual; import eva2.server.go.operators.crossover.InterfaceCrossover; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** *

Title: The JavaEvA

@@ -47,10 +47,10 @@ public class CrossoverOBGAPMXUniform implements InterfaceCrossover, java.io.Seri int[] perm1 = (int[])((InterfaceOBGAIndividual) result[0]).getOBGenotype()[i].clone(); int[] perm2 = (int[])((InterfaceOBGAIndividual) result[1]).getOBGenotype()[i].clone(); - int crossnumber = RandomNumberGenerator.randomInt(1, perm1.length); + int crossnumber = RNG.randomInt(1, perm1.length); for (int iter = 0; iter < crossnumber; iter++) { - int crosspoint = RandomNumberGenerator.randomInt(0, perm1.length - 1); + int crosspoint = RNG.randomInt(0, perm1.length - 1); int p1inp2 = 0; int p2inp1 = 0; while (perm1[p2inp1] != perm2[crosspoint]) p2inp1++; diff --git a/src/eva2/server/go/operators/moso/MOSOMaxiMin.java b/src/eva2/server/go/operators/moso/MOSOMaxiMin.java index 7630c8e2..ee403071 100644 --- a/src/eva2/server/go/operators/moso/MOSOMaxiMin.java +++ b/src/eva2/server/go/operators/moso/MOSOMaxiMin.java @@ -5,7 +5,7 @@ import eva2.gui.Chart2DDPointIconText; import eva2.gui.GraphPointSet; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import wsi.ra.chart2d.DPoint; /** @@ -109,7 +109,7 @@ public class MOSOMaxiMin implements InterfaceMOSOConverter, java.io.Serializable tmpFit = indy.getFitness(); indy.SetData("MOFitness", tmpFit); System.out.println("The MaxiMin MOSO can not be applied to single individuals! I default to random criteria."); - resultFit[0] = tmpFit[RandomNumberGenerator.randomInt(0, tmpFit.length)]; + resultFit[0] = tmpFit[RNG.randomInt(0, tmpFit.length)]; indy.SetFitness(resultFit); } diff --git a/src/eva2/server/go/operators/moso/MOSONoConvert.java b/src/eva2/server/go/operators/moso/MOSONoConvert.java index 1a124f83..9c84924f 100644 --- a/src/eva2/server/go/operators/moso/MOSONoConvert.java +++ b/src/eva2/server/go/operators/moso/MOSONoConvert.java @@ -2,7 +2,7 @@ package eva2.server.go.operators.moso; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -42,7 +42,7 @@ public class MOSONoConvert implements InterfaceMOSOConverter, java.io.Serializab tmpFit = indy.getFitness(); indy.SetData("MOFitness", tmpFit); -// resultFit[0] = tmpFit[RandomNumberGenerator.randomInt(0, tmpFit.length)]; +// resultFit[0] = tmpFit[RNG.randomInt(0, tmpFit.length)]; // indy.SetFitness(resultFit); } diff --git a/src/eva2/server/go/operators/moso/MOSORandomChoice.java b/src/eva2/server/go/operators/moso/MOSORandomChoice.java index 56c46223..f0ae1a44 100644 --- a/src/eva2/server/go/operators/moso/MOSORandomChoice.java +++ b/src/eva2/server/go/operators/moso/MOSORandomChoice.java @@ -2,7 +2,7 @@ package eva2.server.go.operators.moso; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -46,7 +46,7 @@ public class MOSORandomChoice implements InterfaceMOSOConverter, java.io.Serial tmpFit = indy.getFitness(); indy.SetData("MOFitness", tmpFit); - resultFit[0] = tmpFit[RandomNumberGenerator.randomInt(0, tmpFit.length-1)]; + resultFit[0] = tmpFit[RNG.randomInt(0, tmpFit.length-1)]; indy.SetFitness(resultFit); } diff --git a/src/eva2/server/go/operators/moso/MOSORandomWeight.java b/src/eva2/server/go/operators/moso/MOSORandomWeight.java index d4614dd0..9dfe0e83 100644 --- a/src/eva2/server/go/operators/moso/MOSORandomWeight.java +++ b/src/eva2/server/go/operators/moso/MOSORandomWeight.java @@ -3,7 +3,7 @@ package eva2.server.go.operators.moso; import eva2.gui.PropertyDoubleArray; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -47,7 +47,7 @@ public class MOSORandomWeight implements InterfaceMOSOConverter, java.io.Seriali indy.SetData("MOFitness", tmpFit); tmpWeight = new double[tmpFit.length]; for (int i = 0; i < tmpWeight.length; i++) { - tmpWeight[i] = RandomNumberGenerator.randomDouble(0,1); + tmpWeight[i] = RNG.randomDouble(0,1); sum += tmpWeight[i]; } if (sum <= 0.0000001) { diff --git a/src/eva2/server/go/operators/moso/MOSORankbased.java b/src/eva2/server/go/operators/moso/MOSORankbased.java index 8b8963da..4f071e1b 100644 --- a/src/eva2/server/go/operators/moso/MOSORankbased.java +++ b/src/eva2/server/go/operators/moso/MOSORankbased.java @@ -3,7 +3,7 @@ package eva2.server.go.operators.moso; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.operators.archiving.ArchivingNSGAII; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. diff --git a/src/eva2/server/go/operators/mutation/MutateEAMixer.java b/src/eva2/server/go/operators/mutation/MutateEAMixer.java index 25ed7ba0..666e4ed5 100644 --- a/src/eva2/server/go/operators/mutation/MutateEAMixer.java +++ b/src/eva2/server/go/operators/mutation/MutateEAMixer.java @@ -6,7 +6,7 @@ import eva2.gui.GenericObjectEditor; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** @@ -118,7 +118,7 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { double[] probs = this.m_Mutators.getWeights(); if (this.m_UseSelfAdaption) { for (int i = 0; i < probs.length; i++) { - probs[i] = probs[i] * Math.exp(this.m_Tau1 * RandomNumberGenerator.gaussianDouble(1)); + probs[i] = probs[i] * Math.exp(this.m_Tau1 * RNG.gaussianDouble(1)); if (probs[i] <= this.m_LowerLimitChance) probs[i] = this.m_LowerLimitChance; if (probs[i] >= 1) probs[i] = 1; } @@ -126,14 +126,14 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable { } InterfaceMutation[] mutators = this.m_Mutators.getSelectedMutators(); - double pointer = RandomNumberGenerator.randomFloat(0, 1); + double pointer = RNG.randomFloat(0, 1); double dum = probs[0]; int index = 0; while ((pointer > dum) && (index < probs.length-1)) { index++; dum += probs[index]; } - if (index == probs.length) index = RandomNumberGenerator.randomInt(0, probs.length-1); + if (index == probs.length) index = RNG.randomInt(0, probs.length-1); //System.out.println("Using : " + mutators[index].getStringRepresentation()); // for (int i = 0; i < probs.length; i++) { // System.out.println(""+mutators[i].getStringRepresentation()+" : "+ probs[i]); diff --git a/src/eva2/server/go/operators/mutation/MutateESCorrolated.java b/src/eva2/server/go/operators/mutation/MutateESCorrolated.java index 77b4887d..ba91423b 100644 --- a/src/eva2/server/go/operators/mutation/MutateESCorrolated.java +++ b/src/eva2/server/go/operators/mutation/MutateESCorrolated.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -97,7 +97,7 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab // double[] x = ((InterfaceESIndividual)individual).getDGenotype(); // double[] xCopy = ((InterfaceESIndividual)individual).getDGenotype(); // double[][] range = ((InterfaceESIndividual)individual).getDoubleRange(); -// double tmpR = RandomNumberGenerator.gaussianDouble(1); +// double tmpR = RNG.gaussianDouble(1); // if (this.m_Sigmas == null) { // // init the Sigmas // this.m_Sigmas = new double[x.length]; @@ -106,7 +106,7 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab // // //Mutate Sigmas // for (int i = 0; i < x.length; i++) { -// this.m_Sigmas[i] = this.m_Sigmas[i] * Math.exp(this.m_Tau1 * tmpR + this.m_Tau2 * RandomNumberGenerator.gaussianDouble(1)); +// this.m_Sigmas[i] = this.m_Sigmas[i] * Math.exp(this.m_Tau1 * tmpR + this.m_Tau2 * RNG.gaussianDouble(1)); // if (this.m_Sigmas[i] < this.m_LowerLimitStepSize) this.m_Sigmas[i] = this.m_LowerLimitStepSize; // } // @@ -118,14 +118,14 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab // //// //Mutate Alphas //// for (int i = 0; i < this.m_Alphas.length; i++) { -//// this.m_Alphas[i] = this.m_Alphas[i] + RandomNumberGenerator.gaussianDouble(0.01); +//// this.m_Alphas[i] = this.m_Alphas[i] + RNG.gaussianDouble(0.01); //// if (this.m_Alphas[i] < -m_PI/2) this.m_Alphas[i] = -m_PI/2; //// if (this.m_Alphas[i] > m_PI/2) this.m_Alphas[i] = m_PI/2; //// } // // //Generate mutationvector in unitspace modified by sigmas // for (int i = 0; i < x.length; i++) { -// xCopy[i] = RandomNumberGenerator.gaussianDouble(this.m_Sigmas[i]); +// xCopy[i] = RNG.gaussianDouble(this.m_Sigmas[i]); // } // // //modify genotype @@ -156,7 +156,7 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab double[] x = ((InterfaceESIndividual)individual).getDGenotype(); double[] xCopy = new double[x.length]; double[][] range = ((InterfaceESIndividual)individual).getDoubleRange(); - double tmpR = RandomNumberGenerator.gaussianDouble(1); + double tmpR = RNG.gaussianDouble(1); if (this.m_Sigmas == null) { // init the Sigmas @@ -165,7 +165,7 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab } //Mutate Sigmas for (int i = 0; i < x.length; i++) { - this.m_Sigmas[i] = this.m_Sigmas[i] * Math.exp(this.m_Tau1 * tmpR + this.m_Tau2 * RandomNumberGenerator.gaussianDouble(1)); + this.m_Sigmas[i] = this.m_Sigmas[i] * Math.exp(this.m_Tau1 * tmpR + this.m_Tau2 * RNG.gaussianDouble(1)); if (this.m_Sigmas[i] < this.m_LowerLimitStepSize) this.m_Sigmas[i] = this.m_LowerLimitStepSize; } @@ -176,14 +176,14 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab } //Mutate Alphas for (int i = 0; i < this.m_Alphas.length; i++) { - this.m_Alphas[i] = this.m_Alphas[i] + RandomNumberGenerator.gaussianDouble(0.2); + this.m_Alphas[i] = this.m_Alphas[i] + RNG.gaussianDouble(0.2); if (this.m_Alphas[i] < -Math.PI/2) this.m_Alphas[i] = -Math.PI/2; if (this.m_Alphas[i] > Math.PI/2) this.m_Alphas[i] = Math.PI/2; } //Generate mutationvector in unitspace modified by sigmas for (int i = 0; i < x.length; i++) { - xCopy[i] = RandomNumberGenerator.gaussianDouble(this.m_Sigmas[i]); + xCopy[i] = RNG.gaussianDouble(this.m_Sigmas[i]); } //turn mutationvector with alphas diff --git a/src/eva2/server/go/operators/mutation/MutateESCovarianceMartixAdaption.java b/src/eva2/server/go/operators/mutation/MutateESCovarianceMartixAdaption.java index 9b31b3ee..1c6f1919 100644 --- a/src/eva2/server/go/operators/mutation/MutateESCovarianceMartixAdaption.java +++ b/src/eva2/server/go/operators/mutation/MutateESCovarianceMartixAdaption.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import wsi.ra.math.Jama.EigenvalueDecomposition; import wsi.ra.math.Jama.Matrix; @@ -183,7 +183,7 @@ public class MutateESCovarianceMartixAdaption implements InterfaceMutation, java // if (Double.isNaN((x[0]))) System.out.println("treffer in cma "+ x[0]); // if (Double.isNaN((m_C.get(0,0)))) System.out.println("treffer in cma"); // for (int i=0;i range[i][1]) { for (int j = 0; j < this.m_D; j++) x[j] = x[j] - this.m_SigmaGlobal * this.Bz[j]; - this.m_Z[i] = RandomNumberGenerator.gaussianDouble(1.0); + this.m_Z[i] = RNG.gaussianDouble(1.0); constraint = false; counter++; break; diff --git a/src/eva2/server/go/operators/mutation/MutateESDerandomized.java b/src/eva2/server/go/operators/mutation/MutateESDerandomized.java index 39ba851e..083f147d 100644 --- a/src/eva2/server/go/operators/mutation/MutateESDerandomized.java +++ b/src/eva2/server/go/operators/mutation/MutateESDerandomized.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -74,7 +74,7 @@ public class MutateESDerandomized implements InterfaceMutation, java.io.Serializ else this.m_c = 1.0; this.m_Z = new double[this.m_D]; this.m_Path = new double[this.m_D]; - for (int i = 0; i < this.m_D; i++) this.m_Z[i] = RandomNumberGenerator.gaussianDouble(1.0); + for (int i = 0; i < this.m_D; i++) this.m_Z[i] = RNG.gaussianDouble(1.0); evaluateNewObjectX(x, ranges); } @@ -88,7 +88,7 @@ public class MutateESDerandomized implements InterfaceMutation, java.io.Serializ double[] x = ((InterfaceESIndividual)individual).getDGenotype(); double[][] ranges = ((InterfaceESIndividual)individual).getDoubleRange(); this.adaptStrategy(); - for (int i = 0; i < m_D; i++) m_Z[i] = RandomNumberGenerator.gaussianDouble(1.0); + for (int i = 0; i < m_D; i++) m_Z[i] = RNG.gaussianDouble(1.0); this.evaluateNewObjectX(x, ranges); for (int i = 0; i < x.length; i++) { if (x[i] < ranges[i][0]) x[i] = ranges[i][0]; diff --git a/src/eva2/server/go/operators/mutation/MutateESFixedStepSize.java b/src/eva2/server/go/operators/mutation/MutateESFixedStepSize.java index a56b2d60..980a6510 100644 --- a/src/eva2/server/go/operators/mutation/MutateESFixedStepSize.java +++ b/src/eva2/server/go/operators/mutation/MutateESFixedStepSize.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -65,7 +65,7 @@ public class MutateESFixedStepSize implements InterfaceMutation, java.io.Seriali double[] x = ((InterfaceESIndividual)individual).getDGenotype(); double[][] range = ((InterfaceESIndividual)individual).getDoubleRange(); for (int i = 0; i < x.length; i++) { - x[i] += ((range[i][1] -range[i][0])/2)*RandomNumberGenerator.gaussianDouble(this.m_Sigma); + x[i] += ((range[i][1] -range[i][0])/2)*RNG.gaussianDouble(this.m_Sigma); if (range[i][0] > x[i]) x[i] = range[i][0]; if (range[i][1] < x[i]) x[i] = range[i][1]; } diff --git a/src/eva2/server/go/operators/mutation/MutateESGlobal.java b/src/eva2/server/go/operators/mutation/MutateESGlobal.java index a512ff1d..f39d408a 100644 --- a/src/eva2/server/go/operators/mutation/MutateESGlobal.java +++ b/src/eva2/server/go/operators/mutation/MutateESGlobal.java @@ -6,7 +6,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import eva2.tools.SelectedTag; @@ -81,10 +81,10 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable { if (individual instanceof InterfaceESIndividual) { double[] x = ((InterfaceESIndividual)individual).getDGenotype(); double[][] range = ((InterfaceESIndividual)individual).getDoubleRange(); - this.m_MutationStepSize = this.m_MutationStepSize * Math.exp(this.m_Tau1 * RandomNumberGenerator.gaussianDouble(1)); + this.m_MutationStepSize = this.m_MutationStepSize * Math.exp(this.m_Tau1 * RNG.gaussianDouble(1)); if (this.m_MutationStepSize < this.m_LowerLimitStepSize) this.m_MutationStepSize = this.m_LowerLimitStepSize; for (int i = 0; i < x.length; i++) { - x[i] += ((range[i][1] -range[i][0])/2)*RandomNumberGenerator.gaussianDouble(this.m_MutationStepSize); + x[i] += ((range[i][1] -range[i][0])/2)*RNG.gaussianDouble(this.m_MutationStepSize); if (range[i][0] > x[i]) x[i] = range[i][0]; if (range[i][1] < x[i]) x[i] = range[i][1]; } @@ -116,7 +116,7 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable { break; } case 2 : { - this.m_MutationStepSize = list[RandomNumberGenerator.randomInt(0, list.length-1)]; + this.m_MutationStepSize = list[RNG.randomInt(0, list.length-1)]; break; } default : { diff --git a/src/eva2/server/go/operators/mutation/MutateESLocal.java b/src/eva2/server/go/operators/mutation/MutateESLocal.java index 90c5f238..865c0bee 100644 --- a/src/eva2/server/go/operators/mutation/MutateESLocal.java +++ b/src/eva2/server/go/operators/mutation/MutateESLocal.java @@ -8,7 +8,7 @@ import eva2.server.go.individuals.InterfaceDataTypeDouble; import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import eva2.tools.SelectedTag; import eva2.tools.Tag; @@ -99,12 +99,12 @@ public class MutateESLocal implements InterfaceMutation, java.io.Serializable { if (individual instanceof InterfaceESIndividual) { double[] x = ((InterfaceESIndividual)individual).getDGenotype(); double[][] range = ((InterfaceESIndividual)individual).getDoubleRange(); - double tmpR = RandomNumberGenerator.gaussianDouble(1); + double tmpR = RNG.gaussianDouble(1); for (int i = 0; i < x.length; i++) { - this.m_Sigmas[i] = this.m_Sigmas[i] * Math.exp(this.m_Tau1 * tmpR + this.m_Tau2 * RandomNumberGenerator.gaussianDouble(1)); + this.m_Sigmas[i] = this.m_Sigmas[i] * Math.exp(this.m_Tau1 * tmpR + this.m_Tau2 * RNG.gaussianDouble(1)); if (this.m_Sigmas[i] < this.m_LowerLimitStepSize) this.m_Sigmas[i] = this.m_LowerLimitStepSize; - x[i] += ((range[i][1] -range[i][0])/2)*RandomNumberGenerator.gaussianDouble(this.m_Sigmas[i]); + x[i] += ((range[i][1] -range[i][0])/2)*RNG.gaussianDouble(this.m_Sigmas[i]); if (range[i][0] > x[i]) x[i] = range[i][0]; if (range[i][1] < x[i]) x[i] = range[i][1]; } @@ -151,10 +151,10 @@ public class MutateESLocal implements InterfaceMutation, java.io.Serializable { break; } case 2 : { - int rn = RandomNumberGenerator.randomInt(0, listA.length-1); + int rn = RNG.randomInt(0, listA.length-1); this.m_MutationStepSize = listA[rn]; for (int i = 0; i < this.m_Sigmas.length; i++) { - rn = RandomNumberGenerator.randomInt(0, listA.length-1); + rn = RNG.randomInt(0, listA.length-1); this.m_Sigmas[i] = listB[rn][i]; } break; diff --git a/src/eva2/server/go/operators/mutation/MutateESMainVectorAdaption.java b/src/eva2/server/go/operators/mutation/MutateESMainVectorAdaption.java index e3e0c93b..83e11b89 100644 --- a/src/eva2/server/go/operators/mutation/MutateESMainVectorAdaption.java +++ b/src/eva2/server/go/operators/mutation/MutateESMainVectorAdaption.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -98,8 +98,8 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se this.m_main_v[i] = 0; }; this.xi_dach = Math.sqrt(this.N - 0.5); - for (int i = 0; i < this.N; i++) this.m_Z[i] = RandomNumberGenerator.gaussianDouble(1.0); - this.Z1 = RandomNumberGenerator.gaussianDouble(1.0); + for (int i = 0; i < this.N; i++) this.m_Z[i] = RNG.gaussianDouble(1.0); + this.Z1 = RNG.gaussianDouble(1.0); evaluateNewObjectX(x, ranges); } @@ -113,8 +113,8 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se double[] x = ((InterfaceESIndividual)individual).getDGenotype(); double[][] ranges = ((InterfaceESIndividual)individual).getDoubleRange(); this.adaptStrategy(); - for (int i = 0; i < N; i++) m_Z[i] = RandomNumberGenerator.gaussianDouble(1.0); - Z1 = RandomNumberGenerator.gaussianDouble(1.0); + for (int i = 0; i < N; i++) m_Z[i] = RNG.gaussianDouble(1.0); + Z1 = RNG.gaussianDouble(1.0); evaluateNewObjectX(x, ranges); ((InterfaceESIndividual)individual).SetDGenotype(x); diff --git a/src/eva2/server/go/operators/mutation/MutateESMutativeStepSizeControl.java b/src/eva2/server/go/operators/mutation/MutateESMutativeStepSizeControl.java index 103399aa..e42da7b2 100644 --- a/src/eva2/server/go/operators/mutation/MutateESMutativeStepSizeControl.java +++ b/src/eva2/server/go/operators/mutation/MutateESMutativeStepSizeControl.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -65,13 +65,13 @@ public class MutateESMutativeStepSizeControl implements InterfaceMutation, java. if (individual instanceof InterfaceESIndividual) { double[] x = ((InterfaceESIndividual)individual).getDGenotype(); double[][] range = ((InterfaceESIndividual)individual).getDoubleRange(); - if (RandomNumberGenerator.flipCoin(0.5)) + if (RNG.flipCoin(0.5)) this.m_MutationStepSize = this.m_MutationStepSize * this.m_Alpha; else this.m_MutationStepSize = this.m_MutationStepSize / this.m_Alpha; if (this.m_MutationStepSize < this.m_LowerLimitStepSize) this.m_MutationStepSize = this.m_LowerLimitStepSize; for (int i = 0; i < x.length; i++) { - x[i] += ((range[i][1] -range[i][0])/2)*RandomNumberGenerator.gaussianDouble(this.m_MutationStepSize); + x[i] += ((range[i][1] -range[i][0])/2)*RNG.gaussianDouble(this.m_MutationStepSize); if (range[i][0] > x[i]) x[i] = range[i][0]; if (range[i][1] < x[i]) x[i] = range[i][1]; } diff --git a/src/eva2/server/go/operators/mutation/MutateESStandard.java b/src/eva2/server/go/operators/mutation/MutateESStandard.java index 7a16db68..d37aad00 100644 --- a/src/eva2/server/go/operators/mutation/MutateESStandard.java +++ b/src/eva2/server/go/operators/mutation/MutateESStandard.java @@ -5,7 +5,7 @@ import eva2.server.go.individuals.InterfaceDataTypeDouble; import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -61,7 +61,7 @@ public class MutateESStandard implements InterfaceMutation, java.io.Serializable double[] x = ((InterfaceESIndividual)individual).getDGenotype(); double[][] range = ((InterfaceESIndividual)individual).getDoubleRange(); for (int i = 0; i < x.length; i++) { - x[i] += ((range[i][1] -range[i][0])/2)*RandomNumberGenerator.gaussianDouble(this.m_MutationStepSize); + x[i] += ((range[i][1] -range[i][0])/2)*RNG.gaussianDouble(this.m_MutationStepSize); if (range[i][0] > x[i]) x[i] = range[i][0]; if (range[i][1] < x[i]) x[i] = range[i][1]; } diff --git a/src/eva2/server/go/operators/mutation/MutateESSuccessRule.java b/src/eva2/server/go/operators/mutation/MutateESSuccessRule.java index c781f472..8cae281a 100644 --- a/src/eva2/server/go/operators/mutation/MutateESSuccessRule.java +++ b/src/eva2/server/go/operators/mutation/MutateESSuccessRule.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -70,7 +70,7 @@ public class MutateESSuccessRule implements InterfaceMutation, java.io.Serializa double[] x = ((InterfaceESIndividual)individual).getDGenotype(); double[][] range = ((InterfaceESIndividual)individual).getDoubleRange(); for (int i = 0; i < x.length; i++) { - x[i] += ((range[i][1] -range[i][0])/2)*RandomNumberGenerator.gaussianDouble(this.m_MutationStepSize); + x[i] += ((range[i][1] -range[i][0])/2)*RNG.gaussianDouble(this.m_MutationStepSize); if (range[i][0] > x[i]) x[i] = range[i][0]; if (range[i][1] < x[i]) x[i] = range[i][1]; } diff --git a/src/eva2/server/go/operators/mutation/MutateGAAdaptive.java b/src/eva2/server/go/operators/mutation/MutateGAAdaptive.java index 8b1e9f9c..1d1ee254 100644 --- a/src/eva2/server/go/operators/mutation/MutateGAAdaptive.java +++ b/src/eva2/server/go/operators/mutation/MutateGAAdaptive.java @@ -7,7 +7,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceGAIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * The mutation probability is adapted using a parameter tau and stored in the individual. @@ -71,10 +71,10 @@ public class MutateGAAdaptive implements InterfaceMutation, java.io.Serializable //System.out.println("Before Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); if (individual instanceof InterfaceGAIndividual) { BitSet tmpBitSet = ((InterfaceGAIndividual)individual).getBGenotype(); - this.m_MutationStep = this.m_MutationStep * Math.exp(this.m_Tau1 * RandomNumberGenerator.gaussianDouble(1)); + this.m_MutationStep = this.m_MutationStep * Math.exp(this.m_Tau1 * RNG.gaussianDouble(1)); if (this.m_MutationStep < this.m_LowerLimitStepSize) this.m_MutationStep = this.m_LowerLimitStepSize; for (int i = 0; i < ((InterfaceGAIndividual)individual).getGenotypeLength(); i++) { - if (RandomNumberGenerator.flipCoin(this.m_MutationStep/((InterfaceGAIndividual)individual).getGenotypeLength())) { + if (RNG.flipCoin(this.m_MutationStep/((InterfaceGAIndividual)individual).getGenotypeLength())) { tmpBitSet.flip(i); } } diff --git a/src/eva2/server/go/operators/mutation/MutateGAInvertBits.java b/src/eva2/server/go/operators/mutation/MutateGAInvertBits.java index 6b1b2522..916e865e 100644 --- a/src/eva2/server/go/operators/mutation/MutateGAInvertBits.java +++ b/src/eva2/server/go/operators/mutation/MutateGAInvertBits.java @@ -7,7 +7,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceGAIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -67,8 +67,8 @@ public class MutateGAInvertBits implements InterfaceMutation, java.io.Serializab BitSet tmpBitSet = ((InterfaceGAIndividual)individual).getBGenotype(); int[][] mutationIndices = new int[this.m_NumberOfMutations][2]; for (int i = 0; i < mutationIndices.length; i++) { - mutationIndices[i][0] = RandomNumberGenerator.randomInt(0, ((InterfaceGAIndividual)individual).getGenotypeLength());; - mutationIndices[i][1] = RandomNumberGenerator.randomInt(0, this.m_MaxInveredBits);; + mutationIndices[i][0] = RNG.randomInt(0, ((InterfaceGAIndividual)individual).getGenotypeLength());; + mutationIndices[i][1] = RNG.randomInt(0, this.m_MaxInveredBits);; } // double instances of mutationIndices could be checked here... *sigh* for (int i = 0; i < mutationIndices.length; i++) { diff --git a/src/eva2/server/go/operators/mutation/MutateGAStandard.java b/src/eva2/server/go/operators/mutation/MutateGAStandard.java index 73842741..f5e85a98 100644 --- a/src/eva2/server/go/operators/mutation/MutateGAStandard.java +++ b/src/eva2/server/go/operators/mutation/MutateGAStandard.java @@ -7,7 +7,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceGAIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -62,7 +62,7 @@ public class MutateGAStandard implements InterfaceMutation, java.io.Serializable if (individual instanceof InterfaceGAIndividual) { BitSet tmpBitSet = ((InterfaceGAIndividual)individual).getBGenotype(); int[] mutationIndices = new int[this.m_NumberOfMutations]; - for (int i = 0; i < mutationIndices.length; i++) mutationIndices[i] = RandomNumberGenerator.randomInt(0, ((InterfaceGAIndividual)individual).getGenotypeLength());; + for (int i = 0; i < mutationIndices.length; i++) mutationIndices[i] = RNG.randomInt(0, ((InterfaceGAIndividual)individual).getGenotypeLength());; // double instances of mutationIndices could be checked here... *sigh* for (int i = 0; i < mutationIndices.length; i++) { tmpBitSet.flip(mutationIndices[i]); diff --git a/src/eva2/server/go/operators/mutation/MutateGASwapBits.java b/src/eva2/server/go/operators/mutation/MutateGASwapBits.java index 14c3fc3f..c001cc31 100644 --- a/src/eva2/server/go/operators/mutation/MutateGASwapBits.java +++ b/src/eva2/server/go/operators/mutation/MutateGASwapBits.java @@ -7,7 +7,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceGAIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -73,8 +73,8 @@ public class MutateGASwapBits implements InterfaceMutation, java.io.Serializable int[][] mutationIndices = new int[this.m_NumberOfMutations][2]; boolean tmpBit; for (int i = 0; i < mutationIndices.length; i++) { - mutationIndices[i][0] = RandomNumberGenerator.randomInt(0, ((InterfaceGAIndividual)individual).getGenotypeLength());; - mutationIndices[i][1] = RandomNumberGenerator.randomInt(0, ((InterfaceGAIndividual)individual).getGenotypeLength());; + mutationIndices[i][0] = RNG.randomInt(0, ((InterfaceGAIndividual)individual).getGenotypeLength());; + mutationIndices[i][1] = RNG.randomInt(0, ((InterfaceGAIndividual)individual).getGenotypeLength());; } // double instances of mutationIndices could be checked here... *sigh* for (int i = 0; i < mutationIndices.length; i++) { diff --git a/src/eva2/server/go/operators/mutation/MutateGIInsertDelete.java b/src/eva2/server/go/operators/mutation/MutateGIInsertDelete.java index 05cda601..6eac2fe7 100644 --- a/src/eva2/server/go/operators/mutation/MutateGIInsertDelete.java +++ b/src/eva2/server/go/operators/mutation/MutateGIInsertDelete.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceGIIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -73,12 +73,12 @@ public class MutateGIInsertDelete implements InterfaceMutation, java.io.Serializ int[][] newRange; int length, position; //this.pintInt("Before ", x); - length = RandomNumberGenerator.randomInt(1, this.m_MaxLengthOfInsDel); - boolean insert = RandomNumberGenerator.flipCoin(0.5); + length = RNG.randomInt(1, this.m_MaxLengthOfInsDel); + boolean insert = RNG.flipCoin(0.5); if ((!insert) && (length >= x.length-1)) insert = true; if (insert) { // insert - position = RandomNumberGenerator.randomInt(0, x.length-1); + position = RNG.randomInt(0, x.length-1); newX = new int[x.length + length]; newRange = new int[range.length + length][2]; for (int i = 0; i < position; i++) { @@ -86,7 +86,7 @@ public class MutateGIInsertDelete implements InterfaceMutation, java.io.Serializ newRange[i] = range[i]; } for (int i = position; i < position+length; i++) { - newX[i] = RandomNumberGenerator.randomInt(range[position][0], range[position][1]); + newX[i] = RNG.randomInt(range[position][0], range[position][1]); newRange[i][0] = range[position][0]; newRange[i][1] = range[position][1]; } @@ -96,7 +96,7 @@ public class MutateGIInsertDelete implements InterfaceMutation, java.io.Serializ } } else { // delete - position = RandomNumberGenerator.randomInt(0, x.length-1-length); + position = RNG.randomInt(0, x.length-1-length); newX = new int[x.length - length]; newRange = new int[range.length - length][2]; if (newX.length <=1) return; diff --git a/src/eva2/server/go/operators/mutation/MutateGIInvert.java b/src/eva2/server/go/operators/mutation/MutateGIInvert.java index 4daaa58b..8314222c 100644 --- a/src/eva2/server/go/operators/mutation/MutateGIInvert.java +++ b/src/eva2/server/go/operators/mutation/MutateGIInvert.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceGIIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -61,9 +61,9 @@ public class MutateGIInvert implements InterfaceMutation, java.io.Serializable { int[] x = ((InterfaceGIIndividual)individual).getIGenotype(); int range, center, index = 0; //this.pintInt("Before ", x); - range = RandomNumberGenerator.randomInt(1, this.m_MaxLengthOfInvert); + range = RNG.randomInt(1, this.m_MaxLengthOfInvert); if (2*range >= x.length) return; - center = RandomNumberGenerator.randomInt(0+range, x.length-1-range); + center = RNG.randomInt(0+range, x.length-1-range); //System.out.println("Range: " + range + " Center: " + center); int[] tmp = new int[x.length]; System.arraycopy(x, 0, tmp, 0, x.length); diff --git a/src/eva2/server/go/operators/mutation/MutateGINominal.java b/src/eva2/server/go/operators/mutation/MutateGINominal.java index ee9eb993..059af2fd 100644 --- a/src/eva2/server/go/operators/mutation/MutateGINominal.java +++ b/src/eva2/server/go/operators/mutation/MutateGINominal.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceGIIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -63,11 +63,11 @@ public class MutateGINominal implements InterfaceMutation, java.io.Serializable int mutInd = 0; for (int k = 0; k < this.m_NumberOfMutations; k++) { try { - mutInd = RandomNumberGenerator.randomInt(0, x.length-1); + mutInd = RNG.randomInt(0, x.length-1); } catch (java.lang.ArithmeticException e) { System.out.println("x.length " + x.length); } - x[mutInd] = RandomNumberGenerator.randomInt(range[mutInd][0], range[mutInd][1]); + x[mutInd] = RNG.randomInt(range[mutInd][0], range[mutInd][1]); } ((InterfaceGIIndividual)individual).SetIGenotype(x); } diff --git a/src/eva2/server/go/operators/mutation/MutateGIOrdinal.java b/src/eva2/server/go/operators/mutation/MutateGIOrdinal.java index e36f119c..cde9662e 100644 --- a/src/eva2/server/go/operators/mutation/MutateGIOrdinal.java +++ b/src/eva2/server/go/operators/mutation/MutateGIOrdinal.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceGIIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -66,12 +66,12 @@ public class MutateGIOrdinal implements InterfaceMutation, java.io.Serializable int mutInd, mut; double mutate; for (int k = 0; k < this.m_NumberOfMutations; k++) { - mutInd = RandomNumberGenerator.randomInt(0, x.length-1); - mutate = RandomNumberGenerator.gaussianDouble(this.m_StepSize); + mutInd = RNG.randomInt(0, x.length-1); + mutate = RNG.gaussianDouble(this.m_StepSize); mutate = mutate * (range[mutInd][1] - range[mutInd][1]); mut = (int)Math.round(mutate); if (mut == 0) { - if (RandomNumberGenerator.flipCoin(0.5)) mut = -1; + if (RNG.flipCoin(0.5)) mut = -1; else mut = 1; } x[mutInd] += mut; diff --git a/src/eva2/server/go/operators/mutation/MutateGITranslocate.java b/src/eva2/server/go/operators/mutation/MutateGITranslocate.java index a9cd8607..03bf1453 100644 --- a/src/eva2/server/go/operators/mutation/MutateGITranslocate.java +++ b/src/eva2/server/go/operators/mutation/MutateGITranslocate.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceGIIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** @@ -61,10 +61,10 @@ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializa if (individual instanceof InterfaceGIIndividual) { int[] x = ((InterfaceGIIndividual)individual).getIGenotype(); int from, to, length; - length = RandomNumberGenerator.randomInt(1, this.m_MaxLengthOfTranslocate); + length = RNG.randomInt(1, this.m_MaxLengthOfTranslocate); if (x.length < length+2) return; - from = RandomNumberGenerator.randomInt(0, x.length - 1 - length); - to = RandomNumberGenerator.randomInt(0, x.length - 1 - length); + from = RNG.randomInt(0, x.length - 1 - length); + to = RNG.randomInt(0, x.length - 1 - length); //this.pintInt("Before ", x); int[] tmp = new int[x.length]; int[] without = new int[x.length - length]; diff --git a/src/eva2/server/go/operators/mutation/MutateGPAdaptive.java b/src/eva2/server/go/operators/mutation/MutateGPAdaptive.java index d8698dad..5f95f757 100644 --- a/src/eva2/server/go/operators/mutation/MutateGPAdaptive.java +++ b/src/eva2/server/go/operators/mutation/MutateGPAdaptive.java @@ -8,7 +8,7 @@ import eva2.server.go.individuals.InterfaceGAIndividual; import eva2.server.go.individuals.InterfaceGPIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -70,10 +70,10 @@ 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 = this.m_MutationStep * Math.exp(this.m_Tau1 * RandomNumberGenerator.gaussianDouble(1) + this.m_Tau2 * RandomNumberGenerator.gaussianDouble(1)); + this.m_MutationStep = 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; if (this.m_MutationStep > 1) this.m_MutationStep = 1; - if (RandomNumberGenerator.flipCoin(this.m_MutationStep)) ((InterfaceGPIndividual)individual).defaultMutate(); + if (RNG.flipCoin(this.m_MutationStep)) ((InterfaceGPIndividual)individual).defaultMutate(); } //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); } diff --git a/src/eva2/server/go/operators/mutation/MutateGPSingleNode.java b/src/eva2/server/go/operators/mutation/MutateGPSingleNode.java index 68254275..d97d0e71 100644 --- a/src/eva2/server/go/operators/mutation/MutateGPSingleNode.java +++ b/src/eva2/server/go/operators/mutation/MutateGPSingleNode.java @@ -10,7 +10,7 @@ import eva2.server.go.individuals.codings.gp.AbstractGPNode; import eva2.server.go.individuals.codings.gp.GPArea; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -58,7 +58,7 @@ public class MutateGPSingleNode implements InterfaceMutation, java.io.Serializab GPArea[] areas = (GPArea[])((InterfaceGPIndividual)individual).getFunctionArea(); for (int i = 0; i < programs.length; i++) { programs[i].addNodesTo(allNodes); - AbstractGPNode nodeToMutate = (AbstractGPNode) allNodes.get(RandomNumberGenerator.randomInt(0, allNodes.size()-1)); + AbstractGPNode nodeToMutate = (AbstractGPNode) allNodes.get(RNG.randomInt(0, allNodes.size()-1)); int orgArity = nodeToMutate.getArity(); AbstractGPNode newNode = (AbstractGPNode)areas[i].getRandomNodeWithArity(orgArity).clone(); // System.out.println("OldNode "+ nodeToMutate.getName() + ":"+nodeToMutate.getArity() + " / NewNode "+newNode.getName() + ":"+newNode.getArity()); diff --git a/src/eva2/server/go/operators/mutation/MutateOBGAFlip.java b/src/eva2/server/go/operators/mutation/MutateOBGAFlip.java index cb5d014c..e53712ff 100644 --- a/src/eva2/server/go/operators/mutation/MutateOBGAFlip.java +++ b/src/eva2/server/go/operators/mutation/MutateOBGAFlip.java @@ -5,7 +5,7 @@ import eva2.server.go.individuals.InterfaceDataTypePermutation; import eva2.server.go.individuals.InterfaceOBGAIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** @@ -54,8 +54,8 @@ public class MutateOBGAFlip implements InterfaceMutation, java.io.Serializable { getOBGenotype(); for (int p = 0; p < perm.length; p++) { for (int i = 0; i < times; i++) { - int p1 = RandomNumberGenerator.randomInt(0, perm[p].length - 1); - int p2 = RandomNumberGenerator.randomInt(0, perm[p].length - 1); + int p1 = RNG.randomInt(0, perm[p].length - 1); + int p2 = RNG.randomInt(0, perm[p].length - 1); int temp = perm[p][p1]; perm[p][p1] = perm[p][p2]; perm[p][p2] = temp; diff --git a/src/eva2/server/go/operators/mutation/MutateOBGAInversion.java b/src/eva2/server/go/operators/mutation/MutateOBGAInversion.java index 0785c2ac..ab327a5e 100644 --- a/src/eva2/server/go/operators/mutation/MutateOBGAInversion.java +++ b/src/eva2/server/go/operators/mutation/MutateOBGAInversion.java @@ -5,7 +5,7 @@ import eva2.server.go.individuals.InterfaceDataTypePermutation; import eva2.server.go.individuals.InterfaceOBGAIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** @@ -52,8 +52,8 @@ public class MutateOBGAInversion implements java.io.Serializable, InterfaceMutat int[][] permnew = (int[][]) ((InterfaceOBGAIndividual) individual). getOBGenotype().clone(); int[][] perm = ((InterfaceDataTypePermutation) individual).getPermutationData(); for (int p = 0; p < perm.length; p++) { - int p1 = RandomNumberGenerator.randomInt(0, perm[p].length - 1); - int p2 = RandomNumberGenerator.randomInt(p1, perm[p].length - 1); + int p1 = RNG.randomInt(0, perm[p].length - 1); + int p2 = RNG.randomInt(p1, perm[p].length - 1); for (int i = 0; i <= (p2-p1); i++) { permnew[p][p1+i] = perm[p][p2-i]; } diff --git a/src/eva2/server/go/operators/selection/SelectAll.java b/src/eva2/server/go/operators/selection/SelectAll.java index 6aedd69c..674ad99a 100644 --- a/src/eva2/server/go/operators/selection/SelectAll.java +++ b/src/eva2/server/go/operators/selection/SelectAll.java @@ -2,7 +2,7 @@ package eva2.server.go.operators.selection; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** Simple method to selecet all. * In case of multiple fitness values the selection diff --git a/src/eva2/server/go/operators/selection/SelectBest.java b/src/eva2/server/go/operators/selection/SelectBest.java index b9bc36e1..cfc201c3 100644 --- a/src/eva2/server/go/operators/selection/SelectBest.java +++ b/src/eva2/server/go/operators/selection/SelectBest.java @@ -2,7 +2,7 @@ package eva2.server.go.operators.selection; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** Select best individual multiple times if necessary. @@ -55,7 +55,7 @@ public class SelectBest implements InterfaceSelection, java.io.Serializable { result.setPopulationSize(size); if (this.m_ObeyDebsConstViolationPrinciple) { for (int i = 0; i < size; i++) { - currentCriteria = RandomNumberGenerator.randomInt(0, critSize-1); + currentCriteria = RNG.randomInt(0, critSize-1); currentBestValue = Double.POSITIVE_INFINITY; tmpIndy = null; for (int j = 0; j < population.size(); j++) { @@ -78,7 +78,7 @@ public class SelectBest implements InterfaceSelection, java.io.Serializable { } } else { for (int i = 0; i < size; i++) { - currentCriteria = RandomNumberGenerator.randomInt(0, critSize-1); + currentCriteria = RNG.randomInt(0, critSize-1); currentBestValue = Double.POSITIVE_INFINITY; for (int j = 0; j < population.size(); j++) { if (((AbstractEAIndividual)population.get(j)).getFitness(currentCriteria) < currentBestValue) { diff --git a/src/eva2/server/go/operators/selection/SelectBestIndividuals.java b/src/eva2/server/go/operators/selection/SelectBestIndividuals.java index 806d49d5..1bbc7ea0 100644 --- a/src/eva2/server/go/operators/selection/SelectBestIndividuals.java +++ b/src/eva2/server/go/operators/selection/SelectBestIndividuals.java @@ -5,7 +5,7 @@ import java.util.ArrayList; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** Select the best individuals. * In case of multiple fitness values the selection @@ -64,7 +64,7 @@ public class SelectBestIndividuals implements InterfaceSelection, java.io.Serial // now get the actual result from the tmp list for (int i = 0; i < size; i++) { - currentCriteria = RandomNumberGenerator.randomInt(0, critSize-1); + currentCriteria = RNG.randomInt(0, critSize-1); result.add(bestIndividuals[currentCriteria].get(0)); bestIndividuals[currentCriteria].remove(0); } @@ -121,7 +121,7 @@ public class SelectBestIndividuals implements InterfaceSelection, java.io.Serial } } if (index >= 0) return pop.get(index); - else return pop.get(RandomNumberGenerator.randomInt(0, pop.size()-1)); + else return pop.get(RNG.randomInt(0, pop.size()-1)); } } else { for (int i = 0; i < pop.size(); i++) { @@ -140,7 +140,7 @@ public class SelectBestIndividuals implements InterfaceSelection, java.io.Serial } } if (index >= 0) return pop.get(index); - else return pop.get(RandomNumberGenerator.randomInt(0, pop.size()-1)); + else return pop.get(RNG.randomInt(0, pop.size()-1)); } } diff --git a/src/eva2/server/go/operators/selection/SelectEPTournaments.java b/src/eva2/server/go/operators/selection/SelectEPTournaments.java index 3a584189..198d761e 100644 --- a/src/eva2/server/go/operators/selection/SelectEPTournaments.java +++ b/src/eva2/server/go/operators/selection/SelectEPTournaments.java @@ -5,7 +5,7 @@ import java.util.ArrayList; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This method implements the multiple tournament scheme * for EP. @@ -60,7 +60,7 @@ public class SelectEPTournaments implements InterfaceSelection, java.io.Serializ } // perform tournament for (int k = 0; k < this.m_TournamentSize; k++) { - rand = RandomNumberGenerator.randomInt(0, population.size()-1); + rand = RNG.randomInt(0, population.size()-1); tmpIndy = ((AbstractEAIndividual)population.get(rand)); for (int l = 0; l < best.length; l++) { if (this.m_ObeyDebsConstViolationPrinciple) { @@ -102,7 +102,7 @@ public class SelectEPTournaments implements InterfaceSelection, java.io.Serializ // now get the actual result from the tmp list for (int i = 0; i < size; i++) { - currentCriteria = RandomNumberGenerator.randomInt(0, critSize-1); + currentCriteria = RNG.randomInt(0, critSize-1); result.add(bestIndividuals[currentCriteria].get(0)); bestIndividuals[currentCriteria].remove(0); } @@ -139,7 +139,7 @@ public class SelectEPTournaments implements InterfaceSelection, java.io.Serializ } } if (index >= 0) return pop.get(index); - else return pop.get(RandomNumberGenerator.randomInt(0, pop.size()-1)); + else return pop.get(RNG.randomInt(0, pop.size()-1)); } /** This method allows you to select partners for a given Individual diff --git a/src/eva2/server/go/operators/selection/SelectHomologousMate.java b/src/eva2/server/go/operators/selection/SelectHomologousMate.java index 68e11883..5a8cbab4 100644 --- a/src/eva2/server/go/operators/selection/SelectHomologousMate.java +++ b/src/eva2/server/go/operators/selection/SelectHomologousMate.java @@ -6,7 +6,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.operators.distancemetric.InterfaceDistanceMetric; import eva2.server.go.operators.distancemetric.ObjectiveSpaceMetric; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** An experimential implementation for mating restriction. * Possibly defunct. diff --git a/src/eva2/server/go/operators/selection/SelectMOMAIIDominanceCounter.java b/src/eva2/server/go/operators/selection/SelectMOMAIIDominanceCounter.java index 11e5a600..0d507405 100644 --- a/src/eva2/server/go/operators/selection/SelectMOMAIIDominanceCounter.java +++ b/src/eva2/server/go/operators/selection/SelectMOMAIIDominanceCounter.java @@ -58,7 +58,9 @@ public class SelectMOMAIIDominanceCounter implements InterfaceSelection, java.io tmpObj = tmpIndy1.getData("MOMAII"); if ((tmpObj != null) && (tmpObj instanceof MOMultipleSolutions)) { malta = (MOMultipleSolutions)tmpObj; - for (int j = i+1; j < population.size(); i++) { + //for (int j = i+1; j < population.size(); i++) { + // MK: Im rather sure the i++ was intended to become a j++ + for (int j = i+1; j < population.size(); j++) { tmpIndy2 = (AbstractEAIndividual)population.get(j); tmpObj = tmpIndy2.getData("MOMAII"); if ((tmpObj != null) && (tmpObj instanceof MOMultipleSolutions)) { diff --git a/src/eva2/server/go/operators/selection/SelectMOMaxiMin.java b/src/eva2/server/go/operators/selection/SelectMOMaxiMin.java index e6034f22..d3e26ad0 100644 --- a/src/eva2/server/go/operators/selection/SelectMOMaxiMin.java +++ b/src/eva2/server/go/operators/selection/SelectMOMaxiMin.java @@ -3,7 +3,7 @@ package eva2.server.go.operators.selection; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.operators.moso.MOSOMaxiMin; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** A multi-objective selection criterion based on the maximin * method. diff --git a/src/eva2/server/go/operators/selection/SelectMONSGAIICrowedTournament.java b/src/eva2/server/go/operators/selection/SelectMONSGAIICrowedTournament.java index db253a9c..0481fd52 100644 --- a/src/eva2/server/go/operators/selection/SelectMONSGAIICrowedTournament.java +++ b/src/eva2/server/go/operators/selection/SelectMONSGAIICrowedTournament.java @@ -3,7 +3,7 @@ package eva2.server.go.operators.selection; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.operators.archiving.ArchivingNSGAII; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** The infamous NSGA-II selection scheme for multi-objective * optimization based on Pareto ranks and hybergrids. @@ -73,7 +73,7 @@ public class SelectMONSGAIICrowedTournament implements InterfaceSelection, java. try { for (int i = 0; i < this.m_TournamentSize; i++) { - tmpIndy = (AbstractEAIndividual) population.get(RandomNumberGenerator.randomInt(0, population.size()-1)); + tmpIndy = (AbstractEAIndividual) population.get(RNG.randomInt(0, population.size()-1)); tmpL = ((Integer)tmpIndy.getData("ParetoLevel")).intValue(); if (tmpL < smallestLevel) smallestLevel = tmpL; if (tmpIndy.getConstraintViolation() > 0) infeasiblePop.add(tmpIndy); diff --git a/src/eva2/server/go/operators/selection/SelectMONonDominated.java b/src/eva2/server/go/operators/selection/SelectMONonDominated.java index 92f813bf..16327995 100644 --- a/src/eva2/server/go/operators/selection/SelectMONonDominated.java +++ b/src/eva2/server/go/operators/selection/SelectMONonDominated.java @@ -2,7 +2,7 @@ package eva2.server.go.operators.selection; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This multi-objective selection method preferrs non-dominated * individuals over dominated ones. Actually, this fails in case @@ -47,7 +47,7 @@ public class SelectMONonDominated implements InterfaceSelection, java.io.Seriali */ public Population selectFrom(Population population, int size) { Population result = new Population(); - int index = RandomNumberGenerator.randomInt(0, population.size()-1); + int index = RNG.randomInt(0, population.size()-1); if (this.m_ObeyDebsConstViolationPrinciple) { boolean feasible = false; diff --git a/src/eva2/server/go/operators/selection/SelectMOPESA.java b/src/eva2/server/go/operators/selection/SelectMOPESA.java index 99e9f2b2..9166cfcf 100644 --- a/src/eva2/server/go/operators/selection/SelectMOPESA.java +++ b/src/eva2/server/go/operators/selection/SelectMOPESA.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.operators.archiving.ArchivingPESAII; import eva2.server.go.operators.moso.MOSOMaxiMin; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** The multi-objective PESA selection method. * Created by IntelliJ IDEA. @@ -67,9 +67,9 @@ public class SelectMOPESA implements InterfaceSelection, java.io.Serializable { int winner, tmp; try { - winner = RandomNumberGenerator.randomInt(0, population.size()-1); + winner = RNG.randomInt(0, population.size()-1); for (int i = 1; i < this.m_TournamentSize; i++) { - tmp = RandomNumberGenerator.randomInt(0, population.size()-1); + tmp = RNG.randomInt(0, population.size()-1); if (this.m_Squeeze[tmp] < this.m_Squeeze[winner]) winner = tmp; } resultIndy = (AbstractEAIndividual) population.get(winner); diff --git a/src/eva2/server/go/operators/selection/SelectMOPESAII.java b/src/eva2/server/go/operators/selection/SelectMOPESAII.java index b9f6f067..d40a33f3 100644 --- a/src/eva2/server/go/operators/selection/SelectMOPESAII.java +++ b/src/eva2/server/go/operators/selection/SelectMOPESAII.java @@ -8,7 +8,7 @@ import java.util.Enumeration; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.operators.archiving.ArchivingPESAII; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** The multi-objective PESA II selection criteria based on a n-dimensional * grid using a squezzing factor. @@ -102,13 +102,13 @@ public class SelectMOPESAII implements InterfaceSelection, java.io.Serializable int winner, tmp; try { - box1 = (ArrayList)this.m_GridBoxes.get(RandomNumberGenerator.randomInt(0, this.m_GridBoxes.size()-1)); - box2 = (ArrayList)this.m_GridBoxes.get(RandomNumberGenerator.randomInt(0, this.m_GridBoxes.size()-1)); + box1 = (ArrayList)this.m_GridBoxes.get(RNG.randomInt(0, this.m_GridBoxes.size()-1)); + box2 = (ArrayList)this.m_GridBoxes.get(RNG.randomInt(0, this.m_GridBoxes.size()-1)); if (((Integer)((AbstractEAIndividual)box1.get(0)).getData("SqueezeFactor")).intValue() < ((Integer)((AbstractEAIndividual)box2.get(0)).getData("SqueezeFactor")).intValue()) { - resultIndy = (AbstractEAIndividual) (box1.get(RandomNumberGenerator.randomInt(0, box1.size()-1))); + resultIndy = (AbstractEAIndividual) (box1.get(RNG.randomInt(0, box1.size()-1))); } else { - resultIndy = (AbstractEAIndividual) (box2.get(RandomNumberGenerator.randomInt(0, box2.size()-1))); + resultIndy = (AbstractEAIndividual) (box2.get(RNG.randomInt(0, box2.size()-1))); } } catch (java.lang.IndexOutOfBoundsException e) { System.out.println("Tournament Selection produced IndexOutOfBoundsException!"); diff --git a/src/eva2/server/go/operators/selection/SelectMOSPEAII.java b/src/eva2/server/go/operators/selection/SelectMOSPEAII.java index 219f4053..cc95f354 100644 --- a/src/eva2/server/go/operators/selection/SelectMOSPEAII.java +++ b/src/eva2/server/go/operators/selection/SelectMOSPEAII.java @@ -8,7 +8,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.operators.archiving.ArchivingNSGAII; import eva2.server.go.operators.archiving.ArchivingSPEAII; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import wsi.ra.chart2d.DPoint; /** The SPEA II selection criteria using strength and raw fitness to determine diff --git a/src/eva2/server/go/operators/selection/SelectParticleWheel.java b/src/eva2/server/go/operators/selection/SelectParticleWheel.java index 2e788891..3c32a37c 100644 --- a/src/eva2/server/go/operators/selection/SelectParticleWheel.java +++ b/src/eva2/server/go/operators/selection/SelectParticleWheel.java @@ -5,7 +5,7 @@ import eva2.server.go.operators.selection.probability.InterfaceSelectionProbabil import eva2.server.go.operators.selection.probability.SelProbBoltzman; import eva2.server.go.operators.selection.probability.SelProbStandard; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This method implements the roulette wheel selection for @@ -57,7 +57,7 @@ public class SelectParticleWheel implements InterfaceSelection, java.io.Serializ // use a fixed segment roulette wheel selection double segment = 1./(size+1); - double selPoint = RandomNumberGenerator.randomDouble(0., segment); + double selPoint = RNG.randomDouble(0., segment); int selIndex = 0; double selFitSum = ((AbstractEAIndividual)population.getIndividual(selIndex)).getSelectionProbability(0); diff --git a/src/eva2/server/go/operators/selection/SelectRandom.java b/src/eva2/server/go/operators/selection/SelectRandom.java index 8f089653..c709a5f5 100644 --- a/src/eva2/server/go/operators/selection/SelectRandom.java +++ b/src/eva2/server/go/operators/selection/SelectRandom.java @@ -2,7 +2,7 @@ package eva2.server.go.operators.selection; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** Random selection typically used for ES a mating selection. @@ -52,7 +52,7 @@ public class SelectRandom implements InterfaceSelection, java.io.Serializable { if (this.m_ObeyDebsConstViolationPrinciple) { int index = 0, rand; while (result.size() < size) { - rand = RandomNumberGenerator.randomInt(0, population.size()-1); + rand = RNG.randomInt(0, population.size()-1); if (!((AbstractEAIndividual)population.get(rand)).violatesConstraint()) result.add(population.get(rand)); index++; @@ -60,14 +60,14 @@ public class SelectRandom implements InterfaceSelection, java.io.Serializable { // darn there seems to be no feasible solution // just select random one instead for (int i = 0; i < size; i++) { - result.add(population.get(RandomNumberGenerator.randomInt(0, population.size()-1))); + result.add(population.get(RNG.randomInt(0, population.size()-1))); } } } } else { for (int i = 0; i < size; i++) { - result.add(population.get(RandomNumberGenerator.randomInt(0, population.size()-1))); + result.add(population.get(RNG.randomInt(0, population.size()-1))); } } return result; diff --git a/src/eva2/server/go/operators/selection/SelectTournament.java b/src/eva2/server/go/operators/selection/SelectTournament.java index 1be04074..42ef839a 100644 --- a/src/eva2/server/go/operators/selection/SelectTournament.java +++ b/src/eva2/server/go/operators/selection/SelectTournament.java @@ -2,7 +2,7 @@ package eva2.server.go.operators.selection; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** Tournament selection within a given tournament group size, * also scaling invariant. @@ -66,19 +66,19 @@ public class SelectTournament implements InterfaceSelection, java.io.Serializabl try { critSize = ((AbstractEAIndividual)population.get(0)).getFitness().length; - currentCriteria = RandomNumberGenerator.randomInt(0, critSize-1); + currentCriteria = RNG.randomInt(0, critSize-1); if (this.m_ObeyDebsConstViolationPrinciple) { Population tournamentGroup = new Population(); for (int i = 0; i < this.m_TournamentSize; i++) { - tournamentGroup.add(population.get(RandomNumberGenerator.randomInt(0, population.size()-1))); + tournamentGroup.add(population.get(RNG.randomInt(0, population.size()-1))); } SelectBestIndividuals best = new SelectBestIndividuals(); best.setObeyDebsConstViolationPrinciple(true); result = (AbstractEAIndividual)best.selectFrom(tournamentGroup, 1).get(0); } else { - result = (AbstractEAIndividual) population.get(RandomNumberGenerator.randomInt(0, population.size()-1)); + result = (AbstractEAIndividual) population.get(RNG.randomInt(0, population.size()-1)); for (int i = 1; i < this.m_TournamentSize; i++) { - tmpIndy = (AbstractEAIndividual) population.get(RandomNumberGenerator.randomInt(0, population.size()-1)); + tmpIndy = (AbstractEAIndividual) population.get(RNG.randomInt(0, population.size()-1)); if (tmpIndy.getFitness(currentCriteria) < result.getFitness(currentCriteria)) result = tmpIndy; } } diff --git a/src/eva2/server/go/operators/selection/SelectXProbRouletteWheel.java b/src/eva2/server/go/operators/selection/SelectXProbRouletteWheel.java index 0fa4c3bc..b45c6d7c 100644 --- a/src/eva2/server/go/operators/selection/SelectXProbRouletteWheel.java +++ b/src/eva2/server/go/operators/selection/SelectXProbRouletteWheel.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.operators.selection.probability.InterfaceSelectionProbability; import eva2.server.go.operators.selection.probability.SelProbStandard; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; class treeElement implements java.io.Serializable { @@ -147,8 +147,8 @@ public class SelectXProbRouletteWheel implements InterfaceSelection, java.io.Ser int currentCriteria = 0, critSize; critSize = ((AbstractEAIndividual)population.get(0)).getSelectionProbability().length; - currentCriteria = RandomNumberGenerator.randomInt(0, critSize-1); - double d = RandomNumberGenerator.randomDouble(); + currentCriteria = RNG.randomInt(0, critSize-1); + double d = RNG.randomDouble(); int index = this.m_TreeRoot[currentCriteria].getIndexFor(d); //System.out.println("Looking for: " + d + " found " +index); return ((AbstractEAIndividual)(population.get(index))); @@ -159,11 +159,11 @@ public class SelectXProbRouletteWheel implements InterfaceSelection, java.io.Ser int currentCriteria = 0, critSize; critSize = ((AbstractEAIndividual)population.get(0)).getSelectionProbability().length; - currentCriteria = RandomNumberGenerator.randomInt(0, critSize-1); + currentCriteria = RNG.randomInt(0, critSize-1); String logger = ""; while (sum > 0) { sum = 0; - random = RandomNumberGenerator.randomDouble(); + random = RNG.randomDouble(); for (int i = 0; i < population.size(); i++) { tmpD = ((AbstractEAIndividual)(population.get(i))).getSelectionProbability(currentCriteria); logger += tmpD + "; "; diff --git a/src/eva2/server/go/operators/selection/replacement/ReplaceRandom.java b/src/eva2/server/go/operators/selection/replacement/ReplaceRandom.java index e6042dfc..41da37ff 100644 --- a/src/eva2/server/go/operators/selection/replacement/ReplaceRandom.java +++ b/src/eva2/server/go/operators/selection/replacement/ReplaceRandom.java @@ -2,7 +2,7 @@ package eva2.server.go.operators.selection.replacement; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** Random replacement. * Created by IntelliJ IDEA. @@ -27,7 +27,7 @@ public class ReplaceRandom implements InterfaceReplacement, java.io.Serializable * @param sub The subset */ public void insertIndividual(AbstractEAIndividual indy, Population pop, Population sub) { - int rand = RandomNumberGenerator.randomInt(0, pop.size()-1); + int rand = RNG.randomInt(0, pop.size()-1); pop.remove(rand); pop.addIndividual(indy); } diff --git a/src/eva2/server/go/operators/selection/replacement/ReplaceWorst.java b/src/eva2/server/go/operators/selection/replacement/ReplaceWorst.java index 30a59fae..d4edb332 100644 --- a/src/eva2/server/go/operators/selection/replacement/ReplaceWorst.java +++ b/src/eva2/server/go/operators/selection/replacement/ReplaceWorst.java @@ -2,7 +2,7 @@ package eva2.server.go.operators.selection.replacement; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This method replaces the worst indvidual in the population. * Created by IntelliJ IDEA. diff --git a/src/eva2/server/go/populations/PBILPopulation.java b/src/eva2/server/go/populations/PBILPopulation.java index d77cc320..ced2fea9 100644 --- a/src/eva2/server/go/populations/PBILPopulation.java +++ b/src/eva2/server/go/populations/PBILPopulation.java @@ -5,7 +5,7 @@ import java.util.BitSet; import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.InterfaceGAIndividual; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This implementation of Population Based Incremental Learning is only * suited for a BitString based genotyp represenation. @@ -86,7 +86,7 @@ public class PBILPopulation extends Population implements Cloneable, java.io.Ser tmpIndy = (InterfaceGAIndividual)((AbstractEAIndividual)template).clone(); tmpBitSet = tmpIndy.getBGenotype(); for (int j = 0; j < this.m_ProbabilityVector.length; j++) { - if (RandomNumberGenerator.flipCoin(this.m_ProbabilityVector[j])) tmpBitSet.set(j); + if (RNG.flipCoin(this.m_ProbabilityVector[j])) tmpBitSet.set(j); else tmpBitSet.clear(j); } tmpIndy.SetBGenotype(tmpBitSet); @@ -99,7 +99,7 @@ public class PBILPopulation extends Population implements Cloneable, java.io.Ser */ public void mutateProbabilityVector(double mutationRate, double sigma) { for (int j = 0; j < this.m_ProbabilityVector.length; j++) { - if (RandomNumberGenerator.flipCoin(mutationRate)) this.m_ProbabilityVector[j] += RandomNumberGenerator.gaussianDouble(sigma); + if (RNG.flipCoin(mutationRate)) this.m_ProbabilityVector[j] += RNG.gaussianDouble(sigma); if (this.m_ProbabilityVector[j] > 1) this.m_ProbabilityVector[j] = 1; if (this.m_ProbabilityVector[j] < 0) this.m_ProbabilityVector[j] = 0; } diff --git a/src/eva2/server/go/populations/Population.java b/src/eva2/server/go/populations/Population.java index 06220bc0..9b9d6011 100644 --- a/src/eva2/server/go/populations/Population.java +++ b/src/eva2/server/go/populations/Population.java @@ -12,7 +12,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.AbstractEAIndividualComparator; import eva2.server.go.individuals.GAIndividualBinaryData; import eva2.server.go.operators.distancemetric.PhenotypeMetric; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** This is a basic implementation for a EA Population. @@ -323,7 +323,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea // not all violate, maybe all are NaN! // so just select a random one System.err.println("Population reports: All individuals seem to have NaN or infinite fitness!"); - result = RandomNumberGenerator.randomInt(size()); + result = RNG.randomInt(size()); } } return result; @@ -409,7 +409,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * @param to */ public static void moveRandIndFromTo(Population src, Population dst) { - int k = RandomNumberGenerator.randomInt(src.size()); + int k = RNG.randomInt(src.size()); dst.add(src.remove(k)); } @@ -456,7 +456,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea */ public void removeNIndividuals(int n) { for (int i = 0; i < n; i++) { - this.remove(RandomNumberGenerator.randomInt(0, this.size()-1)); + this.remove(RNG.randomInt(0, this.size()-1)); } } @@ -606,11 +606,11 @@ public class Population extends ArrayList implements PopulationInterface, Clonea // int rand; // if (this.size() != 0) { // while (this.size() < size) { -// rand = RandomNumberGenerator.randomInt(0, this.size()-1); +// rand = RNG.randomInt(0, this.size()-1); // this.add(((AbstractEAIndividual)this.get(rand)).clone()); // } // while (this.size() > size) { -// rand = RandomNumberGenerator.randomInt(0, this.size()-1); +// rand = RNG.randomInt(0, this.size()-1); // this.remove(rand); // } // } diff --git a/src/eva2/server/go/problems/AbstractDynTransProblem.java b/src/eva2/server/go/problems/AbstractDynTransProblem.java index b6a8e120..3c11db0e 100644 --- a/src/eva2/server/go/problems/AbstractDynTransProblem.java +++ b/src/eva2/server/go/problems/AbstractDynTransProblem.java @@ -136,9 +136,6 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz return problemDimension; } - protected void changeProblemAt(double problemTime) { - super.changeProblemAt(problemTime); - } /****************************************************************************** * These are for the GUI */ diff --git a/src/eva2/server/go/problems/AbstractProblemDouble.java b/src/eva2/server/go/problems/AbstractProblemDouble.java index 33ca3e14..d1cee89e 100644 --- a/src/eva2/server/go/problems/AbstractProblemDouble.java +++ b/src/eva2/server/go/problems/AbstractProblemDouble.java @@ -5,7 +5,7 @@ import eva2.server.go.individuals.ESIndividualDoubleData; import eva2.server.go.individuals.InterfaceDataTypeDouble; import eva2.server.go.populations.Population; import eva2.server.go.strategies.InterfaceOptimizer; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import eva2.server.go.problems.Interface2DBorderProblem; public abstract class AbstractProblemDouble extends AbstractOptimizationProblem implements Interface2DBorderProblem { @@ -55,7 +55,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem // evaluate the vector fitness = this.eval(x); // if indicated, add Gaussian noise - if (m_Noise != 0) RandomNumberGenerator.addNoise(fitness, m_Noise); + if (m_Noise != 0) RNG.addNoise(fitness, m_Noise); // set the fitness setEvalFitness(individual, x, fitness); } diff --git a/src/eva2/server/go/problems/BKnapsackProblem.java b/src/eva2/server/go/problems/BKnapsackProblem.java index ca8cfd1a..0243fa9b 100644 --- a/src/eva2/server/go/problems/BKnapsackProblem.java +++ b/src/eva2/server/go/problems/BKnapsackProblem.java @@ -9,7 +9,7 @@ import eva2.server.go.individuals.GAIndividualBinaryData; import eva2.server.go.individuals.InterfaceDataTypeBinary; import eva2.server.go.populations.Population; import eva2.server.go.strategies.InterfaceOptimizer; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. @@ -166,12 +166,12 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav for (int i = 0; i < population.getPopulationSize(); i++) { tmpIndy = (AbstractEAIndividual)((AbstractEAIndividual)this.m_Template).clone(); tmpIndy.init(this); - if (RandomNumberGenerator.flipCoin(this.m_ProblemSpecificInit)) { + if (RNG.flipCoin(this.m_ProblemSpecificInit)) { BitSet tmpSet = new BitSet(); tmpSet.clear(); while (evaluate(tmpSet, items.length)[1] > 0) { - tmpSet.set(RandomNumberGenerator.randomInt(0,items.length-1)); + tmpSet.set(RNG.randomInt(0,items.length-1)); } ((InterfaceDataTypeBinary)tmpIndy).SetBinaryDataLamarkian(tmpSet); } @@ -193,7 +193,7 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav tmpIndy = (InterfaceDataTypeBinary) individual; tmpBitSet = tmpIndy.getBinaryData(); result = this.evaluate(tmpBitSet, tmpIndy.size()); - if (RandomNumberGenerator.flipCoin(this.m_LocalSearch)) { + if (RNG.flipCoin(this.m_LocalSearch)) { // first remove surplus assets while (result[1] > 0) { // search for an element to replace @@ -204,7 +204,7 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav weakest = i; } if ( ((-items[i][1])/((double)items[i][0])) == ((-items[weakest][1])/((double)items[weakest][0])) ) { - if (RandomNumberGenerator.flipCoin(0.5)) weakest = i; + if (RNG.flipCoin(0.5)) weakest = i; } } } @@ -222,7 +222,7 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav weakest = i; } if ( ((-items[i][1])/((double)items[i][0])) == ((-items[weakest][1])/((double)items[weakest][0])) ) { - if (RandomNumberGenerator.flipCoin(0.5)) weakest = i; + if (RNG.flipCoin(0.5)) weakest = i; } } } diff --git a/src/eva2/server/go/problems/F1Problem.java b/src/eva2/server/go/problems/F1Problem.java index 581c1006..e2820957 100644 --- a/src/eva2/server/go/problems/F1Problem.java +++ b/src/eva2/server/go/problems/F1Problem.java @@ -50,14 +50,6 @@ public class F1Problem extends AbstractProblemDouble implements Interface2DBorde */ public void initProblem() { // this.m_OverallBest = null; - } - - /** This method inits a given population - * @param population The populations that is to be inited - */ - public void initPopulation(Population population) { - super.initPopulation(population); - } protected double[] getEvalArray(AbstractEAIndividual individual){ diff --git a/src/eva2/server/go/problems/F4Problem.java b/src/eva2/server/go/problems/F4Problem.java index 2c120377..e48b7090 100644 --- a/src/eva2/server/go/problems/F4Problem.java +++ b/src/eva2/server/go/problems/F4Problem.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.ESIndividualDoubleData; import eva2.server.go.individuals.InterfaceDataTypeDouble; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. diff --git a/src/eva2/server/go/problems/F5Problem.java b/src/eva2/server/go/problems/F5Problem.java index 2aa4b31f..ac84e14c 100644 --- a/src/eva2/server/go/problems/F5Problem.java +++ b/src/eva2/server/go/problems/F5Problem.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.ESIndividualDoubleData; import eva2.server.go.individuals.InterfaceDataTypeDouble; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** * Created by IntelliJ IDEA. diff --git a/src/eva2/server/go/problems/F7Problem.java b/src/eva2/server/go/problems/F7Problem.java index 0b0269d4..2dbe5a46 100644 --- a/src/eva2/server/go/problems/F7Problem.java +++ b/src/eva2/server/go/problems/F7Problem.java @@ -4,7 +4,7 @@ import eva2.server.go.individuals.AbstractEAIndividual; import eva2.server.go.individuals.ESIndividualDoubleData; import eva2.server.go.individuals.InterfaceDataTypeDouble; import eva2.server.go.populations.Population; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import eva2.tools.SelectedTag; import eva2.tools.Tag; @@ -79,7 +79,7 @@ public class F7Problem extends F1Problem implements java.io.Serializable { fitness = this.eval(x); for (int i = 0; i < fitness.length; i++) { // add noise to the fitness - fitness[i] += RandomNumberGenerator.gaussianDouble(this.getNoise()); + fitness[i] += RNG.gaussianDouble(this.getNoise()); fitness[i] += this.m_YOffSet; // set the fitness of the individual individual.SetFitness(i, fitness[i]); @@ -101,11 +101,11 @@ public class F7Problem extends F1Problem implements java.io.Serializable { result[0] = 0; if ((Math.floor(this.m_CurrentTimeStamp / this.m_t)%2) == 0) { for (int i = 0; i < x.length-1; i++) { - result[0] += Math.pow(x[i], 2);; + result[0] += Math.pow(x[i], 2); } } else { for (int i = 0; i < x.length-1; i++) { - result[0] += Math.pow(x[i]-this.m_Change, 2);; + result[0] += Math.pow(x[i]-this.m_Change, 2); } } return result; diff --git a/src/eva2/server/go/problems/FLensProblem.java b/src/eva2/server/go/problems/FLensProblem.java index f743a08c..31e00362 100644 --- a/src/eva2/server/go/problems/FLensProblem.java +++ b/src/eva2/server/go/problems/FLensProblem.java @@ -10,7 +10,7 @@ import eva2.server.go.individuals.GAIndividualDoubleData; import eva2.server.go.individuals.InterfaceDataTypeDouble; import eva2.server.go.populations.Population; import eva2.server.go.strategies.InterfaceOptimizer; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import eva2.server.modules.GOParameters; import java.awt.*; @@ -280,7 +280,7 @@ public class FLensProblem extends AbstractOptimizationProblem implements Interfa fitness = this.doEvaluation(x); for (int i = 0; i < fitness.length; i++) { // add noise to the fitness - fitness[i] += RandomNumberGenerator.gaussianDouble(this.m_Noise); + fitness[i] += RNG.gaussianDouble(this.m_Noise); fitness[i] += this.m_YOffSet; // set the fitness of the individual individual.SetFitness(i, fitness[i]); @@ -423,7 +423,7 @@ public class FLensProblem extends AbstractOptimizationProblem implements Interfa GOStandaloneVersion program = new GOStandaloneVersion(); GOParameters GO = program.getGOParameters(); GO.setProblem(f); - RandomNumberGenerator.setRandomSeed(1); + RNG.setRandomSeed(1); program.initFrame(); program.setShow(true); } diff --git a/src/eva2/server/go/problems/MatlabProblem.java b/src/eva2/server/go/problems/MatlabProblem.java index 418efbb1..0287afe0 100644 --- a/src/eva2/server/go/problems/MatlabProblem.java +++ b/src/eva2/server/go/problems/MatlabProblem.java @@ -103,7 +103,7 @@ public class MatlabProblem extends AbstractProblemDouble implements InterfaceTex log("range is " + BeanInspector.toString(range)+ "\n"); log("template len: " + ((ESIndividualDoubleData)m_Template).getDGenotype().length + "\n"); - try { +// try { // if (matlab == null) // matlab = new Matlab();//this command links to the current matlab session // try { @@ -111,10 +111,10 @@ public class MatlabProblem extends AbstractProblemDouble implements InterfaceTex // } catch (Exception e) { // e.printStackTrace(); // } - } catch (Error e) { - log("Error: " + e.toString()); - System.err.println("Error: could not create MatlabProblem instance. MatlabProblem can only be used from Matlab."); - } +// } catch (Error e) { +// log("Error: " + e.toString()); +// System.err.println("Error: could not create MatlabProblem instance. MatlabProblem can only be used from Matlab."); +// } // this.jmInterface = nameJEInterface; // mtCmd = new String("evaluateJE("+jmInterface+")"); @@ -180,7 +180,7 @@ public class MatlabProblem extends AbstractProblemDouble implements InterfaceTex // // public double[] getNewDoubleArray() { // currArray = new double[problemDimension]; -// for (int i=0; i= 0) { // set the new detection anchor individual - detectAnchor = RandomNumberGenerator.randomInt(0, m_Population.size()-1); + detectAnchor = RNG.randomInt(0, m_Population.size()-1); if (detectFit == null) detectFit = (m_Population.getIndividual(detectAnchor).getFitness()).clone(); else System.arraycopy(m_Population.getIndividual(detectAnchor).getFitness(), 0, detectFit, 0, detectFit.length); } diff --git a/src/eva2/server/go/strategies/ParticleSwarmOptimization.java b/src/eva2/server/go/strategies/ParticleSwarmOptimization.java index 8e04f9e5..273be786 100644 --- a/src/eva2/server/go/strategies/ParticleSwarmOptimization.java +++ b/src/eva2/server/go/strategies/ParticleSwarmOptimization.java @@ -16,7 +16,7 @@ import eva2.server.go.populations.Population; import eva2.server.go.problems.F1Problem; import eva2.server.go.problems.Interface2DBorderProblem; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; import eva2.tools.SelectedTag; import wsi.ra.chart2d.DPoint; @@ -167,7 +167,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se // init velocity writeData = new double[((InterfaceESIndividual)indy).getDGenotype().length]; for (int j = 0; j < writeData.length; j++) { - writeData[j] = RandomNumberGenerator.gaussianDouble(1.0); + writeData[j] = RNG.gaussianDouble(1.0); //sum += (writeData[j])*(writeData[j]); } //sum = Math.sqrt(sum); @@ -600,7 +600,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se protected void rotateAllAxes(double[] vect, double alpha, boolean randomize) { for (int i=0; i 0) { // initialize random vector -// randVec.set(0, 0, len/2.+RandomNumberGenerator.gaussianDouble(len/2)); +// randVec.set(0, 0, len/2.+RNG.gaussianDouble(len/2)); // for (int i=1; i 0) { // // initialize random vector -// randVec.setElement(0, len/2.+RandomNumberGenerator.gaussianDouble(len/2)); -// //randVec.setElement(0, RandomNumberGenerator.randomDouble(0, len)); +// randVec.setElement(0, len/2.+RNG.gaussianDouble(len/2)); +// //randVec.setElement(0, RNG.randomDouble(0, len)); // for (int i=1; i RandomNumberGenerator.randomInt(0,1)) { + if (Math.exp(-delta/this.m_CurrentTemperature) > RNG.randomInt(0,1)) { this.m_Population.remove(i); this.m_Population.add(i, original.get(i)); } diff --git a/src/eva2/server/go/strategies/ThresholdAlgorithm.java b/src/eva2/server/go/strategies/ThresholdAlgorithm.java index e69e1df5..97f18b33 100644 --- a/src/eva2/server/go/strategies/ThresholdAlgorithm.java +++ b/src/eva2/server/go/strategies/ThresholdAlgorithm.java @@ -6,7 +6,7 @@ import eva2.server.go.individuals.GAIndividualBinaryData; import eva2.server.go.populations.Population; import eva2.server.go.problems.B1Problem; import eva2.server.go.problems.InterfaceOptimizationProblem; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; /** Threshold accepting algorithm simliar strategy as the flood * algorithm, similar problems. diff --git a/src/eva2/server/go/strategies/tribes/Tribe.java b/src/eva2/server/go/strategies/tribes/Tribe.java index 891fe65d..0f0d91a9 100644 --- a/src/eva2/server/go/strategies/tribes/Tribe.java +++ b/src/eva2/server/go/strategies/tribes/Tribe.java @@ -2,7 +2,7 @@ package eva2.server.go.strategies.tribes; import eva2.server.go.problems.InterfaceOptimizationProblem; import eva2.server.go.strategies.Tribes; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; public class Tribe implements java.io.Serializable { @@ -136,7 +136,7 @@ public class Tribe implements java.io.Serializable { // Reinitialise explorers for (n = 0; n < explorerNb; n++) { contact = explorer[n].contact; // Keep the same contact - option = RandomNumberGenerator.randomInt(3); + option = RNG.randomInt(3); TribesSwarm emptySwarm= new TribesSwarm(null, swarm.getRange(), swarm.getInitRange()); TribesPosition emptyPos=new TribesPosition(swarm.getProblemDim()); explorer[n] = emptySwarm.generateExplorer(emptyPos, -1, option, -1, initType, prob, true); @@ -210,7 +210,7 @@ public class Tribe implements java.io.Serializable { */ if (status == 1) { - status = RandomNumberGenerator.randomInt() - 1; + status = RNG.randomInt() - 1; } } @@ -255,7 +255,7 @@ public class Tribe implements java.io.Serializable { explorer[explorerNb] = explorerNew; // Add a contact at random - contact = RandomNumberGenerator.randomInt(0, memoryNb-1); + contact = RNG.randomInt(0, memoryNb-1); explorer[explorerNb].contact = contact; // Update contact diff --git a/src/eva2/server/go/strategies/tribes/TribesExplorer.java b/src/eva2/server/go/strategies/tribes/TribesExplorer.java index 82d1c35b..b0a37054 100644 --- a/src/eva2/server/go/strategies/tribes/TribesExplorer.java +++ b/src/eva2/server/go/strategies/tribes/TribesExplorer.java @@ -6,7 +6,7 @@ import eva2.server.go.individuals.InterfaceESIndividual; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; import eva2.server.go.strategies.Tribes; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; public class TribesExplorer extends AbstractEAIndividual implements InterfaceESIndividual, InterfaceDataTypeDouble { /** @@ -158,7 +158,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI // case 3: // around a "center" // if (radius < 0) { // // Choose at random a memory -// m = RandomNumberGenerator.randomInt(swarm.tribes[fromTribe].memoryNb); +// m = RNG.randomInt(swarm.tribes[fromTribe].memoryNb); // // // Compute the distance to the "center" = radius // rho = center.distanceTo(swarm.tribes[fromTribe].memory[m].position); @@ -167,10 +167,10 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI // } // // // Define a random point in the hypersphere (center, rho) -// expl.position.setDoubleArray(RandomNumberGenerator.randHypersphere(center.getDoubleArray(), rho, 1.5)); +// expl.position.setDoubleArray(RNG.randHypersphere(center.getDoubleArray(), rho, 1.5)); // // // Define another random point -// rand_i = RandomNumberGenerator.randHypersphere(center.getDoubleArray(), rho, 1.5); +// rand_i = RNG.randHypersphere(center.getDoubleArray(), rho, 1.5); // // // Derive a random velocity // for (d = 0; d < D; d++) { @@ -188,7 +188,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI // expl.position = expl.position.maxIsolated(pb.H, swarm); // // // At this point, fitness[0] contains the "isolation" value -// rand_i = RandomNumberGenerator.randHypersphere(expl.position.getDoubleArray(), expl.position.fitness[0], 1.5); +// rand_i = RNG.randHypersphere(expl.position.getDoubleArray(), expl.position.fitness[0], 1.5); // for (d = 0; d < D; d++) { // expl.velocity.x[d] = rand_i[d] - expl.position.x[d]; // } @@ -223,14 +223,14 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI // /* On the boundary of the search space // For some dimensions, set the coordinate to the min or the max // */ -// dmax = RandomNumberGenerator.randomInt(D); // For a random number of dimensions +// dmax = RNG.randomInt(D); // For a random number of dimensions // // dmax=D-1; // For all dimensions // for (dmod = 0; dmod <= dmax; dmod++) { // // m = Tribes.generator.nextInt(2); // // if(m==0) continue; // With a probability of 1/2 // -// d = RandomNumberGenerator.randomInt(D); // 0,1, ... D-1 -// m = RandomNumberGenerator.randomInt(2); // 0 or 1 +// d = RNG.randomInt(D); // 0,1, ... D-1 +// m = RNG.randomInt(2); // 0 or 1 // if (m == 0) { // expl.position.x[d] = pb.H.xMin[d]; // } else { @@ -427,7 +427,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI // Check if fitness has to be re-evaluated fitnessEval = true; if (Tribes.blind > 0 && strategy == 6) { - if (RandomNumberGenerator.randomDouble() < Tribes.blind) { + if (RNG.randomDouble() < Tribes.blind) { fitnessEval = false; //System.out.print("\n no fitness eval"); } @@ -504,24 +504,24 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI switch (status) { default: - // strategy = RandomNumberGenerator.randomInt(4); // 0 to 3 - strategy = 1 + RandomNumberGenerator.randomInt(3); // 1 to 3 + // strategy = RNG.randomInt(4); // 0 to 3 + strategy = 1 + RNG.randomInt(3); // 1 to 3 case 1: - strategy = 1 + RandomNumberGenerator.randomInt(3); + strategy = 1 + RNG.randomInt(3); break; case 2: - strategy = 1 + RandomNumberGenerator.randomInt(3); + strategy = 1 + RNG.randomInt(3); break; case 3: - strategy = 1 + RandomNumberGenerator.randomInt(3); + strategy = 1 + RNG.randomInt(3); break; case 4: - strategy = 1 + RandomNumberGenerator.randomInt(3); + strategy = 1 + RNG.randomInt(3); break; case 5: - strategy = 1 + RandomNumberGenerator.randomInt(3); + strategy = 1 + RNG.randomInt(3); break; case 6: @@ -530,18 +530,18 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI case 7: if (statusTribe == 1) { - strategy = RandomNumberGenerator.randomInt(2); + strategy = RNG.randomInt(2); } break; case 8: if (statusTribe == 1) { - strategy = RandomNumberGenerator.randomInt(2); + strategy = RNG.randomInt(2); } break; case 9: if (statusTribe == 1) { - strategy = RandomNumberGenerator.randomInt(2); + strategy = RNG.randomInt(2); } else if (Tribes.blind > 0) { strategy = 6; // Keep moving the same way } else { @@ -586,7 +586,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI // position.Dimension = D; // // for (d = 0; d < D; d++) { -// r = RandomNumberGenerator.randomDouble(); +// r = RNG.randomDouble(); // position.x[d] = xmin[d] + (xmax[d] - xmin[d]) * r; // } // @@ -602,7 +602,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI double r; for (int i = 0; i < range.length; i++) { - r = RandomNumberGenerator.randomDouble(); + r = RNG.randomDouble(); position.x[i] = range[i][0] + (range[i][1] - range[i][0]) * r; } @@ -736,7 +736,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI switch (strategy) { case 0: // Around the best informant rho = pos1.distanceTo(pos2); - rand_i = RandomNumberGenerator.randHypersphere(pos2.getDoubleArray(), rho, 1.5); + rand_i = RNG.randHypersphere(pos2.getDoubleArray(), rho, 1.5); for (d = 0; d < velocity.x.length; d++) { velocity.x[d] = rand_i[d]-pos1.x[d]; @@ -748,7 +748,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI c0 = (pos2.getTotalError() - pos1.getTotalError()) / (pos2.getTotalError() + pos1.getTotalError()); - lambda = 1 + RandomNumberGenerator.gaussianDouble(c0); + lambda = 1 + RNG.gaussianDouble(c0); // NO BREAK HERE. Continue with case 1 @@ -757,8 +757,8 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI rho2 = rho; rho3 = rho; - rand_i = RandomNumberGenerator.randHypersphere(pos2.getDoubleArray(), rho2, 0); - rand_g = RandomNumberGenerator.randHypersphere(pos3.getDoubleArray(), rho3, 0); + rand_i = RNG.randHypersphere(pos2.getDoubleArray(), rho2, 0); + rand_g = RNG.randHypersphere(pos3.getDoubleArray(), rho3, 0); c1 = 1 / pos2.getTotalError(); c2 = 1 / pos3.getTotalError(); @@ -778,7 +778,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI case 3: // Independent Gaussians for (d = 0; d < velocity.x.length; d++) { rho2 = Math.abs(pos3.x[d] - pos2.x[d]); - r = RandomNumberGenerator.gaussianDouble(rho2); + r = RNG.gaussianDouble(rho2); velocity.x[d] = pos3.x[d] + r - pos1.x[d]; } @@ -804,8 +804,8 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI c = confCoeff[1]; for (d = 0; d < velocity.x.length; d++) { - r1 = RandomNumberGenerator.randomDouble(); // Sur [0,1] - r2 = RandomNumberGenerator.randomDouble(); + r1 = RNG.randomDouble(); // Sur [0,1] + r2 = RNG.randomDouble(); velocity.x[d] = c1 * velocity.x[d] + r1 * c * (pos2.x[d] - pos1.x[d]) + @@ -816,7 +816,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceESI break; case 6: // Keep moving the same way, with a smaller velocity (quasi-gradient) - r = RandomNumberGenerator.randomDouble() / 2; + r = RNG.randomDouble() / 2; for (d = 0; d < velocity.x.length; d++) { velocity.x[d] = r * velocity.x[d]; } @@ -835,8 +835,8 @@ Like Pivot and hyperspheres, but a velocity component is added rho2 = rho; rho3 = rho; - rand_i = RandomNumberGenerator.randHypersphere(pos2.getDoubleArray(), rho2, 0); - rand_g = RandomNumberGenerator.randHypersphere(pos3.getDoubleArray(), rho3, 0); + rand_i = RNG.randHypersphere(pos2.getDoubleArray(), rho2, 0); + rand_g = RNG.randHypersphere(pos3.getDoubleArray(), rho3, 0); c2 = 1 / pos2.getTotalError(); c3 = 1 / pos3.getTotalError(); @@ -861,8 +861,8 @@ Like Pivot and hyperspheres, but a velocity component is added c = (c1 + 1) * (c1 + 2) / 4; for (d = 0; d < velocity.x.length; d++) { - r1 = RandomNumberGenerator.randomDouble(); // Sur [0,1] - r2 = RandomNumberGenerator.randomDouble(); + r1 = RNG.randomDouble(); // Sur [0,1] + r2 = RNG.randomDouble(); velocity.x[d] = c1 * velocity.x[d] + r1 * c * (pos2.x[d] - pos1.x[d]) + diff --git a/src/eva2/server/go/strategies/tribes/TribesPosition.java b/src/eva2/server/go/strategies/tribes/TribesPosition.java index f9e7d291..db5c6460 100644 --- a/src/eva2/server/go/strategies/tribes/TribesPosition.java +++ b/src/eva2/server/go/strategies/tribes/TribesPosition.java @@ -3,7 +3,7 @@ package eva2.server.go.strategies.tribes; import java.util.Arrays; import eva2.server.go.strategies.Tribes; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; public class TribesPosition implements java.io.Serializable { @@ -700,12 +700,12 @@ public class TribesPosition implements java.io.Serializable { swarm.tribes[0].explorer[n] = explorer; for (d = 0; d < D; d++) { - r = RandomNumberGenerator.randomDouble(); + r = RNG.randomDouble(); swarm.tribes[0].explorer[n].position.x[d] = range[d][0] + (range[d][1] - range[d][0]) * r; - r = RandomNumberGenerator.randomDouble(); + r = RNG.randomDouble(); swarm.tribes[0].explorer[n].velocity.x[d] = (1 - 2 * r) * (range[d][1] - range[d][0]) / 2; @@ -743,10 +743,10 @@ public class TribesPosition implements java.io.Serializable { maxIsoLink[n][n] = 1; } for (n = 0; n < swarm.size; n++) { -// m = RandomNumberGenerator.randomInt(0,neighbourhoodSize-1); +// m = RNG.randomInt(0,neighbourhoodSize-1); // maxIsoLink[n][m] = 1; for (int k=0; k < neighbourhoodSize; k++) { - m = RandomNumberGenerator.randomInt(swarm.size); + m = RNG.randomInt(swarm.size); maxIsoLink[n][m] = 1; } } @@ -768,8 +768,8 @@ public class TribesPosition implements java.io.Serializable { // Move for (d = 0; d < D; d++) { - r1 = RandomNumberGenerator.randomDouble(); - r2 = RandomNumberGenerator.randomDouble(); + r1 = RNG.randomDouble(); + r2 = RNG.randomDouble(); xd = swarm.tribes[0].explorer[m].position.x[d]; swarm.tribes[0].explorer[m].velocity.x[d] = c1 * diff --git a/src/eva2/server/go/strategies/tribes/TribesSwarm.java b/src/eva2/server/go/strategies/tribes/TribesSwarm.java index 8d76758a..35e895a8 100644 --- a/src/eva2/server/go/strategies/tribes/TribesSwarm.java +++ b/src/eva2/server/go/strategies/tribes/TribesSwarm.java @@ -6,7 +6,7 @@ import java.util.List; import eva2.server.go.populations.Population; import eva2.server.go.problems.InterfaceOptimizationProblem; import eva2.server.go.strategies.Tribes; -import eva2.server.go.tools.RandomNumberGenerator; +import wsi.ra.math.RNG; public class TribesSwarm implements java.io.Serializable{ @@ -358,7 +358,7 @@ public class TribesSwarm implements java.io.Serializable{ int gOption; int gMin; - int gMode = RandomNumberGenerator.randomInt(2); // Random choice; + int gMode = RNG.randomInt(2); // Random choice; /* gMode: 0 = according to gener 1 = first particle (center) in the biggest not yet searched area @@ -617,7 +617,7 @@ public class TribesSwarm implements java.io.Serializable{ if (Tribes.TRACE) System.out.println("+ around center "); if (radius < 0) { // Choose at random a memory - m = RandomNumberGenerator.randomInt(this.tribes[fromTribe].memoryNb); + m = RNG.randomInt(this.tribes[fromTribe].memoryNb); // Compute the distance to the "center" = radius rho = center.distanceTo(this.tribes[fromTribe].memory[m].getPos()); @@ -626,10 +626,10 @@ public class TribesSwarm implements java.io.Serializable{ } // Define a random point in the hypersphere (center, rho) - expl.position.setDoubleArray(RandomNumberGenerator.randHypersphere(center.getDoubleArray(), rho, 1.5)); + expl.position.setDoubleArray(RNG.randHypersphere(center.getDoubleArray(), rho, 1.5)); // Define another random point - rand_i = RandomNumberGenerator.randHypersphere(center.getDoubleArray(), rho, 1.5); + rand_i = RNG.randHypersphere(center.getDoubleArray(), rho, 1.5); // Derive a random velocity for (d = 0; d < D; d++) { @@ -649,7 +649,7 @@ public class TribesSwarm implements java.io.Serializable{ expl.position = expl.position.maxIsolated((initRange == null) ? range : initRange, this); // At this point, fitness[0] contains the "isolation" value - rand_i = RandomNumberGenerator.randHypersphere(expl.position.getDoubleArray(), expl.position.fitness[0], 1.5); + rand_i = RNG.randHypersphere(expl.position.getDoubleArray(), expl.position.fitness[0], 1.5); for (d = 0; d < D; d++) { expl.velocity.x[d] = rand_i[d] - expl.position.x[d]; } @@ -679,14 +679,14 @@ public class TribesSwarm implements java.io.Serializable{ /* On the boundary of the search space For some dimensions, set the coordinate to the min or the max */ - dmax = RandomNumberGenerator.randomInt(D); // For a random number of dimensions + dmax = RNG.randomInt(D); // For a random number of dimensions // dmax=D-1; // For all dimensions for (dmod = 0; dmod <= dmax; dmod++) { // m = Tribes.generator.nextInt(2); // if(m==0) continue; // With a probability of 1/2 - d = RandomNumberGenerator.randomInt(D); // 0,1, ... D-1 - m = RandomNumberGenerator.randomInt(2); // 0 or 1 + d = RNG.randomInt(D); // 0,1, ... D-1 + m = RNG.randomInt(2); // 0 or 1 if ((initRange == null) || (initType == 0)) { expl.position.x[d] = range[d][m]; } else { diff --git a/src/eva2/server/go/tools/GONamingBox.java b/src/eva2/server/go/tools/GONamingBox.java index 368fba7f..9f7553e9 100644 --- a/src/eva2/server/go/tools/GONamingBox.java +++ b/src/eva2/server/go/tools/GONamingBox.java @@ -1,5 +1,7 @@ package eva2.server.go.tools; +import wsi.ra.math.RNG; + /** * Created by IntelliJ IDEA. * User: streiche @@ -73,6 +75,6 @@ public class GONamingBox { "Yuriy"}; public static String getRandomName() { - return new String(m_Names[RandomNumberGenerator.randomInt(0, m_Names.length-1)]); + return new String(m_Names[RNG.randomInt(0, m_Names.length-1)]); } } diff --git a/src/eva2/server/go/tools/RandomNumberGenerator.java b/src/eva2/server/go/tools/RandomNumberGenerator.java deleted file mode 100644 index 4c9b1bc4..00000000 --- a/src/eva2/server/go/tools/RandomNumberGenerator.java +++ /dev/null @@ -1,286 +0,0 @@ -package eva2.server.go.tools; - -import java.util.Random; -import java.util.ArrayList; - -public class RandomNumberGenerator extends Random { - private static Random random; - private static long randomSeed; - /** - * - */ - static { - randomSeed=System.currentTimeMillis(); - //randomSeed=(long)100.0; - //System.out.println("randomSeed ="+ randomSeed); - random=new Random(randomSeed); - } - - /** - * - */ - public static void setRandomSeed() { - //counter++; - randomSeed=System.currentTimeMillis(); - random=new Random(randomSeed); - } - /** - * - */ - public static void setRandom(Random base_random) { - //counter++; - random=base_random; - } - /** - * - */ - public static void setRandomSeed(long new_seed){ - //counter++; - randomSeed=new_seed; - if (randomSeed == 0) setRandomSeed(); - else random.setSeed(randomSeed); - } - /** - * - */ - public static long getRandomSeed() { - //counter++; - return randomSeed; - } - - /** - * Returns 0 or 1 evenly distributed. - */ - public static int randomInt() { - //counter++; - return randomInt(0,1); - } - - /** - * Returns an evenly distributes int value between zero and - * upperLim-1. - * @param upperLim upper exclusive limit of the random int - */ - public static int randomInt(int upperLim) { - //counter++; - return randomInt(0,upperLim-1); - } - - /** This method returns a evenly distributed int value. - * The boundarys are included. - * @param lo Lower bound. - * @param hi Upper bound. - * @return int - */ - public static int randomInt(int lo,int hi) { - //counter++; - int result = (Math.abs(random.nextInt())%(hi-lo+1))+lo; - if (result < lo) { - System.out.println("Result "+result+" < " +lo+"!?"); - result = lo; - } - if (result > hi) { - System.out.println("Result "+result+" > " +hi+"!?"); - result = hi; - } - return result; - } - - /** This method returns a random permutation of n int values - * @param length The number of int values - * @return The permutation [0-length-1] - */ - public static int[] randomPermutation(int length) { - boolean[] validList = new boolean[length]; - int[] result = new int[length]; - int index; - for (int i = 0; i < validList.length; i++) validList[i] = true; - for (int i = 0; i < result.length; i++) { - index = randomInt(0, length-1); - while (!validList[index]) { - index++; - if (index == length) index = 0; - } - validList[index] = false; - result[i] = index; - } - return result; - } - /** - * - */ - public static long randomLong() { - // counter++; - return randomLong(0,1); - } - /** - * - */ - public static long randomLong(long lo,long hi) { - //counter++; - return (Math.abs(random.nextLong())%(hi-lo+1))+lo; - } - /** - * - */ - public static float randomFloat() { - //counter++; - return random.nextFloat(); - } - /** - * - */ - public static float randomFloat(float lo,float hi) { - //counter++; - return (hi-lo)*random.nextFloat()+lo; - } - /** - * - */ - public static double randomDouble() { - //counter++; - return random.nextDouble(); - } - /** - * - */ - public static double randomDouble(double lo,double hi) { - //counter++; - return (hi-lo)*random.nextDouble()+lo; - } - /** - * - */ - public static double[] randomDoubleArray(double[] lo,double[] hi) { - //counter++; - double[] xin = new double[lo.length]; - for (int i=0;i 0, - * - inside a D-Gaussian if nonUnif < 0. - * For case 2, the nonUnif parameter is used as standard deviation (instead of 1/D), the parameter - * is not further used in the other two cases. - * Original code by Maurice Clerc, from the TRIBES package - * - * @param center center point of the distribution - * @param radius radius of the distribution - * @param nonUnif kind of distribution - * - **/ - public static double[] randHypersphere(double[] center, double radius, double nonUnif) { - double[] x = new double[center.length]; - int j; - double xLen, r; - int D=center.length; - -// ----------------------------------- Step 1. Direction - xLen = 0; - for (j=0; j 0) r = Math.pow(r,nonUnif); // non-uniform hypersphere - else r=Math.pow(r,1./D); // Real hypersphere - - for (j=0;j 0, + * - inside a D-Gaussian if nonUnif < 0. + * For case 2, the nonUnif parameter is used as standard deviation (instead of 1/D), the parameter + * is not further used in the other two cases. + * Original code by Maurice Clerc, from the TRIBES package + * + * @param center center point of the distribution + * @param radius radius of the distribution + * @param nonUnif kind of distribution + * + **/ + public static double[] randHypersphere(double[] center, double radius, double nonUnif) { + double[] x = new double[center.length]; + int j; + double xLen, r; + int D=center.length; + +// ----------------------------------- Step 1. Direction + xLen = 0; + for (j=0; j 0) r = Math.pow(r,nonUnif); // non-uniform hypersphere + else r=Math.pow(r,1./D); // Real hypersphere + + for (j=0;j