Changeset 82 for tests/sam_mogi.py
- Timestamp:
- 01/26/09 16:12:08 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/sam_mogi.py
r81 r82 9 9 import sam 10 10 from test_mogi import * 11 from mystic.nelder_mead import fmin 11 from mystic.scipy_optimize_fmin import NelderMeadSimplexSolver as fmin 12 from mystic.nmtools import IterationRelativeError as IRE 12 13 from mystic import getch, Sow 13 14 … … 61 62 z1 = z0*random.uniform(0.5,1.5) 62 63 v1 = v0*random.uniform(0.5,1.5) 63 sol = fmin(cost_function, [random.uniform(x0-40,x0+40), random.uniform(y0-40,y0+40), z1, v1], retall = True, StepMonitor = simplex) 64 print sol[0] 64 xinit = [random.uniform(x0-40,x0+40), random.uniform(y0-40,y0+40), z1, v1] 65 66 solver = fmin(len(xinit)) 67 solver.SetInitialPoints(xinit) 68 killme = IRE(1e-4,1e-4) 69 solver.Solve(cost_function, termination=killme, StepMonitor = simplex) 70 sol = solver.Solution() 71 print sol 65 72 66 73 for x in simplex.x: 67 74 sam.putarray('x',x) 68 75 sam.eval("plot(x([1,2,3,1],1),x([1,2,3,1],4),'w-','LineWidth',2)") 69 return sol [0]76 return sol 70 77 71 78 … … 74 81 y1 = y0*random.uniform(0.5,1.5) 75 82 z1 = z0*random.uniform(0.5,1.5) 76 sol = fmin(cost_function, [random.uniform(x0-40,x0+40), y1, z1, random.uniform(v0-0.1,v0+0.1)], retall = True, StepMonitor = simplex) 77 print sol[0] 78 83 xinit = [random.uniform(x0-40,x0+40), y1, z1, random.uniform(v0-0.1,v0+0.1)] 84 85 solver = fmin(len(xinit)) 86 solver.SetInitialPoints(xinit) 87 killme = IRE(1e-4,1e-4) 88 solver.Solve(cost_function, termination=killme, StepMonitor = simplex) 89 sol = solver.Solution() 90 print sol 91 79 92 for x in simplex.x: 80 93 sam.putarray('x',x) 81 94 sam.eval("plot(x([1,2,3,1],1),x([1,2,3,1],2),'w-','LineWidth',2)") 82 return sol [0]95 return sol 83 96 84 97 draw_contour_xv()
Note: See TracChangeset
for help on using the changeset viewer.