#include "itkParticleSwarmOptimizerDOMWriter.h"
namespace itk
{
void
ParticleSwarmOptimizerDOMWriter::GenerateData( DOMNodeType* outputdom, const void* ) const
{
LoggerType* logger = this->GetLogger();
const InputType* input = this->GetInput();
auto * ipobj = const_cast<ParticleSwarmOptimizer*>(input);
outputdom->SetName( "optimizer" );
outputdom->SetAttribute( "type", "ParticleSwarmOptimizer" );
FancyString s;
logger->Info( "writing NumberOfParticles ...\n" );
outputdom->SetAttribute( "NumberOfParticles", s );
logger->Info( "writing MaximumNumberOfIterations ...\n" );
outputdom->SetAttribute( "MaximumNumberOfIterations", s );
logger->Info( "writing InertiaCoefficient ...\n" );
outputdom->SetAttribute( "InertiaCoefficient", s );
logger->Info( "writing GlobalCoefficient ...\n" );
outputdom->SetAttribute( "GlobalCoefficient", s );
logger->Info( "writing PersonalCoefficient ...\n" );
outputdom->SetAttribute( "PersonalCoefficient", s );
std::vector<double> lbound;
std::vector<double> ubound;
for (auto & bound : ipobj->GetParameterBounds() )
{
lbound.push_back( bound.first );
ubound.push_back( bound.second );
}
logger->Info( "writing LowerBound ...\n" );
nodelb->SetName( "bound" );
nodelb->SetAttribute( "id", "lower" );
nodelb->SetAttribute(
"value", s <<
ClearContent << lbound );
outputdom->AddChildAtEnd( nodelb );
logger->Info( "writing UpperBound ...\n" );
nodeub->SetName( "bound" );
nodeub->SetAttribute( "id", "upper" );
nodeub->SetAttribute(
"value", s <<
ClearContent << ubound );
outputdom->AddChildAtEnd( nodeub );
logger->Info( "writing ParametersConvergenceTolerance ...\n" );
nodeptols->SetName( "ParametersConvergenceTolerance" );
outputdom->AddChildAtEnd( nodeptols );
s << ClearContent << (Array<double>)ipobj->GetParametersConvergenceTolerance();
nodeptols->AddTextChildAtEnd( s );
logger->Info( "writing FunctionConvergenceTolerance ...\n" );
s <<
ClearContent << ipobj->GetFunctionConvergenceTolerance();
outputdom->SetAttribute( "FunctionConvergenceTolerance", s );
logger->Info( "writing ConvergedPercentageToStop ...\n" );
s <<
ClearContent << ipobj->GetPercentageParticlesConverged();
outputdom->SetAttribute( "ConvergedPercentageToStop", s );
}
}