Range { public void stringToRange(String s) { String[] sA = s.split(";"); this.start = new double[sA.length]; this.stop = new double[sA.length]; this.step = new double[sA.length]; this.random = new boolean[sA.length]; for (int j = 0; j < sA.length; j++) { String[] sA_2 = sA[j].split("\\s*eq\\s*"); for (int i = 0; i < sA_2.length; i++) { if (sA_2[i].contains("[")) { String sA_3[] = sA_2[i].split(":"); this.start[j] = Double.parseDouble(sA_3[0].substring(1)); this.step[j] = Double.parseDouble(sA_3[1]); this.stop[j] = Double.parseDouble(sA_3[2].substring(0, (sA_3[2].length() - 1))); this.random[j] = false; } else { if (sA_2[i].contains("(")) { String sA_3[] = sA_2[i].split(","); this.start[j] = Double.parseDouble(sA_3[0].substring(4)); this.step[j] = Double.parseDouble(sA_3[1]); this.stop[j] = Double.parseDouble(sA_3[2].substring(0, (sA_3[2].length() - 1))); this.random[j] = true; } } } } this.totalSamples = this.getTotalSamples(); } Range(String s);  Range(String s, RandomNumberGenerator rng); void stringToRange(String s); double[][] getSamples(); boolean isRandom(); void setRandom(boolean random); boolean isRandom(int i); void setRandom(boolean random, int i); double getStart(int dim); double getStep(int dim); double getStop(int dim); int getDimensions(); @Override String toString();  }
@Test public void testStringToRange() { System.out.println("stringToRange"); String s = "x0 eq [1:2:7]; x1 eq [2:1:5]"; Range r = new Range(""); r.stringToRange(s); assertEquals(r.getStart(0), 1, 0.01); assertEquals(r.getStart(1), 2, 0.01); assertEquals(r.getStep(0), 2, 0.01); assertEquals(r.getStep(1), 1, 0.01); assertEquals(r.getStop(0), 7, 0.01); assertEquals(r.getStop(1), 5, 0.01); assertEquals(r.isRandom(0), false); assertEquals(r.isRandom(1), false); assertEquals(r.getTotalSamples(0), 3); assertEquals(r.getTotalSamples(1), 3); s = "x0 eq rnd(0,3,1); x1 eq rnd(1,3,2)"; r = new Range(""); r.stringToRange(s); assertEquals(r.getStart(0), 0, 0.01); assertEquals(r.getStart(1), 1, 0.01); assertEquals(r.getStep(0), 3, 0.01); assertEquals(r.getStep(1), 3, 0.01); assertEquals(r.getStop(0), 1, 0.01); assertEquals(r.getStop(1), 2, 0.01); assertEquals(r.isRandom(0), true); assertEquals(r.isRandom(1), true); assertEquals(r.getTotalSamples(0), 3); assertEquals(r.getTotalSamples(1), 3); s = "x0 eq rnd(0,3:1)"; r = new Range(""); try { r.stringToRange(s); } catch (NumberFormatException e) { assertTrue(true); } s = "x0 eq rnd(0,3,1"; r = new Range(""); try { r.stringToRange(s); } catch (NumberFormatException e) { } }