[Insight-users] Cloning optimizer state

Jordi Inglada jordi.inglada at cnes.fr
Thu Dec 21 10:13:41 EST 2006


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

-- 
CNES - DCT/SI/AP - BPI 1219
18, avenue Edouard Belin
31401 Toulouse Cedex 09 - France
Tel. +33.(0)5.61.27.33.97 - Fax. +33.(0)5.61.28.31.09 




More information about the Insight-users mailing list