List of usage examples for org.apache.commons.math3.distribution UniformRealDistribution UniformRealDistribution
public UniformRealDistribution()
From source file:it.cnr.isti.smartfed.federation.generation.AbstractGenerator.java
public AbstractGenerator(long seed) { distribution = new UniformRealDistribution(); type = GenerationType.UNIFORM; this.resetSeed(seed); }
From source file:com.vsthost.rnd.StructuralTest.java
@Test public void isItRunningAtAll() { // Create an instance of a problem: Problem problem = new Problem(new double[] { -1, -1 }, new double[] { 1, 1 }); // Define an objective: Objective objective = candidate -> Math.abs(SillyFormula(candidate[0], candidate[1])); // Define an empty strategy: Strategy strategy = (population, problem1, objective1) -> { };/*from w w w .j a v a2 s. c o m*/ // Initialize a population: Population population = new Population(100, 2, new double[] { -1, -1 }, new double[] { 1, 1 }, new UniformRealDistribution()); // Define the diagnostics: Diagnostics diagnostics = new Diagnostics(true, true); // Define the DE instance: DEoptim DEoptim = new DEoptim(10, problem, objective, strategy, population, diagnostics); // Run it: DEoptim.evolve(); }
From source file:it.cnr.isti.smartfed.federation.generation.ApplicationGenerator.java
/** * Return an application whose cloudlets are assigned to vertex with * an uniform distribution. /*from w w w.j av a 2s . c o m*/ * @param userId * @param numVertex * @param numCloudlet * @return */ public Application getApplication(int userId, int numVertex, int numCloudlet) { UniformRealDistribution urd = new UniformRealDistribution(); urd.reseedRandomGenerator(this.seed); return this.getApplication(userId, numVertex, numCloudlet, urd); }
From source file:com.vsthost.rnd.SandboxStrategyTest.java
@Test public void isItEvolving() { // Create an instance of a problem: Problem problem = new Problem(new double[] { -1, -1 }, new double[] { 1, 1 }); // Define an objective: Objective objective = candidate -> Math.abs(SillyFormula(candidate[0], candidate[1])); // Define a strategy: Strategy strategy = new SandboxStrategy(0.75, 0.8, 0.1, new MersenneTwister()); // Initialize a population: Population population = new Population(20, 2, new double[] { -1, -1 }, new double[] { 1, 1 }, new UniformRealDistribution()); // Define the diagnostics: Diagnostics diagnostics = new Diagnostics(true, true); // Define the DE instance: DEoptim DEoptim = new DEoptim(50, problem, objective, strategy, population, diagnostics); // Run it:/*from w w w . ja v a2s .com*/ DEoptim.evolve(); // Compare the first score to the best: assertTrue(diagnostics.getEntries().get(0).score >= diagnostics.getBestScore()); }
From source file:it.cnr.isti.smartfed.papers.qbrokage.ApplicationGenerator.java
public Application getApplication(int userId, int numVertex, int numCloudlet) { UniformRealDistribution urd = new UniformRealDistribution(); urd.reseedRandomGenerator(this.seed); return this.getApplication(userId, numVertex, numCloudlet, urd); }
From source file:com.vsthost.rnd.StructuralTest.java
@Test public void isItEvolving() { // Create an instance of a problem: Problem problem = new Problem(new double[] { -1, -1 }, new double[] { 1, 1 }); // Define an objective: Objective objective = candidate -> Math.abs(SillyFormula(candidate[0], candidate[1])); // Define a strategy: Strategy strategy = new SimpleStrategy(0.75, 0.8, new MersenneTwister()); // Initialize a population: Population population = new Population(10, 2, new double[] { -1, -1 }, new double[] { 1, 1 }, new UniformRealDistribution()); // Define the diagnostics: Diagnostics diagnostics = new Diagnostics(true, true); // Define the DE instance: DEoptim DEoptim = new DEoptim(50, problem, objective, strategy, population, diagnostics); // Run it:// www. j a v a 2 s. com DEoptim.evolve(); // Compare the first score to the best: assertTrue(diagnostics.getEntries().get(0).score >= diagnostics.getBestScore()); }
From source file:it.cnr.isti.smartfed.federation.generation.DatacenterGenerator.java
/** * Generates the list of datacenters by assigning hosts to datacenters according * to a uniform distribution. If a datacenter will result with 0 hosts, it will not * be created./*from ww w .j av a2 s . c o m*/ * * @param numOfDatacenters * @param numHost * @return */ public List<FederationDatacenter> getDatacenters(int numOfDatacenters, int numHost) { UniformRealDistribution urd = new UniformRealDistribution(); urd.reseedRandomGenerator(this.seed); return getDatacenters(numOfDatacenters, numHost, urd); }
From source file:com.github.tteofili.looseen.yay.SGM.java
private RealMatrix[] initWeights() { int[] conf = new int[] { configuration.inputs, configuration.vectorSize, configuration.outputs }; int[] layers = new int[conf.length]; System.arraycopy(conf, 0, layers, 0, layers.length); int weightsCount = layers.length - 1; RealMatrix[] initialWeights = new RealMatrix[weightsCount]; for (int i = 0; i < weightsCount; i++) { RealMatrix matrix = MatrixUtils.createRealMatrix(layers[i + 1], layers[i]); UniformRealDistribution uniformRealDistribution = new UniformRealDistribution(); double[] vs = uniformRealDistribution.sample(matrix.getRowDimension() * matrix.getColumnDimension()); int r = 0; int c = 0; for (double v : vs) { matrix.setEntry(r % matrix.getRowDimension(), c % matrix.getColumnDimension(), v); r++;/*from w w w . ja va2 s . c o m*/ c++; } initialWeights[i] = matrix; } return initialWeights; }