source: trunk/packages/optimizer/examples/visualize.tcl @ 6716

Last change on this file since 6716 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

File size: 2.2 KB
Line 
1# ----------------------------------------------------------------------
2#  Visualize the output of genetic optimization
3#
4#  This script reads a bunch of runXXXX.xml files and plots them
5#  so you can see where the genetic algorithm was simulating and
6#  what it came up with.
7#
8#  Run this as:  wish visualize.tcl
9#
10# ======================================================================
11#  AUTHOR:  Michael McLennan, Purdue University
12#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
13#
14#  See the file "license.terms" for information on usage and
15#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
16# ======================================================================
17package require BLT
18package require Rappture
19
20# ----------------------------------------------------------------------
21#  Load up all of the Rappture result files
22# ----------------------------------------------------------------------
23set jobs 0
24foreach file [lsort [glob run*.xml]] {
25    set result($jobs) [Rappture::library $file]
26    incr jobs
27}
28
29blt::graph .space
30.space xaxis configure -title "x1" -min -2 -max 2
31.space yaxis configure -title "y1" -min -2 -max 2
32.space legend configure -hide no
33pack .space -side left -expand yes -fill both
34
35blt::graph .value
36.value xaxis configure -title "job number" -min 0 -max $jobs
37.value yaxis configure -title "f(x1,x2)" -min 0 -max 2
38.value legend configure -hide yes
39pack .value -side left -expand yes -fill both
40
41set colors {blue purple magenta green yellow orange tomato red black}
42for {set pop [expr [llength $colors]-1]} {$pop >= 0} {incr pop -1} {
43    blt::vector x1vec$pop
44    blt::vector x2vec$pop
45    .space element create spots$pop -xdata x1vec$pop -ydata x2vec$pop \
46        -color [lindex $colors $pop] -linewidth 0 -label "Population #$pop"
47
48    blt::vector jobvec$pop
49    blt::vector fvec$pop
50    .value element create line$pop -xdata jobvec$pop -ydata fvec$pop \
51        -color [lindex $colors $pop] -symbol none
52}
53
54for {set n 0} {$n < $jobs} {incr n} {
55    set pop [expr {$n/100}]
56    x1vec$pop append [$result($n) get input.number(x1).current]
57    x2vec$pop append [$result($n) get input.number(x2).current]
58    jobvec$pop append $n
59    fvec$pop append [$result($n) get output.number(f).current]
60    update
61    after 100
62}
Note: See TracBrowser for help on using the repository browser.