List of usage examples for org.apache.commons.math3.random SobolSequenceGenerator SobolSequenceGenerator
public SobolSequenceGenerator(final int dimension) throws OutOfRangeException
From source file:exploration.rendezvous.MultiPointRendezvousStrategy.java
public static LinkedList<NearRVPoint> generateSobolPoints(OccupancyGrid grid, double density) { SobolSequenceGenerator sobolGen = new SobolSequenceGenerator(2); //int numPointsToGenerate = grid.getNumFreeCells() * 150 / 432000; int numPointsToGenerate = (int) (grid.getNumFreeCells() / density); //roughly every 20 sq. cells if (SimConstants.DEBUG_OUTPUT) { System.out.println("Generating " + numPointsToGenerate + " Sobol points"); }//from w w w .java 2 s . c om LinkedList<NearRVPoint> genPoints = new LinkedList<NearRVPoint>(); for (int i = 0; i < numPointsToGenerate; i++) { int x = 0; int y = 0; double[] vector; do { vector = sobolGen.nextVector(); x = (int) (vector[0] * grid.width); y = (int) (vector[1] * grid.height); } while (!grid.freeSpaceAt(x, y)); NearRVPoint pd = new NearRVPoint(x, y); /*simConfig.getEnv().setPathStart(pd.point); simConfig.getEnv().setPathGoal(expLocation); simConfig.getEnv().getTopologicalPath(false); pd.distance1 = simConfig.getEnv().getPath().getLength(); simConfig.getEnv().setPathStart(pd.point); simConfig.getEnv().setPathGoal(relLocation); simConfig.getEnv().getTopologicalPath(false); pd.distance2 = simConfig.getEnv().getPath().getLength();*/ genPoints.add(pd); //freeSpace.remove(index); } return genPoints; }
From source file:jeplus.JEPlusProject.java
public String[][] getSobolJobList(int LHSsize, Random randomsrc) { if (randomsrc == null) randomsrc = RandomSource.getRandomGenerator(); String[][] JobList = new String[LHSsize][]; // Get all parameters (inc. idf and weather) and their distributions if (ParamTree != null) { // Create sample for each parameter String[][] SampledValues = getSampleInEqualProbSegments(LHSsize, randomsrc); int length = SampledValues.length; // Generate Sobol sequence SobolSequenceGenerator SSG = new SobolSequenceGenerator(length - 1); // SSG.skipTo(1000); // Shuffle the sample value vector of each parameter // for (int i=1; i<length; i++) { // Collections.shuffle(Arrays.asList(SampledValues[i]), randomsrc); // } // n jobs are created by taking a value from each parameter's vector // sequentially for (int i = 0; i < LHSsize; i++) { double[] vector = SSG.nextVector(); JobList[i] = new String[length]; JobList[i][0] = new Formatter().format("SOBOL-%06d", i).toString(); // Job id for (int j = 1; j < length; j++) { JobList[i][j] = SampledValues[j][Math.round((float) vector[j - 1] * LHSsize)]; }//ww w .ja va2s . c o m } return JobList; } return null; }
From source file:gdsc.smlm.ij.plugins.CreateData.java
/** * Create distribution within an XY border * //from ww w.j a va 2 s . c o m * @param border * @return */ private UniformDistribution createUniformDistribution(double border) { double depth = (settings.fixedDepth) ? settings.depth / settings.pixelPitch : settings.depth / (2 * settings.pixelPitch); // Ensure the focal plane is in the middle of the zDepth double[] max = new double[] { settings.size / 2 - border, settings.size / 2 - border, depth }; double[] min = new double[3]; for (int i = 0; i < 3; i++) min[i] = -max[i]; if (settings.fixedDepth) min[2] = max[2]; // Try using different distributions: final RandomGenerator rand1 = createRandomGenerator(); if (settings.distribution.equals(DISTRIBUTION[UNIFORM_HALTON])) { return new UniformDistribution(min, max, rand1.nextInt()); } if (settings.distribution.equals(DISTRIBUTION[UNIFORM_SOBOL])) { SobolSequenceGenerator rvg = new SobolSequenceGenerator(3); rvg.skipTo(rand1.nextInt()); return new UniformDistribution(min, max, rvg); } // Create a distribution using random generators for each dimension UniformDistribution distribution = new UniformDistribution(min, max, this); return distribution; }
From source file:org.openda.algorithms.DelsaCoreOptimizer.java
/** * Constructor for Delsa/* ww w . ja v a2s .c o m*/ * @param f : costfunction to be minimized * @param minRangePar : minimum of range to scan for each parameter * @param maxRangePar : maximum of range * @param nPoints: number of grid points for each parameter or number of sample */ public DelsaCoreOptimizer(ICostFunction f, IVector minRangePar, IVector maxRangePar, int nPoints, boolean isSobol, IVector pInit) { this.f = f; if (isSobol) { // add grid settings this.nparam = minRangePar.getSize(); this.minRangePar = minRangePar.getValues(); this.maxRangePar = maxRangePar.getValues(); this.pCurrent = minRangePar; this.fCurrent = Double.POSITIVE_INFINITY; this.SL1 = new IVector[nPoints]; this.isSobol = isSobol; sobolSequence = new SobolSequenceGenerator(this.nparam); // compute variances of the parameters (see Appendix B of Rakovec et al, 2014) this.paramVariance = new Vector(nparam); for (int iParam = 0; iParam < this.nparam; iParam++) { double thisVariance = (this.maxRangePar[iParam] - this.minRangePar[iParam]) * (this.maxRangePar[iParam] - this.minRangePar[iParam]) / 12.0d; this.paramVariance.setValue(iParam, thisVariance); } } else { int nPointsPerParameter = nPoints; this.setGrid(minRangePar, maxRangePar, nPointsPerParameter); } this.pInit = pInit; }