/** * dG/dα and dH/dα computations test based on 2 independent methods. If they give same results, we * assume them to be consistent. */ @Test public void testdGHdAlpha() { final int sMax = 30; final int mMax = 20; final MersenneTwister random = new MersenneTwister(123456789); for (int i = 0; i < 10; i++) { final double k = random.nextDouble(); final double h = random.nextDouble(); final double a = random.nextDouble(); final double b = random.nextDouble(); final GHmsjPolynomials gMSJ = new GHmsjPolynomials(k, h, a, b, 1); for (int s = -sMax; s <= sMax; s++) { for (int m = 2; m <= mMax; m += 2) { final int j = m / 2; final double[] dGHda = getdGHda(k, h, a, b, m, s, j); Assert.assertEquals(dGHda[0], gMSJ.getdGmsdAlpha(m, s, j), Math.abs(eps * dGHda[0])); Assert.assertEquals(dGHda[1], gMSJ.getdHmsdAlpha(m, s, j), Math.abs(eps * dGHda[1])); } } } }
public void randomize() { for (TIntObjectIterator<int[]> it = offsets.iterator(); it.hasNext(); ) { it.advance(); int[] newVal = new int[it.value().length]; RaptorWorkerTimetable tt = data.timetablesForPattern.get(it.key()); for (int i = 0; i < newVal.length; i++) { newVal[i] = mt.nextInt(tt.headwaySecs[i]); } it.setValue(newVal); } }