NeighbourhoodSizeFunctionFactory { public static NeighbourhoodSizeFunction quasiSigmoidDecay(final double initValue, final double slope, final long numCall) { return new NeighbourhoodSizeFunction() { private final QuasiSigmoidDecayFunction decay = new QuasiSigmoidDecayFunction(initValue, slope, 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 testQuasiSigmoidDecayPrecondition1() { NeighbourhoodSizeFunctionFactory.quasiSigmoidDecay(0d, -1d, 2); }
@Test(expected=NumberIsTooLargeException.class) public void testQuasiSigmoidDecayPrecondition3() { NeighbourhoodSizeFunctionFactory.quasiSigmoidDecay(1d, 0d, 100); }
@Test(expected=NotStrictlyPositiveException.class) public void testQuasiSigmoidDecayPrecondition4() { NeighbourhoodSizeFunctionFactory.quasiSigmoidDecay(1d, -1d, 0); }
@Test public void testQuasiSigmoidDecayTrivial() { final int n = 65; final double init = 4; final double slope = -1e-1; final NeighbourhoodSizeFunction f = NeighbourhoodSizeFunctionFactory.quasiSigmoidDecay(init, slope, n); Assert.assertEquals(init, f.value(0), 0d); Assert.assertEquals(0, f.value(Long.MAX_VALUE), 0d); }