[Insight-users] OnePlusOneEvolutionaryOptimizer (compilation fault)

Christos Panagiotou C.Panagiotou at cs.ucl.ac.uk
Sun, 02 May 2004 05:36:25 +0100


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