[Insight-users] OnePlusOneEvolutionaryOptimizer (compilation fault)

Luis Ibanez luis.ibanez at kitware.com
Sun, 02 May 2004 11:52:00 -0400


Hi Christos,


Thanks for pointinng this out.

The problem is that the GetValue() method
wasn't declared 'const' in the optimizer.

This was entered as Bug #815
http://www.itk.org/Bug/bug.php?op=show&bugid=815&pos=0

and has already been fixed in the CVS repository.

Please update your CVS checkout.


   Thanks



      Luis



-----------------------
Christos Panagiotou wrote:

> Dear luis
> 
> i have also another problem concerning the oneplusonevolutionary 
> optimizer...
> i have an observing method which works for gradient descent and regular 
> gradient descent
> which returns me the value for each iteration
> however when i modify this execute method to work with the one+one it 
> just throws me the following error
> during compilation:
> 
> /CommandIterationUpdate.h:42: error: passing
>   `const itk::OnePlusOneEvolutionaryOptimizer' as `this' argument of 
> `double
>   itk::OnePlusOneEvolutionaryOptimizer::GetValue()' discards qualifiers
> 
> 
> 
> The only change i make is just the name of the optimizer...
> 
> i also post the whole execute method for verification:
> 
> #include "itkObject.h"
> #include "itkCommand.h"
> #include "itkGradientDescentOptimizer.h"
> #include "itkRegularStepGradientDescentOptimizer.h"
> #include "itkOnePlusOneEvolutionaryOptimizer.h"
> 
> #include <iostream.h>
> #include <fstream.h>
> 
> 
> 
> class CommandIterationUpdate : public itk::Command
> {
> public:
>  typedef  CommandIterationUpdate   Self;
>  typedef  itk::Command             Superclass;
>  typedef  itk::SmartPointer<Self>  Pointer;
>  itkNewMacro( Self );
> protected:
>  CommandIterationUpdate() {};
> public:
>  typedef   itk::OnePlusOneEvolutionaryOptimizer     OptimizerType;  <-- 
> from itk::GradientDescent to itk::One+OneEvol... the only change i made
>  typedef   const OptimizerType   *           OptimizerPointer;
> 
>  void Execute(itk::Object *caller, const itk::EventObject & event)
>    {
>      Execute( (const itk::Object *)caller, event);
>    }
> 
>  void Execute(const itk::Object * object, const itk::EventObject & event)
>    {
>            ofstream 
> fout("/home/christos/PhD/Code/matlab/optimizer.m",ios::app);
>        OptimizerPointer optimizer =
>        dynamic_cast< OptimizerPointer >( object );
>      if( typeid( event ) != typeid( itk::IterationEvent ) )
>        {
>        return;
>        }
>      //fout << optimizer->GetCurrentIteration() << "   ";
>      fout << optimizer->GetValue() << "\n";
>      //std::cout << optimizer->GetCurrentPosition() << std::endl;
>      fout.close();
>    }
> };
> 
> of course i ve chaged the code in MIMRegistrator.h and .txx to be 
> compatible with the 1+1 EVO optimizer
> 
> i wonder what goes wrong in my code...
> 
> thanks again
> christos
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>