Revision 855,
1.2 KB
checked in by mmckerns, 5 months ago
(diff) 
updated copyright to 2016


Property svn:executable set to
*

Line  

1  #!/usr/bin/env python 

2  # 

3  # Author: Mike McKerns (mmckerns @caltech and @uqfoundation) 

4  # Copyright (c) 19972016 California Institute of Technology. 

5  # License: 3clause BSD. The full license text is available at: 

6  #  http://trac.mystic.cacr.caltech.edu/project/mystic/browser/mystic/LICENSE 

7  """ 

8  Example: 

9   Minimize Rosenbrock's Function with NelderMead. 

10   Plot of parameter convergence to function minimum. 

11  

12  Demonstrates: 

13   standard models 

14   minimal solver interface 

15   parameter trajectories using retall 

16  """ 

17  

18  # NelderMead solver 

19  from mystic.solvers import fmin 

20  

21  # Rosenbrock function 

22  from mystic.models import rosen 

23  

24  # tools 

25  import pylab 

26  

27  

28  if __name__ == '__main__': 

29  

30  # initial guess 

31  x0 = [0.8,1.2,0.7] 

32  

33  # use NelderMead to minimize the Rosenbrock function 

34  solution = fmin(rosen,x0,disp=0,retall=1) 

35  allvecs = solution[1] 

36  

37  # plot the parameter trajectories 

38  pylab.plot([i[0] for i in allvecs]) 

39  pylab.plot([i[1] for i in allvecs]) 

40  pylab.plot([i[2] for i in allvecs]) 

41  

42  # draw the plot 

43  pylab.title("Rosenbrock parameter convergence") 

44  pylab.xlabel("NelderMead solver iterations") 

45  pylab.ylabel("parameter value") 

46  pylab.legend(["x", "y", "z"]) 

47  pylab.show() 

48  

49  # end of file 

Note: See
TracBrowser
for help on using the repository browser.