NeighbourhoodSizeFunctionFactory { public static NeighbourhoodSizeFunction exponentialDecay(final double initValue, final double valueAtNumCall, final long numCall) { return new NeighbourhoodSizeFunction() { private final ExponentialDecayFunction decay = new ExponentialDecayFunction(initValue, valueAtNumCall, numCall); public int value(long n) { return (int) FastMath.rint(decay.value(n)); } }; } private  NeighbourhoodSizeFunctionFactory(); static NeighbourhoodSizeFunction exponentialDecay(final double initValue,
                                                             final double valueAtNumCall,
                                                             final long numCall); static NeighbourhoodSizeFunction quasiSigmoidDecay(final double initValue,
                                                              final double slope,
                                                              final long numCall);  }
@Test(expected=NotStrictlyPositiveException.class) public void testExponentialDecayPrecondition1() { NeighbourhoodSizeFunctionFactory.exponentialDecay(0, 0, 2); }
@Test(expected=NotStrictlyPositiveException.class) public void testExponentialDecayPrecondition2() { NeighbourhoodSizeFunctionFactory.exponentialDecay(1, 0, 2); }
@Test(expected=NumberIsTooLargeException.class) public void testExponentialDecayPrecondition3() { NeighbourhoodSizeFunctionFactory.exponentialDecay(1, 1, 100); }
@Test(expected=NotStrictlyPositiveException.class) public void testExponentialDecayPrecondition4() { NeighbourhoodSizeFunctionFactory.exponentialDecay(2, 1, 0); }
@Test public void testExponentialDecayTrivial() { final int n = 65; final int init = 4; final int valueAtN = 3; final NeighbourhoodSizeFunction f = NeighbourhoodSizeFunctionFactory.exponentialDecay(init, valueAtN, n); Assert.assertEquals(init, f.value(0)); Assert.assertEquals(valueAtN, f.value(n)); Assert.assertEquals(0, f.value(Long.MAX_VALUE)); }