org.apache.commons.math.random.RandomGenerator Java Examples
The following examples show how to use
org.apache.commons.math.random.RandomGenerator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NaturalRankingTest.java From astor with GNU General Public License v2.0 | 6 votes |
public void testNaNsFixedTiesRandom() { RandomGenerator randomGenerator = new JDKRandomGenerator(); randomGenerator.setSeed(1000); NaturalRanking ranking = new NaturalRanking(NaNStrategy.FIXED, randomGenerator); double[] ranks = ranking.rank(exampleData); double[] correctRanks = { 5, 4, 6, 7, 3, 8, Double.NaN, 1, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesFirst); correctRanks = new double[] { 1, 1, 4, 3, 5 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesLast); correctRanks = new double[] { 3, 4, 2, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleNaNs); correctRanks = new double[] { 1, 2, Double.NaN, Double.NaN }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleTies); correctRanks = new double[] { 3, 2, 5, 5, 7, 6, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(allSame); correctRanks = new double[] { 1, 3, 4, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); }
Example #2
Source File: NaturalRankingTest.java From astor with GNU General Public License v2.0 | 6 votes |
public void testNaNsFixedTiesRandom() { RandomGenerator randomGenerator = new JDKRandomGenerator(); randomGenerator.setSeed(1000); NaturalRanking ranking = new NaturalRanking(NaNStrategy.FIXED, randomGenerator); double[] ranks = ranking.rank(exampleData); double[] correctRanks = { 5, 4, 6, 7, 3, 8, Double.NaN, 1, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesFirst); correctRanks = new double[] { 1, 1, 4, 3, 5 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesLast); correctRanks = new double[] { 3, 4, 2, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleNaNs); correctRanks = new double[] { 1, 2, Double.NaN, Double.NaN }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleTies); correctRanks = new double[] { 3, 2, 5, 5, 7, 6, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(allSame); correctRanks = new double[] { 1, 3, 4, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); }
Example #3
Source File: NaturalRankingTest.java From astor with GNU General Public License v2.0 | 6 votes |
public void testNaNsFixedTiesRandom() { RandomGenerator randomGenerator = new JDKRandomGenerator(); randomGenerator.setSeed(1000); NaturalRanking ranking = new NaturalRanking(NaNStrategy.FIXED, randomGenerator); double[] ranks = ranking.rank(exampleData); double[] correctRanks = { 5, 4, 6, 7, 3, 8, Double.NaN, 1, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesFirst); correctRanks = new double[] { 1, 1, 4, 3, 5 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesLast); correctRanks = new double[] { 3, 4, 2, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleNaNs); correctRanks = new double[] { 1, 2, Double.NaN, Double.NaN }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleTies); correctRanks = new double[] { 3, 2, 5, 5, 7, 6, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(allSame); correctRanks = new double[] { 1, 3, 4, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); }
Example #4
Source File: NaturalRankingTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testNaNsFixedTiesRandom() { RandomGenerator randomGenerator = new JDKRandomGenerator(); randomGenerator.setSeed(1000); NaturalRanking ranking = new NaturalRanking(NaNStrategy.FIXED, randomGenerator); double[] ranks = ranking.rank(exampleData); double[] correctRanks = { 5, 4, 6, 7, 3, 8, Double.NaN, 1, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesFirst); correctRanks = new double[] { 1, 1, 4, 3, 5 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesLast); correctRanks = new double[] { 3, 4, 2, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleNaNs); correctRanks = new double[] { 1, 2, Double.NaN, Double.NaN }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleTies); correctRanks = new double[] { 3, 2, 5, 5, 7, 6, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(allSame); correctRanks = new double[] { 1, 3, 4, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); }
Example #5
Source File: NaturalRankingTest.java From astor with GNU General Public License v2.0 | 6 votes |
public void testNaNsFixedTiesRandom() { RandomGenerator randomGenerator = new JDKRandomGenerator(); randomGenerator.setSeed(1000); NaturalRanking ranking = new NaturalRanking(NaNStrategy.FIXED, randomGenerator); double[] ranks = ranking.rank(exampleData); double[] correctRanks = { 5, 4, 6, 7, 3, 8, Double.NaN, 1, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesFirst); correctRanks = new double[] { 1, 1, 4, 3, 5 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesLast); correctRanks = new double[] { 3, 4, 2, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleNaNs); correctRanks = new double[] { 1, 2, Double.NaN, Double.NaN }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleTies); correctRanks = new double[] { 3, 2, 5, 5, 7, 6, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(allSame); correctRanks = new double[] { 1, 3, 4, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); }
Example #6
Source File: NaturalRankingTest.java From astor with GNU General Public License v2.0 | 6 votes |
public void testNaNsFixedTiesRandom() { RandomGenerator randomGenerator = new JDKRandomGenerator(); randomGenerator.setSeed(1000); NaturalRanking ranking = new NaturalRanking(NaNStrategy.FIXED, randomGenerator); double[] ranks = ranking.rank(exampleData); double[] correctRanks = { 5, 4, 6, 7, 3, 8, Double.NaN, 1, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesFirst); correctRanks = new double[] { 1, 1, 4, 3, 5 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesLast); correctRanks = new double[] { 3, 4, 2, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleNaNs); correctRanks = new double[] { 1, 2, Double.NaN, Double.NaN }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleTies); correctRanks = new double[] { 3, 2, 5, 5, 7, 6, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(allSame); correctRanks = new double[] { 1, 3, 4, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); }
Example #7
Source File: LSHCreator.java From datafu with Apache License 2.0 | 6 votes |
/** * * @param rg The random generator to use when constructing the family * @return The family of locality sensitive hashes * @throws MathException MathException */ public LSHFamily constructFamily(RandomGenerator rg) throws MathException { List<LSH> hashes = new ArrayList<LSH>(); for(int i = 0;i < getNumHashes();++i) { LSH lsh = null; if(getNumInternalRepetitions() == 1) { // in the situation of 1, we don't do a composite of 1..we just pass the raw LSH back lsh = constructLSH(rg); } else { List<LSH> lshFamily = new ArrayList<LSH>(); for(int j = 0;j < getNumInternalRepetitions();++j) { lshFamily.add(constructLSH(rg)); } lsh = new RepeatingLSH(lshFamily); } hashes.add(lsh); } return new LSHFamily(hashes); }
Example #8
Source File: NaturalRankingTest.java From astor with GNU General Public License v2.0 | 6 votes |
public void testNaNsFixedTiesRandom() { RandomGenerator randomGenerator = new JDKRandomGenerator(); randomGenerator.setSeed(1000); NaturalRanking ranking = new NaturalRanking(NaNStrategy.FIXED, randomGenerator); double[] ranks = ranking.rank(exampleData); double[] correctRanks = { 5, 4, 6, 7, 3, 8, Double.NaN, 1, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesFirst); correctRanks = new double[] { 1, 1, 4, 3, 5 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesLast); correctRanks = new double[] { 3, 4, 2, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleNaNs); correctRanks = new double[] { 1, 2, Double.NaN, Double.NaN }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleTies); correctRanks = new double[] { 3, 2, 5, 5, 7, 6, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(allSame); correctRanks = new double[] { 1, 3, 4, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); }
Example #9
Source File: NaturalRankingTest.java From astor with GNU General Public License v2.0 | 6 votes |
public void testNaNsFixedTiesRandom() { RandomGenerator randomGenerator = new JDKRandomGenerator(); randomGenerator.setSeed(1000); NaturalRanking ranking = new NaturalRanking(NaNStrategy.FIXED, randomGenerator); double[] ranks = ranking.rank(exampleData); double[] correctRanks = { 5, 4, 6, 7, 3, 8, Double.NaN, 1, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesFirst); correctRanks = new double[] { 1, 1, 4, 3, 5 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(tiesLast); correctRanks = new double[] { 3, 4, 2, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleNaNs); correctRanks = new double[] { 1, 2, Double.NaN, Double.NaN }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(multipleTies); correctRanks = new double[] { 3, 2, 5, 5, 7, 6, 1 }; TestUtils.assertEquals(correctRanks, ranks, 0d); ranks = ranking.rank(allSame); correctRanks = new double[] { 1, 3, 4, 4 }; TestUtils.assertEquals(correctRanks, ranks, 0d); }
Example #10
Source File: MultiStartUnivariateRealOptimizer.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Create a multi-start optimizer from a single-start optimizer. * * @param optimizer Single-start optimizer to wrap. * @param starts Number of starts to perform. If {@code starts == 1}, * the {@code optimize} methods will return the same solution as * {@code optimizer} would. * @param generator Random generator to use for restarts. * @throws NullArgumentException if {@code optimizer} or {@code generator} * is {@code null}. * @throws NotStrictlyPositiveException if {@code starts < 1}. */ public MultiStartUnivariateRealOptimizer(final BaseUnivariateRealOptimizer<FUNC> optimizer, final int starts, final RandomGenerator generator) { if (optimizer == null || generator == null) { throw new NullArgumentException(); } if (starts < 1) { throw new NotStrictlyPositiveException(starts); } this.optimizer = optimizer; this.starts = starts; this.generator = generator; }
Example #11
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with the given NaNStrategy, TiesStrategy.RANDOM * and the given source of random data. * * @param nanStrategy NaNStrategy to use * @param randomGenerator source of random data */ public NaturalRanking(NaNStrategy nanStrategy, RandomGenerator randomGenerator) { super(); this.nanStrategy = nanStrategy; this.tiesStrategy = TiesStrategy.RANDOM; randomData = new RandomDataImpl(randomGenerator); }
Example #12
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with the given NaNStrategy, TiesStrategy.RANDOM * and the given source of random data. * * @param nanStrategy NaNStrategy to use * @param randomGenerator source of random data */ public NaturalRanking(NaNStrategy nanStrategy, RandomGenerator randomGenerator) { super(); this.nanStrategy = nanStrategy; this.tiesStrategy = TiesStrategy.RANDOM; randomData = new RandomDataImpl(randomGenerator); }
Example #13
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with the given NaNStrategy, TiesStrategy.RANDOM * and the given source of random data. * * @param nanStrategy NaNStrategy to use * @param randomGenerator source of random data */ public NaturalRanking(NaNStrategy nanStrategy, RandomGenerator randomGenerator) { super(); this.nanStrategy = nanStrategy; this.tiesStrategy = TiesStrategy.RANDOM; randomData = new RandomDataImpl(randomGenerator); }
Example #14
Source File: MultiStartUnivariateRealOptimizer.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a multi-start optimizer from a single-start optimizer * @param optimizer single-start optimizer to wrap * @param starts number of starts to perform (including the * first one), multi-start is disabled if value is less than or * equal to 1 * @param generator random generator to use for restarts */ public MultiStartUnivariateRealOptimizer(final UnivariateRealOptimizer optimizer, final int starts, final RandomGenerator generator) { this.optimizer = optimizer; this.totalIterations = 0; this.starts = starts; this.generator = generator; this.optima = null; setMaximalIterationCount(Integer.MAX_VALUE); setMaxEvaluations(Integer.MAX_VALUE); }
Example #15
Source File: L1PStableHash.java From datafu with Apache License 2.0 | 5 votes |
@Override protected LSHCreator createLSHCreator() { return new LSHCreator(dim, numHashes, repeat, getSeed()) { @Override protected LSH constructLSH(RandomGenerator rg) throws MathException { return new L1LSH(dim, w, rg ); } }; }
Example #16
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with TiesStrategy.RANDOM and the given * RandomGenerator as the source of random data. * * @param randomGenerator source of random data */ public NaturalRanking(RandomGenerator randomGenerator) { super(); this.tiesStrategy = TiesStrategy.RANDOM; nanStrategy = DEFAULT_NAN_STRATEGY; randomData = new RandomDataImpl(randomGenerator); }
Example #17
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with the given NaNStrategy, TiesStrategy.RANDOM * and the given source of random data. * * @param nanStrategy NaNStrategy to use * @param randomGenerator source of random data */ public NaturalRanking(NaNStrategy nanStrategy, RandomGenerator randomGenerator) { super(); this.nanStrategy = nanStrategy; this.tiesStrategy = TiesStrategy.RANDOM; randomData = new RandomDataImpl(randomGenerator); }
Example #18
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with TiesStrategy.RANDOM and the given * RandomGenerator as the source of random data. * * @param randomGenerator source of random data */ public NaturalRanking(RandomGenerator randomGenerator) { super(); this.tiesStrategy = TiesStrategy.RANDOM; nanStrategy = DEFAULT_NAN_STRATEGY; randomData = new RandomDataImpl(randomGenerator); }
Example #19
Source File: MultiStartUnivariateRealOptimizer.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a multi-start optimizer from a single-start optimizer * @param optimizer single-start optimizer to wrap * @param starts number of starts to perform (including the * first one), multi-start is disabled if value is less than or * equal to 1 * @param generator random generator to use for restarts */ public MultiStartUnivariateRealOptimizer(final UnivariateRealOptimizer optimizer, final int starts, final RandomGenerator generator) { this.optimizer = optimizer; this.totalIterations = 0; this.starts = starts; this.generator = generator; this.optima = null; setMaximalIterationCount(Integer.MAX_VALUE); setMaxEvaluations(Integer.MAX_VALUE); }
Example #20
Source File: MultiStartUnivariateRealOptimizer.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a multi-start optimizer from a single-start optimizer * @param optimizer single-start optimizer to wrap * @param starts number of starts to perform (including the * first one), multi-start is disabled if value is less than or * equal to 1 * @param generator random generator to use for restarts */ public MultiStartUnivariateRealOptimizer(final UnivariateRealOptimizer optimizer, final int starts, final RandomGenerator generator) { this.optimizer = optimizer; this.totalIterations = 0; this.starts = starts; this.generator = generator; this.optima = null; setMaximalIterationCount(Integer.MAX_VALUE); setMaxEvaluations(Integer.MAX_VALUE); }
Example #21
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with the given NaNStrategy, TiesStrategy.RANDOM * and the given source of random data. * * @param nanStrategy NaNStrategy to use * @param randomGenerator source of random data */ public NaturalRanking(NaNStrategy nanStrategy, RandomGenerator randomGenerator) { super(); this.nanStrategy = nanStrategy; this.tiesStrategy = TiesStrategy.RANDOM; randomData = new RandomDataImpl(randomGenerator); }
Example #22
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with the given NaNStrategy, TiesStrategy.RANDOM * and the given source of random data. * * @param nanStrategy NaNStrategy to use * @param randomGenerator source of random data */ public NaturalRanking(NaNStrategy nanStrategy, RandomGenerator randomGenerator) { super(); this.nanStrategy = nanStrategy; this.tiesStrategy = TiesStrategy.RANDOM; randomData = new RandomDataImpl(randomGenerator); }
Example #23
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with TiesStrategy.RANDOM and the given * RandomGenerator as the source of random data. * * @param randomGenerator source of random data */ public NaturalRanking(RandomGenerator randomGenerator) { super(); this.tiesStrategy = TiesStrategy.RANDOM; nanStrategy = DEFAULT_NAN_STRATEGY; randomData = new RandomDataImpl(randomGenerator); }
Example #24
Source File: MultiStartUnivariateRealOptimizer.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a multi-start optimizer from a single-start optimizer * @param optimizer single-start optimizer to wrap * @param starts number of starts to perform (including the * first one), multi-start is disabled if value is less than or * equal to 1 * @param generator random generator to use for restarts */ public MultiStartUnivariateRealOptimizer(final UnivariateRealOptimizer optimizer, final int starts, final RandomGenerator generator) { this.optimizer = optimizer; this.totalIterations = 0; this.starts = starts; this.generator = generator; this.optima = null; setMaximalIterationCount(Integer.MAX_VALUE); setMaxEvaluations(Integer.MAX_VALUE); }
Example #25
Source File: LSHPigTest.java From datafu with Apache License 2.0 | 5 votes |
@Test public void testL1UDF() throws Exception { setMemorySettings(); RandomGenerator rg = new JDKRandomGenerator(); rg.setSeed(0); RandomData rd = new RandomDataImpl(rg); int n = 1000; List<RealVector> vectors = LSHTest.getVectors(rd, 1000, n); PigTest test = createPigTestFromString(l1Test); writeLinesToFile("input", getLines(vectors)); List<RealVector> queries = LSHTest.getVectors(rd, 1000, 10); writeLinesToFile("queries", getLines(queries)); test.runScript(); List<Tuple> neighbors = this.getLinesForAlias(test, "NEIGHBOR_CNT"); Assert.assertEquals( queries.size(), neighbors.size() ); for(long cnt : getCounts(neighbors)) { Assert.assertTrue(cnt >= 3); } Distance d = new Distance() { @Override public double distance(RealVector v1, RealVector v2) { return L1.distance(v1, v2); } }; verifyPoints(neighbors, d, 1000); }
Example #26
Source File: LSHPigTest.java From datafu with Apache License 2.0 | 5 votes |
@Test public void testCosineUDF() throws Exception { setMemorySettings(); RandomGenerator rg = new JDKRandomGenerator(); rg.setSeed(0); RandomData rd = new RandomDataImpl(rg); int n = 1000; List<RealVector> vectors = LSHTest.getVectors(rd, 1000, n); PigTest test = createPigTestFromString(cosTest); writeLinesToFile("input", getLines(vectors)); List<RealVector> queries = LSHTest.getVectors(rd, 1000, 10); writeLinesToFile("queries", getLines(queries)); test.runScript(); List<Tuple> neighbors = this.getLinesForAlias(test, "NEIGHBOR_CNT"); Assert.assertEquals( queries.size(), neighbors.size() ); for(long cnt : getCounts(neighbors)) { Assert.assertTrue(cnt >= 2); } Distance d = new Distance() { @Override public double distance(RealVector v1, RealVector v2) { return Cosine.distance(v1, v2); } }; verifyPoints(neighbors, d, .001); }
Example #27
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with the given NaNStrategy, TiesStrategy.RANDOM * and the given source of random data. * * @param nanStrategy NaNStrategy to use * @param randomGenerator source of random data */ public NaturalRanking(NaNStrategy nanStrategy, RandomGenerator randomGenerator) { super(); this.nanStrategy = nanStrategy; this.tiesStrategy = TiesStrategy.RANDOM; randomData = new RandomDataImpl(randomGenerator); }
Example #28
Source File: DirectSearchOptimizer.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** Minimizes a cost function. * <p>The initial simplex is built from two vertices that are * considered to represent two opposite vertices of a box parallel * to the canonical axes of the space. The simplex is the subset of * vertices encountered while going from vertexA to vertexB * traveling along the box edges only. This can be seen as a scaled * regular simplex using the projected separation between the given * points as the scaling factor along each coordinate axis.</p> * <p>The optimization is performed in multi-start mode.</p> * @param f cost function * @param maxEvaluations maximal number of function calls for each * start (note that the number will be checked <em>after</em> * complete simplices have been evaluated, this means that in some * cases this number will be exceeded by a few units, depending on * the dimension of the problem) * @param checker object to use to check for convergence * @param vertexA first vertex * @param vertexB last vertex * @param starts number of starts to perform (including the * first one), multi-start is disabled if value is less than or * equal to 1 * @param seed seed for the random vector generator * @return the point/cost pairs giving the minimal cost * @exception CostException if the cost function throws one during * the search * @exception ConvergenceException if none of the starts did * converge (it is not thrown if at least one start did converge) */ public PointCostPair minimize(CostFunction f, int maxEvaluations, ConvergenceChecker checker, double[] vertexA, double[] vertexB, int starts, long seed) throws CostException, ConvergenceException { // set up the simplex traveling around the box buildSimplex(vertexA, vertexB); // we consider the simplex could have been produced by a generator // having its mean value at the center of the box, the standard // deviation along each axe being the corresponding half size double[] mean = new double[vertexA.length]; double[] standardDeviation = new double[vertexA.length]; for (int i = 0; i < vertexA.length; ++i) { mean[i] = 0.5 * (vertexA[i] + vertexB[i]); standardDeviation[i] = 0.5 * Math.abs(vertexA[i] - vertexB[i]); } RandomGenerator rg = new JDKRandomGenerator(); rg.setSeed(seed); UniformRandomGenerator urg = new UniformRandomGenerator(rg); RandomVectorGenerator rvg = new UncorrelatedRandomVectorGenerator(mean, standardDeviation, urg); setMultiStart(starts, rvg); // compute minimum return minimize(f, maxEvaluations, checker); }
Example #29
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with TiesStrategy.RANDOM and the given * RandomGenerator as the source of random data. * * @param randomGenerator source of random data */ public NaturalRanking(RandomGenerator randomGenerator) { super(); this.tiesStrategy = TiesStrategy.RANDOM; nanStrategy = DEFAULT_NAN_STRATEGY; randomData = new RandomDataImpl(randomGenerator); }
Example #30
Source File: NaturalRanking.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a NaturalRanking with TiesStrategy.RANDOM and the given * RandomGenerator as the source of random data. * * @param randomGenerator source of random data */ public NaturalRanking(RandomGenerator randomGenerator) { super(); this.tiesStrategy = TiesStrategy.RANDOM; nanStrategy = DEFAULT_NAN_STRATEGY; randomData = new RandomDataImpl(randomGenerator); }