| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package test.dr.inference.operators; |
| 27 |
|
| 28 |
import dr.inference.model.Parameter; |
| 29 |
import dr.inference.operators.AdaptationMode; |
| 30 |
import dr.inference.operators.RandomWalkOperator; |
| 31 |
import junit.framework.*; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public class RandomWalkOperatorTest extends TestCase { |
| 41 |
|
| 42 |
public RandomWalkOperatorTest(String name) { |
| 43 |
super(name); |
| 44 |
} |
| 45 |
|
| 46 |
public void setUp() throws Exception { |
| 47 |
super.setUp(); |
| 48 |
} |
| 49 |
|
| 50 |
public void testRandomWalkOperator() { |
| 51 |
Parameter parameter = new Parameter.Default("test", 0.5, 0.0, 1.0); |
| 52 |
RandomWalkOperator rwo = new RandomWalkOperator(parameter, 1.0, RandomWalkOperator.BoundaryCondition.reflecting, 1.0, AdaptationMode.ADAPTATION_OFF); |
| 53 |
|
| 54 |
double test1 = rwo.reflectValue(8.7654321, 3.14159265, Double.POSITIVE_INFINITY); |
| 55 |
double test2 = rwo.reflectValue(8.7654321, Double.NEGATIVE_INFINITY, 3.14159265); |
| 56 |
double test3 = rwo.reflectValue(1.2345678, 3.14159265, 2.0 * 3.14159265); |
| 57 |
double test4 = rwo.reflectValue(12345678.987654321, 3.14159265, 2.0 * 3.14159265); |
| 58 |
|
| 59 |
double test1b = rwo.reflectValueLoop(8.7654321, 3.14159265, Double.POSITIVE_INFINITY); |
| 60 |
double test2b = rwo.reflectValueLoop(8.7654321, Double.NEGATIVE_INFINITY, 3.14159265); |
| 61 |
double test3b = rwo.reflectValueLoop(1.2345678, 3.14159265, 2.0 * 3.14159265); |
| 62 |
double test4b = rwo.reflectValueLoop(12345678.987654321, 3.14159265, 2.0 * 3.14159265); |
| 63 |
|
| 64 |
assertEquals(test1, test1b); |
| 65 |
assertEquals(test2, test2b); |
| 66 |
assertEquals(test3, test3b); |
| 67 |
assertTrue(Math.abs(test4 - test4b) < 0.001); |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
public static Test suite() { |
| 72 |
return new TestSuite(RandomWalkOperatorTest.class); |
| 73 |
} |
| 74 |
} |