[Insight-users] Cloning optimizer state

Luis Ibanez luis.ibanez at kitware.com
Sun Dec 31 10:00:34 EST 2006


Hi Jordi,

In the past we have used the approach of having a helper class
that clones an instance of an object.

Examples of this approach are:

  1) Insight/Code/SpatialObject/itkSpatialObjectDuplicator.h

  2) Insight/Code/Common/itkImageDuplicator.h


We could create an itkOptimizerDuplicator class.

For this it will be desirable to generalize the notion of
internal parameters of an optimizer. Along the same lines
that we use in the Transforms. We could imagine the optimizers
having a GetOptimizationParameters() method returning an array
of doubles. A combination of Set/Get methods will pack and unpack
the parameters in the array.

This is a significant additional feature that may require
some more thinking.

You may want to add it as a feature request to the ITK bug tracker.



    Regards,


       Luis



-------------------
Jordi Inglada wrote:
> Dear all,
> 
> We are implementing a filter which uses several optimizers of the same
> type. The optimizer type can be chosen by the user of the filter. All
> the optimizers are of the same type. The choice is still open between : 
> 
> 1. making the optimizer type a template type of the filter --
> Filter<TImage, TOptimizer> and SetOptimizer(TOptimizer ) 
> 
> 2. or using polymorphism with a Filter<TImage>  and
> SetOptimizer( itk::Optimizer::Pointer ).
> 
> We are facing the problem of optimizer initialization : given the fact
> that different ITK optimizers have different parameters (number of
> samples, learning rate, stopping criteria, etc.) we are not able to
> write code for a generic initialization. 
> 
> On the other hand, since we are using many optimizers inside the filter,
> we would like to avoid the need of performing initialization outside the
> class (done by the class user).
> 
> What we would like to do is -- as for registration methods in ITK -- ask
> the user to initialize one instance of the optimizer type, and then
> "clone" this instance inside the filter any time we need a new
> optimizer.
> 
> The problem is that copy constructors are not available. 
> 
> It is not clear to me how we should deal with this issue.  
> 
> I have taken a look at several design patterns (the factory method and
> the prototype pattern in particular), but I understand that I need to
> provide a base class with an accessible copy constructor or something
> like this.
> 
> Before getting into complex approaches I would like to know if there is
> some straightforward solution that is already known.
> 
> Thanks in advance.
> 
> Jordi
> 


More information about the Insight-users mailing list