diff options
Diffstat (limited to 'packages/tests/src/Numeric/GSL')
-rw-r--r-- | packages/tests/src/Numeric/GSL/Tests.hs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/tests/src/Numeric/GSL/Tests.hs b/packages/tests/src/Numeric/GSL/Tests.hs index 3065fd8..025427b 100644 --- a/packages/tests/src/Numeric/GSL/Tests.hs +++ b/packages/tests/src/Numeric/GSL/Tests.hs | |||
@@ -21,6 +21,7 @@ import Test.HUnit (runTestTT, failures, Test(..), errors) | |||
21 | 21 | ||
22 | import Numeric.LinearAlgebra.HMatrix | 22 | import Numeric.LinearAlgebra.HMatrix |
23 | import Numeric.GSL | 23 | import Numeric.GSL |
24 | import Numeric.GSL.SimulatedAnnealing | ||
24 | import Numeric.LinearAlgebra.Tests (qCheck, utest) | 25 | import Numeric.LinearAlgebra.Tests (qCheck, utest) |
25 | import Numeric.LinearAlgebra.Tests.Properties ((|~|), (~~), (~=)) | 26 | import Numeric.LinearAlgebra.Tests.Properties ((|~|), (~~), (~=)) |
26 | 27 | ||
@@ -106,6 +107,21 @@ interpolationTest = TestList [ | |||
106 | 107 | ||
107 | --------------------------------------------------------------------- | 108 | --------------------------------------------------------------------- |
108 | 109 | ||
110 | simanTest = TestList [ | ||
111 | -- We use a slightly more relaxed tolerance here because the | ||
112 | -- simulated annealer is randomized | ||
113 | utest "simulated annealing manual example" $ abs (result - 1.3631300) < 1e-6 | ||
114 | ] | ||
115 | where | ||
116 | -- This is the example from the GSL manual. | ||
117 | result = simanSolve 0 1 exampleParams 15.5 exampleE exampleM exampleS Nothing | ||
118 | exampleParams = SimulatedAnnealingParams 200 10000 1.0 1.0 0.008 1.003 2.0e-6 | ||
119 | exampleE x = exp (-(x - 1)**2) * sin (8 * x) | ||
120 | exampleM x y = abs $ x - y | ||
121 | exampleS rands stepSize current = (rands ! 0) * 2 * stepSize - stepSize + current | ||
122 | |||
123 | --------------------------------------------------------------------- | ||
124 | |||
109 | minimizationTest = TestList | 125 | minimizationTest = TestList |
110 | [ utest "minimization conjugatefr" (minim1 f df [5,7] ~~ [1,2]) | 126 | [ utest "minimization conjugatefr" (minim1 f df [5,7] ~~ [1,2]) |
111 | , utest "minimization nmsimplex2" (minim2 f [5,7] `elem` [24,25]) | 127 | , utest "minimization nmsimplex2" (minim2 f [5,7] `elem` [24,25]) |
@@ -162,6 +178,7 @@ runTests n = do | |||
162 | , rootFindingTest | 178 | , rootFindingTest |
163 | , minimizationTest | 179 | , minimizationTest |
164 | , interpolationTest | 180 | , interpolationTest |
181 | , simanTest | ||
165 | , utest "deriv" derivTest | 182 | , utest "deriv" derivTest |
166 | , utest "integrate" (abs (volSphere 2.5 - 4/3*pi*2.5**3) < 1E-8) | 183 | , utest "integrate" (abs (volSphere 2.5 - 4/3*pi*2.5**3) < 1E-8) |
167 | , utest "polySolve" (polySolveProp [1,2,3,4]) | 184 | , utest "polySolve" (polySolveProp [1,2,3,4]) |