Hi,
now i made a try to get a clone of the itk::AmoebaOptimizer.
To get a clone with the correct parameters I added in following classes following code.
In itkOptimizer.h, itkSingleValuedNonLinearVnlOptimizer.h, itkAmoebaOptimizer.h I added in the protected space:
/**
* Clone the current optimizer.
* This does a complete copy of the optimizer state to the new optimizer
*/
typename LightObject::Pointer InternalClone() const override;
In the body files is added:
LightObject::Pointer
Optimizer
::InternalClone() const
{
// Default implementation just copies the parameters from
// this to new optimizer.
LightObject::Pointer loPtr = Superclass::InternalClone();
Self::Pointer rval = dynamic_cast<Self *>(loPtr.GetPointer());
if (rval.IsNull())
{
itkExceptionMacro(<< "downcast to type " << this->GetNameOfClass() << " failed.");
}
rval->SetScales(this->GetScales());
rval->SetInitialPosition(this->GetInitialPosition());
return loPtr;
}
itkSingleValuedNonLinearVnlOptimizer.cxx
LightObject::Pointer
SingleValuedNonLinearVnlOptimizer
::InternalClone() const
{
// Default implementation just copies the parameters from
// this to new optimizer.
LightObject::Pointer loPtr = Superclass::InternalClone();
Self::Pointer rval = dynamic_cast<Self *>(loPtr.GetPointer());
if (rval.IsNull())
{
itkExceptionMacro(<< "downcast to type " << this->GetNameOfClass() << " failed.");
}
rval->SetMaximize(this->GetMaximize());
return loPtr;
}
LightObject::Pointer
AmoebaOptimizer
::InternalClone() const
{
// Default implementation just copies the parameters from
// this to new optimizer.
LightObject::Pointer loPtr = Superclass::InternalClone();
Self::Pointer rval = dynamic_cast<Self *>(loPtr.GetPointer());
if (rval.IsNull())
{
itkExceptionMacro(<< "downcast to type " << this->GetNameOfClass() << " failed.");
}
rval->SetMaximumNumberOfIterations(this->GetMaximumNumberOfIterations());
rval->SetOptimizeWithRestarts(this->GetOptimizeWithRestarts());
rval->SetParametersConvergenceTolerance(this->GetParametersConvergenceTolerance());
rval->SetFunctionConvergenceTolerance(this->GetFunctionConvergenceTolerance());
rval->SetInitialSimplexDelta(this->GetInitialSimplexDelta());
rval->SetAutomaticInitialSimplex(this->GetAutomaticInitialSimplex());
return loPtr;
}
I tested it in my local copy and it worked as expected. I have a local copy but cannot push it to the repository. Even pushing to a fork doesnt work.
Is this something I can contribute or do you need more information?
Do I have to follow this guide for contribution: itk.org/Wiki/ITK/Git/Develop?