#include "ExampleCostFunction.h"
namespace
{
using CostType = itk::ExampleCostFunction2;
}
int main(int, char *[])
{
OptimizerType::Pointer optimizer = OptimizerType::New();
optimizer->SetMaximumNumberOfIterations( 100 );
optimizer->SetParametersConvergenceTolerance( 0.01 );
optimizer->SetFunctionConvergenceTolerance( 0.01 );
CostType::Pointer cost = CostType::New();
optimizer->SetCostFunction( cost.GetPointer() );
OptimizerType::ParametersType initial(2);
initial[0] = 123;
initial[1] = -97.4;
optimizer->SetInitialPosition( initial );
optimizer->StartOptimization();
std::cout << "Position: " << optimizer->GetCurrentPosition() << std::endl;
std::cout << "Value: " << optimizer->GetValue() << std::endl;
return EXIT_SUCCESS;
}