File: TestAmoebaMinimizer.tcl

package info (click to toggle)
vtk 5.8.0-13
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 130,524 kB
  • sloc: cpp: 1,129,256; ansic: 708,203; tcl: 48,526; python: 20,875; xml: 6,779; yacc: 4,208; perl: 3,121; java: 2,788; lex: 931; sh: 660; asm: 471; makefile: 299
file content (57 lines) | stat: -rw-r--r-- 1,202 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
for {set i  0} {$i < [expr $argc - 1]} {incr i} {
   if {[lindex $argv $i] == "-A"} {
      set auto_path "$auto_path [lindex $argv [expr $i +1]]"
   }
}

package require vtk

vtkAmoebaMinimizer m

proc func {} {
    set x  [m GetParameterValue "x"]
    set y  [m GetParameterValue "y"]
    set z  [m GetParameterValue "z"]
    
    set r  [expr ($x-5.0)*($x-5.0) + ($y+2.0)*($y+2.0) + ($z)*($z)]
    
    m SetFunctionValue $r
}

m SetFunction func
m SetParameterValue "x" 0.0
m SetParameterScale "x" 2.0
m SetParameterValue "y" 0.0
m SetParameterScale "y" 2.0
m SetParameterValue "z" 0.0
m SetParameterScale "z" 2.0
m Minimize

puts "should find x=5, y=-2, z=0"

puts -nonewline "should be 0 if the simplex converged -> "
puts [m Iterate]

puts -nonewline "x = "
puts [m GetParameterValue "x"]
puts -nonewline "y = "
puts [m GetParameterValue "y"]
puts -nonewline "z = "
puts [m GetParameterValue "z"]

puts -nonewline "function value = "
puts [m GetFunctionValue]

puts -nonewline "evaluations = "
puts [m GetFunctionEvaluations]

puts -nonewline "iterations = "
puts [m GetIterations]

puts "To improve coverage and catch errors, do a PrintSelf with parameters set:"

puts [m Print]

m Delete

exit