BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MinimizerInfo Class Reference
Collaboration diagram for MinimizerInfo:

Public Member Functions

 MinimizerInfo ()=delete
 
 MinimizerInfo (const std::string &minimizerType, const std::string &minimizerDescription)
 
void setAlgorithmName (const std::string &algorithmName)
 
std::string name () const
 
std::string description () const
 
std::string algorithmName () const
 
std::vector< std::string > algorithmNames () const
 
std::vector< std::string > algorithmDescriptions () const
 

Static Public Member Functions

static MinimizerInfo buildMinuit2Info (const std::string &defaultAlgo="")
 
static MinimizerInfo buildGSLMultiMinInfo (const std::string &defaultAlgo="")
 
static MinimizerInfo buildGSLLMAInfo ()
 
static MinimizerInfo buildGSLSimAnInfo ()
 
static MinimizerInfo buildGeneticInfo ()
 
static MinimizerInfo buildTestMinimizerInfo ()
 

Private Member Functions

void addAlgorithm (const AlgorithmInfo &algorithm)
 
void addAlgorithm (const std::string &algorithmName, const std::string &algorithmDescription)
 

Private Attributes

std::string m_name
 
std::string m_description
 
std::vector< AlgorithmInfom_algorithms
 
std::string m_current_algorithm
 

Detailed Description

Info about a minimizer, including list of defined minimization algorithms.

Definition at line 44 of file MinimizerInfo.h.

Constructor & Destructor Documentation

◆ MinimizerInfo() [1/2]

MinimizerInfo::MinimizerInfo ( )
delete

◆ MinimizerInfo() [2/2]

MinimizerInfo::MinimizerInfo ( const std::string &  minimizerType,
const std::string &  minimizerDescription 
)
inline

Definition at line 48 of file MinimizerInfo.h.

49  : m_name(minimizerType), m_description(minimizerDescription)
50  {
51  }
std::string m_name
Definition: MinimizerInfo.h:75
std::string m_description
Definition: MinimizerInfo.h:76

Member Function Documentation

◆ setAlgorithmName()

void MinimizerInfo::setAlgorithmName ( const std::string &  algorithmName)

Sets currently active algorithm.

Definition at line 19 of file MinimizerInfo.cpp.

20 {
21  for (const AlgorithmInfo& algo : m_algorithms) {
22  if (algo.name() == algorithmName) {
24  return;
25  }
26  }
27 
28  std::ostringstream msg;
29  msg << "MinimizerInfo::setAlgorithmName() -> Error. Algorithm name '" << algorithmName
30  << "' is not in the list of defined algorithms (";
31  for (const AlgorithmInfo& algo : m_algorithms)
32  msg << algo.name() << " ";
33  msg << ")";
34  throw std::runtime_error(msg.str());
35 }
A name and a description.
Definition: MinimizerInfo.h:25
std::string m_current_algorithm
Definition: MinimizerInfo.h:78
std::string algorithmName() const
Definition: MinimizerInfo.h:59
std::vector< AlgorithmInfo > m_algorithms
Definition: MinimizerInfo.h:77
Some additions to standard library algorithms.
Definition: Algorithms.h:27

References algorithmName(), m_algorithms, and m_current_algorithm.

Referenced by buildGSLMultiMinInfo(), and buildMinuit2Info().

Here is the call graph for this function:

◆ name()

std::string MinimizerInfo::name ( ) const
inline

Definition at line 56 of file MinimizerInfo.h.

56 { return m_name; }

References m_name.

Referenced by MinimizerFactory::catalogDetailsToString(), and RootMinimizerAdapter::minimizerName().

◆ description()

std::string MinimizerInfo::description ( ) const
inline

Definition at line 57 of file MinimizerInfo.h.

57 { return m_description; }

References m_description.

Referenced by MinimizerFactory::catalogDetailsToString().

◆ algorithmName()

std::string MinimizerInfo::algorithmName ( ) const
inline

◆ algorithmNames()

std::vector< std::string > MinimizerInfo::algorithmNames ( ) const

Return list of defined algorithm names.

Definition at line 39 of file MinimizerInfo.cpp.

40 {
41  std::vector<std::string> result;
42  for (const AlgorithmInfo& algo : m_algorithms)
43  result.push_back(algo.name());
44  return result;
45 }

References m_algorithms.

Referenced by MinimizerCatalog::algorithmNames(), and MinimizerFactory::catalogDetailsToString().

◆ algorithmDescriptions()

std::vector< std::string > MinimizerInfo::algorithmDescriptions ( ) const

Returns list of string with description of all available algorithms.

Definition at line 49 of file MinimizerInfo.cpp.

50 {
51  std::vector<std::string> result;
52  for (const AlgorithmInfo& algo : m_algorithms)
53  result.push_back(algo.description());
54  return result;
55 }

References m_algorithms.

Referenced by MinimizerCatalog::algorithmDescriptions(), and MinimizerFactory::catalogDetailsToString().

◆ buildMinuit2Info()

MinimizerInfo MinimizerInfo::buildMinuit2Info ( const std::string &  defaultAlgo = "")
static

Creates information for Minuit2Minimizer.

Definition at line 59 of file MinimizerInfo.cpp.

60 {
61  MinimizerInfo result("Minuit2", "Minuit2 minimizer from ROOT library");
62 
63  result.addAlgorithm(
64  "Migrad",
65  "Variable-metric method with inexact line search, best minimizer according to ROOT.");
66 
67  result.addAlgorithm("Simplex", "Simplex method of Nelder and Meadh, robust "
68  "against big fluctuations in objective function.");
69 
70  result.addAlgorithm("Combined", "Combination of Migrad and Simplex (if Migrad fails).");
71 
72  result.addAlgorithm("Scan", "Simple objective function scan, one parameter at a time.");
73 
74  result.addAlgorithm("Fumili", "Gradient descent minimizer similar to "
75  "Levenberg-Margquardt, sometimes can be better "
76  "than all others.");
77 
78  if (defaultAlgo.empty())
79  result.setAlgorithmName("Migrad");
80  else
81  result.setAlgorithmName(defaultAlgo);
82 
83  return result;
84 }
Info about a minimizer, including list of defined minimization algorithms.
Definition: MinimizerInfo.h:45

References addAlgorithm(), and setAlgorithmName().

Referenced by MinimizerCatalog::MinimizerCatalog().

Here is the call graph for this function:

◆ buildGSLMultiMinInfo()

MinimizerInfo MinimizerInfo::buildGSLMultiMinInfo ( const std::string &  defaultAlgo = "")
static

Creates information for GSLMultiMinMinimizer.

Definition at line 88 of file MinimizerInfo.cpp.

89 {
90  MinimizerInfo result("GSLMultiMin", "MultiMin minimizer from GSL library");
91 
92  result.addAlgorithm("SteepestDescent", "Steepest descent");
93  result.addAlgorithm("ConjugateFR", "Fletcher-Reeves conjugate gradient");
94  result.addAlgorithm("ConjugatePR", "Polak-Ribiere conjugate gradient");
95  result.addAlgorithm("BFGS", "BFGS conjugate gradient");
96  result.addAlgorithm("BFGS2", "BFGS conjugate gradient (Version 2)");
97 
98  if (defaultAlgo.empty())
99  result.setAlgorithmName("ConjugateFR");
100  else
101  result.setAlgorithmName(defaultAlgo);
102 
103  return result;
104 }

References addAlgorithm(), and setAlgorithmName().

Referenced by MinimizerCatalog::MinimizerCatalog().

Here is the call graph for this function:

◆ buildGSLLMAInfo()

MinimizerInfo MinimizerInfo::buildGSLLMAInfo ( )
static

Creates information for GSL's Levenberg-Marquardt.

Definition at line 108 of file MinimizerInfo.cpp.

109 {
110  MinimizerInfo result("GSLLMA", "Levenberg-Marquardt from GSL library");
111  result.addAlgorithm("Default", "Default algorithm");
112  return result;
113 }

References addAlgorithm().

Referenced by MinimizerCatalog::MinimizerCatalog().

Here is the call graph for this function:

◆ buildGSLSimAnInfo()

MinimizerInfo MinimizerInfo::buildGSLSimAnInfo ( )
static

Creates information for GSL's simmulated annealing algorithm.

Definition at line 117 of file MinimizerInfo.cpp.

118 {
119  MinimizerInfo result("GSLSimAn", "Simmulated annealing minimizer from GSL library");
120  result.addAlgorithm("Default", "Default algorithm");
121  return result;
122 }

References addAlgorithm().

Referenced by MinimizerCatalog::MinimizerCatalog().

Here is the call graph for this function:

◆ buildGeneticInfo()

MinimizerInfo MinimizerInfo::buildGeneticInfo ( )
static

Creates information for TMVA genetic minimizer.

Definition at line 126 of file MinimizerInfo.cpp.

127 {
128  MinimizerInfo result("Genetic", "Genetic minimizer from TMVA library");
129  result.addAlgorithm("Default", "Default algorithm");
130  return result;
131 }

References addAlgorithm().

Referenced by MinimizerCatalog::MinimizerCatalog().

Here is the call graph for this function:

◆ buildTestMinimizerInfo()

MinimizerInfo MinimizerInfo::buildTestMinimizerInfo ( )
static

Creates information for simple test minimizer.

Definition at line 135 of file MinimizerInfo.cpp.

136 {
137  MinimizerInfo result("Test", "One-shot minimizer to test whole chain");
138  result.addAlgorithm("Default", "Default algorithm");
139  return result;
140 }

References addAlgorithm().

Referenced by MinimizerCatalog::MinimizerCatalog().

Here is the call graph for this function:

◆ addAlgorithm() [1/2]

void MinimizerInfo::addAlgorithm ( const AlgorithmInfo algorithm)
private

Adds minimizer algorithm to the list of defined algorithms.

Definition at line 144 of file MinimizerInfo.cpp.

145 {
146  m_current_algorithm = algorithm.name();
147  m_algorithms.push_back(algorithm);
148 }
std::string name() const
Definition: MinimizerInfo.h:33

References m_algorithms, m_current_algorithm, and AlgorithmInfo::name().

Referenced by addAlgorithm(), buildGeneticInfo(), buildGSLLMAInfo(), buildGSLMultiMinInfo(), buildGSLSimAnInfo(), buildMinuit2Info(), and buildTestMinimizerInfo().

Here is the call graph for this function:

◆ addAlgorithm() [2/2]

void MinimizerInfo::addAlgorithm ( const std::string &  algorithmName,
const std::string &  algorithmDescription 
)
private

Definition at line 150 of file MinimizerInfo.cpp.

152 {
153  addAlgorithm(AlgorithmInfo(algorithmName, algorithmDescription));
154 }
void addAlgorithm(const AlgorithmInfo &algorithm)
Adds minimizer algorithm to the list of defined algorithms.

References addAlgorithm(), and algorithmName().

Here is the call graph for this function:

Member Data Documentation

◆ m_name

std::string MinimizerInfo::m_name
private

Definition at line 75 of file MinimizerInfo.h.

Referenced by name().

◆ m_description

std::string MinimizerInfo::m_description
private

Definition at line 76 of file MinimizerInfo.h.

Referenced by description().

◆ m_algorithms

std::vector<AlgorithmInfo> MinimizerInfo::m_algorithms
private

◆ m_current_algorithm

std::string MinimizerInfo::m_current_algorithm
private

Definition at line 78 of file MinimizerInfo.h.

Referenced by addAlgorithm(), algorithmName(), and setAlgorithmName().


The documentation for this class was generated from the following files: