Loading...
Searching...
No Matches
eonc::helpers::create Namespace Reference

Functions

std::unique_ptr< Optimizer > mkOptim (std::shared_ptr< ObjectiveFunction > a_objf, OptType a_otype, const Parameters &a_params)

Function Documentation

◆ mkOptim()

std::unique_ptr< Optimizer > eonc::helpers::create::mkOptim ( std::shared_ptr< ObjectiveFunction > a_objf,
OptType a_otype,
const Parameters & a_params )
nodiscard

Definition at line 24 of file Optimizer.cpp.

26 {
27 switch (a_otype) {
28 case OptType::FIRE: {
29 return std::make_unique<FIRE>(a_objf, a_params);
30 }
31 case OptType::QM: {
32 return std::make_unique<Quickmin>(a_objf, a_params);
33 }
34 case OptType::CG: {
35 return std::make_unique<ConjugateGradients>(a_objf, a_params);
36 }
37 case OptType::LBFGS: {
38 return std::make_unique<LBFGS>(a_objf, a_params);
39 }
40 case OptType::SD: {
41 return std::make_unique<SteepestDescent>(a_objf, a_params);
42 }
43#ifdef WITH_XTSCI
44 case OptType::XTSCI: {
45 return std::make_unique<XtsciOptimizer>(a_objf, a_params);
46 }
47#else
48 case OptType::XTSCI: {
49 throw std::runtime_error(
50 "[Optimizer] opt_method=xtsci needs -Dwith_xtsci=true");
51 }
52#endif
53 case OptType::None: {
54 throw std::runtime_error("[Optimizer] Cannot create None");
55 }
56 case OptType::Unknown: {
57 throw std::runtime_error("[Optimizer] Cannot create Unknown");
58 }
59 default: {
60 throw std::runtime_error("Unsupported optimization type");
61 }
62 }
63}