Loading...
Searching...
No Matches
Optimizer.cpp
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
12#include "eon/Optimizer.h"
13#include "eon/BaseStructures.h"
15#include "eon/FIRE.h"
16#include "eon/LBFGS.h"
17#include "eon/Quickmin.h"
18#include "eon/SteepestDescent.h"
19#ifdef WITH_XTSCI
20#include "eon/XtsciOptimizer.h"
21#endif
22
24std::unique_ptr<Optimizer> mkOptim(std::shared_ptr<ObjectiveFunction> a_objf,
25 OptType a_otype,
26 const Parameters &a_params) {
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}
64} // namespace eonc::helpers::create
Direct optimization for energy minimization.
The optimizer class is used to serve as an abstract class for all optimizers, as well as to call an o...
std::unique_ptr< Optimizer > mkOptim(std::shared_ptr< ObjectiveFunction > a_objf, OptType a_otype, const Parameters &a_params)
Definition Optimizer.cpp:24