summaryrefslogtreecommitdiff
path: root/examples/minimize.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-10-23 19:53:03 +0000
committerAlberto Ruiz <aruiz@um.es>2007-10-23 19:53:03 +0000
commit9c65a03f4e2b3b09f6f2ac606c5b22f6df9cea14 (patch)
tree72e0410c896e5ab6c1e7745bab20b1e2eaf6c72b /examples/minimize.hs
parent477c7cfc74c93363708ece4832947455c3e55e31 (diff)
removed conjTrans
Diffstat (limited to 'examples/minimize.hs')
-rw-r--r--examples/minimize.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/minimize.hs b/examples/minimize.hs
index d7bc350..5beba3b 100644
--- a/examples/minimize.hs
+++ b/examples/minimize.hs
@@ -2,6 +2,7 @@
2import Numeric.GSL 2import Numeric.GSL
3import Numeric.LinearAlgebra 3import Numeric.LinearAlgebra
4import Graphics.Plot 4import Graphics.Plot
5import Text.Printf(printf)
5 6
6-- the function to be minimized 7-- the function to be minimized
7f [x,y] = 10*(x-1)^2 + 20*(y-2)^2 + 30 8f [x,y] = 10*(x-1)^2 + 20*(y-2)^2 + 30
@@ -26,18 +27,20 @@ main = do
26 -- conjugate gradient with true gradient 27 -- conjugate gradient with true gradient
27 let (s,p) = minimizeCG f df [5,7] 28 let (s,p) = minimizeCG f df [5,7]
28 print s -- solution 29 print s -- solution
29 dispR 2 p -- evolution of the algorithm 30 disp p -- evolution of the algorithm
30 let [x,y] = drop 2 (toColumns p) 31 let [x,y] = drop 2 (toColumns p)
31 mplot [x,y] -- path from the starting point to the solution 32 mplot [x,y] -- path from the starting point to the solution
32 33
33 -- conjugate gradient with estimated gradient 34 -- conjugate gradient with estimated gradient
34 let (s,p) = minimizeCG f (gradient f) [5,7] 35 let (s,p) = minimizeCG f (gradient f) [5,7]
35 print s 36 print s
36 dispR 2 p 37 disp p
37 mplot $ drop 2 (toColumns p) 38 mplot $ drop 2 (toColumns p)
38 39
39 -- without gradient, using the NM Simplex method 40 -- without gradient, using the NM Simplex method
40 let (s,p) = minimizeS f [5,7] 41 let (s,p) = minimizeS f [5,7]
41 print s 42 print s
42 dispR 2 p 43 disp p
43 mplot $ drop 3 (toColumns p) 44 mplot $ drop 3 (toColumns p)
45
46disp = putStrLn . format " " (printf "%.2f") \ No newline at end of file