[vtkusers] vtkAmoebaMinimizer

David Gobbi dgobbi at irus.rri.ca
Mon Jun 10 09:12:16 EDT 2002


Hi All,

I added a downhill simplex minimization class to VTK over the weekend,
it is in the Hybrid directory in CVS and includes examples in
Hybrid/Testing/Cxx and Hybrid/Testing/Tcl.

My intention is to eventually split off a vtkAbstractMinimizer base
class (once I know whether people like the basic interface), but for now
if anyone wants to create their own minimizer class they can derive from
vtkAmoebaMinimizer and override the Iterate() and Minimize() methods.

Here is a short example (in python) of how to use the class:

m = vtkAmoebaMinimizer()

# create the function that will be minimized
def func():
    x = m.GetParameterValue("x")
    y = m.GetParameterValue("y")
    z = m.GetParameterValue("z")

    r = (x-5)*(x-5) + (y+2)*(y+2) + (z)*(z)

    m.SetResult(r)

m.SetFunction(func)
m.SetParameterBracket("x",-2,2)  # initial guess is -2, 2nd guess is +2
m.SetParameterBracket("y",-2,2)
m.SetParameterBracket("z",-2,2)
m.Minimize()
m.Iterate()

print "should get x=5, y=-2, z=0"

print "x =", m.GetParameterValue("x")
print "y =", m.GetParameterValue("y")
print "z =", m.GetParameterValue("z")

print "minimum =", m.GetResult()

print "iterations =", m.GetIterations()


 - David

--
  David Gobbi, MSc                       dgobbi at irus.rri.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario




More information about the vtkusers mailing list