41 #include "geneva/Go2.hpp" 50 std::vector<ComPWA::Optimizer::Geneva::AlgorithmTypes> AlgorithmOrder_,
51 std::string ConfigFileDir_)
52 : AlgorithmOrder(AlgorithmOrder_), ConfigFileDir(ConfigFileDir_) {
53 LOG(INFO) <<
"GenevaIF::GenevaIF(): Starting Geneva interface (config dir=" 69 char *argv[] = {temp};
73 if (go.clientMode()) {
74 LOG(INFO) <<
"Geneva Client waiting for action!";
79 std::vector<double> initialpars;
80 for (
auto const &x : FitParameters)
81 initialpars.push_back(x.Value);
83 double InitialEstimatorValue(Estimator.
evaluate());
85 std::shared_ptr<GFMinIndividual> p(
86 new GFMinIndividual(Estimator, FitParameters));
90 switch (AlgorithmType) {
92 GEvolutionaryAlgorithmFactory eaf(
ConfigFileDir +
"GEvolutionary.json");
97 GSwarmAlgorithmFactory sf(
ConfigFileDir +
"GGradientDescent.json");
102 GGradientDescentFactory gdf(
ConfigFileDir +
"GGradientDescent.json");
109 std::chrono::steady_clock::time_point StartTime =
110 std::chrono::steady_clock::now();
112 std::shared_ptr<GFMinIndividual> bestIndividual_ptr =
113 go.optimize<GFMinIndividual>();
114 std::chrono::steady_clock::time_point EndTime =
115 std::chrono::steady_clock::now();
118 FitParameters, finalFitPars, finalFitPars.size(), InitialEstimatorValue,
119 std::get<1>(bestIndividual_ptr->getBestKnownPrimaryFitness()),
120 std::chrono::duration_cast<std::chrono::seconds>(EndTime - StartTime)});
125 std::shared_ptr<Gem::Geneva::GFMinIndividual> BestIndividual)
const {
127 std::vector<double> finalpars;
128 BestIndividual->streamline(finalpars);
132 for (
auto const &p : ParList) {
136 FinalParameters.push_back(
140 return FinalParameters;
This class provides a wrapper around the Geneva library.
virtual void updateParametersFrom(const std::vector< double > &)=0
It is important to input the vector in the same length and order as defined in the getParameters() me...
ComPWA::FitParameterList getFinalParameters(const FitParameterList &ParList, std::shared_ptr< Gem::Geneva::GFMinIndividual > min) const
bool isValid(const FitParameterList &FitParameters, const std::vector< ComPWA::Parameter > &EstimatorParameters)
std::vector< FitParameter< double > > FitParameterList
GenevaIF(std::vector< ComPWA::Optimizer::Geneva::AlgorithmTypes > AlgorithmOrder_={AlgorithmTypes::EVOLUTIONARY, AlgorithmTypes::GRADIENT_DECENT}, std::string ConfigFileDir_="./")
std::vector< ComPWA::Optimizer::Geneva::AlgorithmTypes > AlgorithmOrder
virtual OutputType evaluate(const InputTypes &... args) noexcept=0
Data structure which resembles a general fit result.
virtual std::vector< Parameter > getParameters() const =0
GenevaResult optimize(Estimator::Estimator< double > &Estimator, FitParameterList FitParameters) final
Finds the optimal value of the Estimator, by varying its parameters.
std::string ConfigFileDir
This class template provides the interface to optimization libraries.