List of usage examples for org.apache.commons.math3.random SobolSequenceGenerator nextVector
public double[] nextVector()
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 ww w . ja va2 s . c o m*/ 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)]; }/*w w w.j a v a2 s . c o m*/ } return JobList; } return null; }