- 3.0.2 optimal control module.
NlpSolver.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 #include <ct/optcon/nlp/Nlp.h>
9 #include "NlpSolverSettings.h"
10 
11 namespace ct {
12 namespace optcon {
13 namespace tpl {
14 
20 template <typename SCALAR>
21 class NlpSolver
22 {
23 public:
24  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
25 
29  NlpSolver() : isInitialized_(false) {}
35  NlpSolver(std::shared_ptr<Nlp<SCALAR>> nlp) : nlp_(nlp) {}
42  NlpSolver(std::shared_ptr<Nlp<SCALAR>> nlp, NlpSolverSettings settings)
43  : nlp_(nlp), settings_(settings), isInitialized_(false)
44  {
45  }
46 
50  virtual ~NlpSolver() = default;
56  void configure(const NlpSolverSettings& settings)
57  {
58  settings_ = settings;
59  configureDerived(settings);
60  }
61 
67  virtual void configureDerived(const NlpSolverSettings& settings) = 0;
68 
74  virtual bool solve() = 0;
75 
83  virtual void prepareWarmStart(const size_t maxIterations) = 0;
84 
85  bool isInitialized() { return isInitialized_; }
86 protected:
87  std::shared_ptr<Nlp<SCALAR>> nlp_;
90 };
91 }
92 
94 
95 } // namespace optcon
96 } // namespace ct
NlpSolver(std::shared_ptr< Nlp< SCALAR >> nlp)
Custom Constructor 1.
Definition: NlpSolver.h:35
Abstract base class for the NLP solvers.
Definition: NlpSolver.h:21
NlpSolver(std::shared_ptr< Nlp< SCALAR >> nlp, NlpSolverSettings settings)
Custom constructor 2.
Definition: NlpSolver.h:42
bool isInitialized_
Definition: NlpSolver.h:89
Contains the NLP solver settings.
Definition: NlpSolverSettings.h:261
The NLP base class. This class serves as abstract base class to use as an interface to the NLP solver...
Definition: Nlp.h:32
virtual void prepareWarmStart(const size_t maxIterations)=0
Prepares the solver for a warmstarting scenario with available (good) initial guess.
std::shared_ptr< Nlp< SCALAR > > nlp_
Definition: NlpSolver.h:87
EIGEN_MAKE_ALIGNED_OPERATOR_NEW NlpSolver()
Default constructor.
Definition: NlpSolver.h:29
virtual ~NlpSolver()=default
Destructor.
bool isInitialized()
Definition: NlpSolver.h:85
NlpSolverSettings settings_
Definition: NlpSolver.h:88
void configure(const NlpSolverSettings &settings)
Configures the solver with new settings.
Definition: NlpSolver.h:56
virtual void configureDerived(const NlpSolverSettings &settings)=0
Forwards the settings to the corresponding nlp solver.
virtual bool solve()=0
Solves the nlp.