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) 1997-2016 California Institute of Technology. |
---|
5 | # License: 3-clause BSD. The full license text is available at: |
---|
6 | # - http://mmckerns.github.io/project/mystic/browser/mystic/LICENSE |
---|
7 | """ |
---|
8 | Example: |
---|
9 | - Minimize Rosenbrock's Function with Powell's method. |
---|
10 | |
---|
11 | Demonstrates: |
---|
12 | - standard models |
---|
13 | - minimal solver interface |
---|
14 | - parameter constraints solver |
---|
15 | - customized monitors |
---|
16 | """ |
---|
17 | |
---|
18 | # Powell's Directonal solver |
---|
19 | from mystic.solvers import fmin_powell |
---|
20 | |
---|
21 | # Rosenbrock function |
---|
22 | from mystic.models import rosen |
---|
23 | |
---|
24 | # tools |
---|
25 | from mystic.monitors import VerboseMonitor |
---|
26 | |
---|
27 | |
---|
28 | if __name__ == '__main__': |
---|
29 | |
---|
30 | print "Powell's Method" |
---|
31 | print "===============" |
---|
32 | |
---|
33 | # initial guess |
---|
34 | x0 = [0.8,1.2,0.7] |
---|
35 | |
---|
36 | # define constraints function |
---|
37 | def constraints(x): |
---|
38 | # constrain the last x_i to be the same value as the first x_i |
---|
39 | x[-1] = x[0] |
---|
40 | return x |
---|
41 | |
---|
42 | # configure monitor |
---|
43 | stepmon = VerboseMonitor(1) |
---|
44 | |
---|
45 | # use Powell's method to minimize the Rosenbrock function |
---|
46 | solution = fmin_powell(rosen,x0,constraints=constraints,itermon=stepmon) |
---|
47 | print solution |
---|
48 | |
---|
49 | # end of file |
---|
Note: See
TracBrowser
for help on using the repository browser.