Last change
on this file since 1052 was
899,
checked in by mmc, 15 years ago
|
Added a -fitness option to the "perform" operation. Right now, you can
specify just the name of an output quantity, and that quantity can be
minimized or maximized. In the future, there should be an expression
parser so you can enter any function of Rappture quantities.
Fixed up the example so that it runs the Rosenbrock function, which is
difficult to minimize. Added a visualize.tcl script, so you can visualize
the output from many different runXXXX.xml files.
|
-
Property svn:executable set to
*
|
File size:
1.2 KB
|
Line | |
---|
1 | # ---------------------------------------------------------------------- |
---|
2 | # EXAMPLE: Optimization of the Rosenbrock function |
---|
3 | # |
---|
4 | # This tool is a good example for optimization. It implements the |
---|
5 | # Rosenbrock function: |
---|
6 | # |
---|
7 | # f(x1,x2) = 100(x2 - x1**2)**2 + (1-x1)**2 |
---|
8 | # |
---|
9 | # This has a minimum at (x1,x2) = (1,1). |
---|
10 | # |
---|
11 | # ====================================================================== |
---|
12 | # AUTHOR: Michael McLennan, Purdue University |
---|
13 | # Copyright (c) 2004-2007 Purdue Research Foundation |
---|
14 | # |
---|
15 | # See the file "license.terms" for information on usage and |
---|
16 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
17 | # ====================================================================== |
---|
18 | package require Rappture |
---|
19 | |
---|
20 | # open the XML file containing the run parameters |
---|
21 | set driver [Rappture::library [lindex $argv 0]] |
---|
22 | |
---|
23 | set x1 [$driver get input.(x1).current] |
---|
24 | set x2 [$driver get input.(x2).current] |
---|
25 | |
---|
26 | set f [expr {100*($x2-$x1*$x1)*($x2-$x1*$x1) + (1-$x1)*(1-$x1)}] |
---|
27 | |
---|
28 | $driver put output.number(f).about.label "Rosenbrock function" |
---|
29 | $driver put output.number(f).about.description \ |
---|
30 | "f(x1,x2) = 100(x2 - x1**2)**2 + (1-x1)**2" |
---|
31 | $driver put output.number(f).current $f |
---|
32 | |
---|
33 | # save the updated XML describing the run... |
---|
34 | Rappture::result $driver |
---|
35 | exit 0 |
---|
Note: See
TracBrowser
for help on using the repository browser.