- 3.0.2 optimal control module.
DiscreteCostEvaluatorBase.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 
7 #pragma once
8 
9 #include <Eigen/Core>
10 
11 namespace ct {
12 namespace optcon {
13 namespace tpl {
14 
21 template <typename SCALAR>
23 {
24 public:
25  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
26 
30  DiscreteCostEvaluatorBase() = default;
31 
35  virtual ~DiscreteCostEvaluatorBase() = default;
36 
37 
43  virtual SCALAR eval() = 0;
44 
51  virtual void evalGradient(size_t grad_length, Eigen::Map<Eigen::Matrix<SCALAR, Eigen::Dynamic, 1>>& grad) = 0;
52 
53  virtual void getSparsityPatternHessian(Eigen::VectorXi& iRow, Eigen::VectorXi& jCol)
54  {
55  throw std::runtime_error(
56  "Hessian evaluation not implemented for this cost function. Use limited-memory Hessian approximation!");
57  }
58 
66  virtual void sparseHessianValues(const Eigen::VectorXd& optVec, const Eigen::VectorXd& lambda, Eigen::VectorXd& hes)
67  {
68  throw std::runtime_error(
69  "Hessian evaluation not implemented for this cost function. Use limited-memory Hessian approximation!");
70  }
71 };
72 }
73 
75 
76 } // namespace optcon
77 } // namespace ct
Implements an abstract base class which evaluates the cost function and its gradient in the NLP...
Definition: DiscreteCostEvaluatorBase.h:22
virtual void evalGradient(size_t grad_length, Eigen::Map< Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 >> &grad)=0
Evaluates the cost gradient.
CppAD::AD< CppAD::cg::CG< double > > SCALAR
virtual void getSparsityPatternHessian(Eigen::VectorXi &iRow, Eigen::VectorXi &jCol)
Definition: DiscreteCostEvaluatorBase.h:53
virtual void sparseHessianValues(const Eigen::VectorXd &optVec, const Eigen::VectorXd &lambda, Eigen::VectorXd &hes)
Evaluates the cost hessian.
Definition: DiscreteCostEvaluatorBase.h:66
virtual ~DiscreteCostEvaluatorBase()=default
Destructor.
virtual SCALAR eval()=0
Evaluates the cost function.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW DiscreteCostEvaluatorBase()=default
Default constructor.