[Insight-users] Re: vnl_amoeba : Premature termination issue

Karthik Krishnan karthik.krishnan at kitware.com
Mon Jan 15 14:31:22 EST 2007


Hi Syed,

Yes, I posted it on the vxlusers list since several vxl optimizers don't
support a callback method to stop optimization.

Your method to terminate like that won't work for the amoeba. The point
being that the amoeba optimizer internally instantiates another amoeba
class, (by that I mean that the class is local in scope to the optimization
function in the amoeba class), called an "amoebaFit" that does the
optimization for you. You never really have access to this class and saying

  terminator->set_max_interations(0);
isn't going to do anything once you've started optimization.

What I ended up doing was adding callback support to the class. You should
find the modified files here itkAmoebaOptimzer2.* and the class it users
vnl_amoeba2.* in kitware's ftp site (my previous mail bounced):

  ftp public.kitware.com
    (Username: ftpuser    Password: public)
  cd pub/itk/UsersITK/amoeba

The callback is invoked at every iteration from the amoeba optimzier and you
can check whatever you need from the callback and abort if you like.   [The
calldata is initiazed to that locally created amoebaFit class, so you have
access to it from the user callback].

The way to use it is :

---------

void GUIClass::AmoebaIterationCallback( void *cd ) // declare as a static
void method
{
  if( !cd )
    {
    return;
    }

  vnl_amoeba2::IterationCallbackCallData *calldata =
          (vnl_amoeba2::IterationCallbackCallData*)(cd);

  Self *client = (Self *)(calldata->client_calldata);

  if( client->GetAbort()) // Abort this resolution
    {
    calldata->stop_optimization = true; // tells ameba opt to stop
    client->AbortOff();  // Reset the flag
    }
}


//... Somewhere in the GUI-registration class before you start the
optimization...
// .. pass yourself as calldata, so you have access to GUI methods from the
// callback.

registrationMethod->GetOptimizer()->set_iteration_callback(
AmoebaIterationCallback, (this) );

 ..
// In your GUI class, when you need to abort
this->SetAbort(true);
--------

HTH
-karthik


On 1/11/07, Syed Hassan Amin <hassanamin_77 at yahoo.com> wrote:
>
> Dear Karthik,
>   I am a PhD student . The reason I am bothering you
> is that I want to terminate vnl_amoeba pre maturely. I
> tried to change to the values of different parameters
> such as :-
> terminator->set_max_iterations(0);
>           terminator->set_x_tolerance(5);
>           terminator->set_f_tolerance(5);
> where terminator has a pointer to the calling
> vnl_amoeba optimizer. But still optimizer goes on to
> perform hundereds of iterations before terminating.
> You once initiated a discussion along these lines . If
> you did implement solution for above mentioned problem
> , could you please share it with me.
>
> Regards,
>
> Hassan Amin
>
>
>
>
>
> ____________________________________________________________________________________
> Need a quick answer? Get one in minutes from people who know.
> Ask your question on www.Answers.yahoo.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070115/9287c22a/attachment-0001.html


More information about the Insight-users mailing list