This commit is contained in:
parent
d55016e36e
commit
9843be0855
@ -79,7 +79,7 @@ import eva2.tools.math.RNG;
|
|||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @author mkron
|
* @author mkron
|
||||||
* @author Andreas Dräger <andreas.draeger@uni-tuebingen.de>
|
* @author <a href="mailto:andreas.draeger@uni-tuebingen.de">Andreas Dräger</a>
|
||||||
* @date 17.04.2007
|
* @date 17.04.2007
|
||||||
*/
|
*/
|
||||||
public class OptimizerFactory {
|
public class OptimizerFactory {
|
||||||
|
@ -11,33 +11,18 @@ package eva2.gui;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.GridLayout;
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Window;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.ItemEvent;
|
|
||||||
import java.awt.event.ItemListener;
|
|
||||||
import java.beans.BeanInfo;
|
import java.beans.BeanInfo;
|
||||||
import java.beans.IntrospectionException;
|
import java.beans.IntrospectionException;
|
||||||
import java.beans.Introspector;
|
import java.beans.Introspector;
|
||||||
import java.beans.MethodDescriptor;
|
import java.beans.MethodDescriptor;
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.beans.PropertyChangeSupport;
|
import java.beans.PropertyChangeSupport;
|
||||||
import java.beans.PropertyDescriptor;
|
import java.beans.PropertyDescriptor;
|
||||||
import java.beans.PropertyEditor;
|
import java.beans.PropertyEditor;
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
@ -45,18 +30,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import eva2.EvAInfo;
|
import eva2.EvAInfo;
|
||||||
import eva2.client.EvAClient;
|
import eva2.client.EvAClient;
|
||||||
import eva2.tools.EVAHELP;
|
|
||||||
import eva2.tools.ReflectPackage;
|
import eva2.tools.ReflectPackage;
|
||||||
import eva2.tools.jproxy.RMIProxyLocal;
|
import eva2.tools.jproxy.RMIProxyLocal;
|
||||||
|
|
||||||
|
@ -54,6 +54,11 @@ import eva2.tools.math.Jama.Matrix;
|
|||||||
*/
|
*/
|
||||||
public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Serializable, InterfaceAdditionalPopulationInformer {
|
public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Serializable, InterfaceAdditionalPopulationInformer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated serial version uid.
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -149996122795669589L;
|
||||||
|
|
||||||
protected Population m_Population = new Population();
|
protected Population m_Population = new Population();
|
||||||
Object[] sortedPop = null;
|
Object[] sortedPop = null;
|
||||||
protected AbstractEAIndividual m_BestIndividual;
|
protected AbstractEAIndividual m_BestIndividual;
|
||||||
|
@ -14,7 +14,6 @@ package eva2.tools.jproxy;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Proxy;
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* CLASS DECLARATION
|
* CLASS DECLARATION
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
package eva2.tools.math;
|
package eva2.tools.math;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import eva2.tools.EVAHELP;
|
|
||||||
import eva2.tools.Mathematics;
|
import eva2.tools.Mathematics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class RNG extends Random {
|
public class RNG extends Random {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1565216859128723844L;
|
||||||
private static Random random;
|
private static Random random;
|
||||||
private static long randomSeed;
|
private static long randomSeed;
|
||||||
/**
|
/**
|
||||||
@ -17,14 +22,17 @@ public class RNG extends Random {
|
|||||||
randomSeed = System.currentTimeMillis();
|
randomSeed = System.currentTimeMillis();
|
||||||
random = new Random(randomSeed);
|
random = new Random(randomSeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static void setRandomSeed(long new_seed) {
|
public static void setRandomSeed(long new_seed) {
|
||||||
// counter++;
|
// counter++;
|
||||||
randomSeed = new_seed;
|
randomSeed = new_seed;
|
||||||
if (randomSeed == 0) setRandomSeed();
|
if (randomSeed == 0)
|
||||||
else random = new Random(randomSeed);
|
setRandomSeed();
|
||||||
|
else
|
||||||
|
random = new Random(randomSeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +42,7 @@ public class RNG extends Random {
|
|||||||
randomSeed = new_seed;
|
randomSeed = new_seed;
|
||||||
random.setSeed(randomSeed);
|
random.setSeed(randomSeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -41,12 +50,14 @@ public class RNG extends Random {
|
|||||||
randomSeed = System.currentTimeMillis();
|
randomSeed = System.currentTimeMillis();
|
||||||
random = new Random(randomSeed);
|
random = new Random(randomSeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static void setRandom(Random base_random) {
|
public static void setRandom(Random base_random) {
|
||||||
random = base_random;
|
random = base_random;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -62,18 +73,23 @@ public class RNG extends Random {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an evenly distributes int value between zero and
|
* Returns an evenly distributes int value between zero and upperLim-1.
|
||||||
* upperLim-1.
|
*
|
||||||
* @param upperLim upper exclusive limit of the random int
|
* @param upperLim
|
||||||
|
* upper exclusive limit of the random int
|
||||||
*/
|
*/
|
||||||
public static int randomInt(int upperLim) {
|
public static int randomInt(int upperLim) {
|
||||||
return randomInt(0, upperLim - 1);
|
return randomInt(0, upperLim - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method returns a evenly distributed int value.
|
/**
|
||||||
* The boundarys are included.
|
* This method returns a evenly distributed int value. The boundarys are
|
||||||
* @param lo Lower bound.
|
* included.
|
||||||
* @param hi Upper bound.
|
*
|
||||||
|
* @param lo
|
||||||
|
* Lower bound.
|
||||||
|
* @param hi
|
||||||
|
* Upper bound.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static int randomInt(int lo, int hi) {
|
public static int randomInt(int lo, int hi) {
|
||||||
@ -83,26 +99,33 @@ public class RNG extends Random {
|
|||||||
}
|
}
|
||||||
int result = (Math.abs(random.nextInt()) % (hi - lo + 1)) + lo;
|
int result = (Math.abs(random.nextInt()) % (hi - lo + 1)) + lo;
|
||||||
if ((result < lo) || (result > hi)) {
|
if ((result < lo) || (result > hi)) {
|
||||||
System.err.println("Error, invalid value " + result + " in RNG.randomInt! boundaries were lo/hi: " + lo + " / " + hi);
|
System.err.println("Error, invalid value " + result
|
||||||
|
+ " in RNG.randomInt! boundaries were lo/hi: " + lo + " / "
|
||||||
|
+ hi);
|
||||||
result = Math.abs(random.nextInt() % (hi - lo + 1)) + lo;
|
result = Math.abs(random.nextInt() % (hi - lo + 1)) + lo;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method returns a random permutation of n int values
|
/**
|
||||||
* @param length The number of int values
|
* This method returns a random permutation of n int values
|
||||||
|
*
|
||||||
|
* @param length
|
||||||
|
* The number of int values
|
||||||
* @return The permutation [0-length-1]
|
* @return The permutation [0-length-1]
|
||||||
*/
|
*/
|
||||||
public static int[] randomPermutation(int length) {
|
public static int[] randomPermutation(int length) {
|
||||||
boolean[] validList = new boolean[length];
|
boolean[] validList = new boolean[length];
|
||||||
int[] result = new int[length];
|
int[] result = new int[length];
|
||||||
int index;
|
int index;
|
||||||
for (int i = 0; i < validList.length; i++) validList[i] = true;
|
for (int i = 0; i < validList.length; i++)
|
||||||
|
validList[i] = true;
|
||||||
for (int i = 0; i < result.length; i++) {
|
for (int i = 0; i < result.length; i++) {
|
||||||
index = randomInt(0, length - 1);
|
index = randomInt(0, length - 1);
|
||||||
while (!validList[index]) {
|
while (!validList[index]) {
|
||||||
index++;
|
index++;
|
||||||
if (index == length) index = 0;
|
if (index == length)
|
||||||
|
index = 0;
|
||||||
}
|
}
|
||||||
validList[index] = false;
|
validList[index] = false;
|
||||||
result[i] = index;
|
result[i] = index;
|
||||||
@ -110,8 +133,11 @@ public class RNG extends Random {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method returns a random permutation of n int values
|
/**
|
||||||
* @param length The number of int values
|
* This method returns a random permutation of n int values
|
||||||
|
*
|
||||||
|
* @param length
|
||||||
|
* The number of int values
|
||||||
* @return The permutation [0-length-1]
|
* @return The permutation [0-length-1]
|
||||||
*/
|
*/
|
||||||
public static int[] randomPerm(int length) {
|
public static int[] randomPerm(int length) {
|
||||||
@ -126,7 +152,8 @@ public class RNG extends Random {
|
|||||||
intList.remove(index);
|
intList.remove(index);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (intList.size()>1) System.err.println("Error in randomPerm!");
|
if (intList.size() > 1)
|
||||||
|
System.err.println("Error in randomPerm!");
|
||||||
result[length - 1] = intList.get(0);
|
result[length - 1] = intList.get(0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -144,24 +171,28 @@ public class RNG extends Random {
|
|||||||
public static long randomLong(long lo, long hi) {
|
public static long randomLong(long lo, long hi) {
|
||||||
return (Math.abs(random.nextLong()) % (hi - lo + 1)) + lo;
|
return (Math.abs(random.nextLong()) % (hi - lo + 1)) + lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static float randomFloat() {
|
public static float randomFloat() {
|
||||||
return random.nextFloat();
|
return random.nextFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static float randomFloat(float lo, float hi) {
|
public static float randomFloat(float lo, float hi) {
|
||||||
return (hi - lo) * random.nextFloat() + lo;
|
return (hi - lo) * random.nextFloat() + lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A random double value between 0 and 1.
|
* A random double value between 0 and 1.
|
||||||
*/
|
*/
|
||||||
public static double randomDouble() {
|
public static double randomDouble() {
|
||||||
return random.nextDouble();
|
return random.nextDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -185,19 +216,22 @@ public class RNG extends Random {
|
|||||||
public static double[] randomDoubleArray(double[][] range) {
|
public static double[] randomDoubleArray(double[][] range) {
|
||||||
double[] xin = new double[range.length];
|
double[] xin = new double[range.length];
|
||||||
for (int i = 0; i < xin.length; i++)
|
for (int i = 0; i < xin.length; i++)
|
||||||
xin[i] = (range[i][1]-range[i][0])*random.nextDouble()+range[i][0];
|
xin[i] = (range[i][1] - range[i][0]) * random.nextDouble()
|
||||||
|
+ range[i][0];
|
||||||
return xin;
|
return xin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a uniform random double vector within the given bounds (inclusive) in every dimension.
|
* Create a uniform random double vector within the given bounds (inclusive)
|
||||||
|
* in every dimension.
|
||||||
*
|
*
|
||||||
* @param lower
|
* @param lower
|
||||||
* @param upper
|
* @param upper
|
||||||
* @param size
|
* @param size
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static double[] randomDoubleArray(double lower, double upper, int size) {
|
public static double[] randomDoubleArray(double lower, double upper,
|
||||||
|
int size) {
|
||||||
double[] result = new double[size];
|
double[] result = new double[size];
|
||||||
for (int i = 0; i < result.length; i++) {
|
for (int i = 0; i < result.length; i++) {
|
||||||
result[i] = RNG.randomDouble(lower, upper);
|
result[i] = RNG.randomDouble(lower, upper);
|
||||||
@ -212,7 +246,8 @@ public class RNG extends Random {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static double[] randomDoubleArray(double[] lo,double[] hi,double[] xin) {
|
public static double[] randomDoubleArray(double[] lo, double[] hi,
|
||||||
|
double[] xin) {
|
||||||
// counter++;
|
// counter++;
|
||||||
for (int i = 0; i < lo.length; i++)
|
for (int i = 0; i < lo.length; i++)
|
||||||
xin[i] = (hi[i] - lo[i]) * random.nextDouble() + lo[i];
|
xin[i] = (hi[i] - lo[i]) * random.nextDouble() + lo[i];
|
||||||
@ -220,7 +255,8 @@ public class RNG extends Random {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a uniform random integer vector within the given bounds (inclusive) in every dimension.
|
* Create a uniform random integer vector within the given bounds
|
||||||
|
* (inclusive) in every dimension.
|
||||||
*
|
*
|
||||||
* @param n
|
* @param n
|
||||||
* @param lower
|
* @param lower
|
||||||
@ -242,6 +278,7 @@ public class RNG extends Random {
|
|||||||
// counter++;
|
// counter++;
|
||||||
return (randomInt() == 1);
|
return (randomInt() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -260,6 +297,7 @@ public class RNG extends Random {
|
|||||||
// counter++;
|
// counter++;
|
||||||
return (randomDouble() < p ? true : false);
|
return (randomDouble() < p ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -267,16 +305,19 @@ public class RNG extends Random {
|
|||||||
// counter++;
|
// counter++;
|
||||||
return (float) random.nextGaussian() * dev;
|
return (float) random.nextGaussian() * dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a Gaussian double with mean 0 and deviation dev.
|
* Return a Gaussian double with mean 0 and deviation dev.
|
||||||
*
|
*
|
||||||
* @param dev the deviation of the distribution.
|
* @param dev
|
||||||
|
* the deviation of the distribution.
|
||||||
* @return a Gaussian double with mean 0 and given deviation.
|
* @return a Gaussian double with mean 0 and given deviation.
|
||||||
*/
|
*/
|
||||||
public static double gaussianDouble(double dev) {
|
public static double gaussianDouble(double dev) {
|
||||||
// counter++;
|
// counter++;
|
||||||
return random.nextGaussian() * dev;
|
return random.nextGaussian() * dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -284,6 +325,7 @@ public class RNG extends Random {
|
|||||||
// counter++;
|
// counter++;
|
||||||
return (float) (-mean * Math.log(randomDouble()));
|
return (float) (-mean * Math.log(randomDouble()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -293,20 +335,23 @@ public class RNG extends Random {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a vector denoting a random point around the center
|
* Returns a vector denoting a random point around the center - inside a
|
||||||
* - inside a hypersphere of uniform distribution if nonUnif=0,
|
* hypersphere of uniform distribution if nonUnif=0, - inside a hypersphere
|
||||||
* - inside a hypersphere of non-uniform distribution if nonUnif > 0,
|
* of non-uniform distribution if nonUnif > 0, - inside a D-Gaussian if
|
||||||
* - inside a D-Gaussian if nonUnif < 0.
|
* nonUnif < 0. For case 2, the nonUnif parameter is used as standard
|
||||||
* For case 2, the nonUnif parameter is used as standard deviation (instead of 1/D), the parameter
|
* deviation (instead of 1/D), the parameter is not further used in the
|
||||||
* is not further used in the other two cases.
|
* other two cases. Original code by Maurice Clerc, from the TRIBES package
|
||||||
* Original code by Maurice Clerc, from the TRIBES package
|
|
||||||
*
|
*
|
||||||
* @param center center point of the distribution
|
* @param center
|
||||||
* @param radius radius of the distribution
|
* center point of the distribution
|
||||||
* @param nonUnif kind of distribution
|
* @param radius
|
||||||
|
* radius of the distribution
|
||||||
|
* @param nonUnif
|
||||||
|
* kind of distribution
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
public static double[] randHypersphere(double[] center, double radius, double nonUnif) {
|
public static double[] randHypersphere(double[] center, double radius,
|
||||||
|
double nonUnif) {
|
||||||
double[] x = new double[center.length];
|
double[] x = new double[center.length];
|
||||||
int j;
|
int j;
|
||||||
double xLen, r;
|
double xLen, r;
|
||||||
@ -325,9 +370,12 @@ public class RNG extends Random {
|
|||||||
// ----------------------------------- Step 2. Random radius
|
// ----------------------------------- Step 2. Random radius
|
||||||
|
|
||||||
r = randomDouble();
|
r = randomDouble();
|
||||||
if (nonUnif < 0) r = gaussianDouble(r/2); // D-Gaussian
|
if (nonUnif < 0)
|
||||||
else if (nonUnif > 0) r = Math.pow(r,nonUnif); // non-uniform hypersphere
|
r = gaussianDouble(r / 2); // D-Gaussian
|
||||||
else r=Math.pow(r,1./D); // Real hypersphere
|
else if (nonUnif > 0)
|
||||||
|
r = Math.pow(r, nonUnif); // non-uniform hypersphere
|
||||||
|
else
|
||||||
|
r = Math.pow(r, 1. / D); // Real hypersphere
|
||||||
|
|
||||||
for (j = 0; j < D; j++) {
|
for (j = 0; j < D; j++) {
|
||||||
x[j] = center[j] + radius * r * x[j] / xLen;
|
x[j] = center[j] + radius * r * x[j] / xLen;
|
||||||
@ -337,8 +385,11 @@ public class RNG extends Random {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds Gaussian noise to a double vector
|
* Adds Gaussian noise to a double vector
|
||||||
* @param v the double vector
|
*
|
||||||
* @param dev the Gaussian deviation
|
* @param v
|
||||||
|
* the double vector
|
||||||
|
* @param dev
|
||||||
|
* the Gaussian deviation
|
||||||
*/
|
*/
|
||||||
public static void addNoise(double[] v, double dev) {
|
public static void addNoise(double[] v, double dev) {
|
||||||
for (int i = 0; i < v.length; i++) {
|
for (int i = 0; i < v.length; i++) {
|
||||||
@ -366,15 +417,16 @@ public class RNG extends Random {
|
|||||||
* @param n
|
* @param n
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static double[] gaussianVector(double dev, double[] result, boolean normalize) {
|
public static double[] gaussianVector(double dev, double[] result,
|
||||||
|
boolean normalize) {
|
||||||
for (int i = 0; i < result.length; i++) {
|
for (int i = 0; i < result.length; i++) {
|
||||||
result[i] = RNG.gaussianDouble(dev);
|
result[i] = RNG.gaussianDouble(dev);
|
||||||
}
|
}
|
||||||
if (normalize) Mathematics.normVect(result, result);
|
if (normalize)
|
||||||
|
Mathematics.normVect(result, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public static int testRndInt(long seed, int bits) {
|
// public static int testRndInt(long seed, int bits) {
|
||||||
// return (int)(seed >>> (48 - bits));
|
// return (int)(seed >>> (48 - bits));
|
||||||
// }
|
// }
|
||||||
@ -386,8 +438,10 @@ public class RNG extends Random {
|
|||||||
// }
|
// }
|
||||||
// int result = (Math.abs(testRndInt(seed,32))%(hi-lo+1))+lo;
|
// int result = (Math.abs(testRndInt(seed,32))%(hi-lo+1))+lo;
|
||||||
// if ((result < lo) || (result > hi)) {
|
// if ((result < lo) || (result > hi)) {
|
||||||
// System.err.println("Error, invalid value " + result + " in RNG.randomInt! boundaries were lo/hi: " + lo + " / " + hi);
|
// System.err.println("Error, invalid value " + result +
|
||||||
// System.out.println("Error, invalid value " + result + " in RNG.randomInt! boundaries were lo/hi: " + lo + " / " + hi);
|
// " in RNG.randomInt! boundaries were lo/hi: " + lo + " / " + hi);
|
||||||
|
// System.out.println("Error, invalid value " + result +
|
||||||
|
// " in RNG.randomInt! boundaries were lo/hi: " + lo + " / " + hi);
|
||||||
// }
|
// }
|
||||||
// return result;
|
// return result;
|
||||||
// }
|
// }
|
||||||
@ -411,7 +465,8 @@ public class RNG extends Random {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a uniform random double vector within the given bounds (inclusive) in every dimension.
|
* Create a uniform random double vector within the given bounds (inclusive)
|
||||||
|
* in every dimension.
|
||||||
*
|
*
|
||||||
* @param n
|
* @param n
|
||||||
* @param lower
|
* @param lower
|
||||||
@ -425,5 +480,4 @@ public class RNG extends Random {
|
|||||||
// }
|
// }
|
||||||
// return result;
|
// return result;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user