31 #ifndef _GENERICCONSTRAINTSBASE_H
32 #define _GENERICCONSTRAINTSBASE_H
34 #include <Eigen/Dense>
38 namespace DirectTrajectoryOptimization {
48 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
62 virtual Eigen::VectorXd
Evalfx(
const Eigen::VectorXd & input) = 0;
64 virtual void fx(
const Eigen::VectorXd & in , Eigen::VectorXd & out)
override;
70 virtual Eigen::MatrixXd
EvalFxJacobian(
const Eigen::VectorXd & input);
96 int GetNumConstraints() {
return g_size_;}
98 int GetNnzJac() {
return nnz_jac_;}
100 Eigen::VectorXi GetSparseRow() {
return iRow_;}
101 Eigen::VectorXi GetSparseCol() {
return jCol_;}
110 std::shared_ptr<GenericConstraintsBase> self_pointer;
117 Eigen::VectorXd g_low_;
118 Eigen::VectorXd g_up_;
120 Eigen::VectorXi iRow_;
121 Eigen::VectorXi jCol_;
127 output = this->
Evalfx(input);
137 this->
numDiff->df(input,this->mJacobian);
144 this->g_low_ = g_lb_candidate;
148 this->g_up_ = g_ub_candidate;
153 mJacobian.resize(g_size_,input_size_);
155 this->self_pointer = std::enable_shared_from_this<GenericConstraintsBase>::shared_from_this();
157 this->
numdifoperator = std::shared_ptr<FunctionOperator>(
new FunctionOperator(input_size_, g_size_ , this->self_pointer));
159 this->
numDiff = std::shared_ptr<Eigen::NumericalDiff<FunctionOperator> >(
new Eigen::NumericalDiff<FunctionOperator>(*this->
numdifoperator , std::numeric_limits<double>::epsilon()));
std::shared_ptr< Eigen::NumericalDiff< FunctionOperator > > numDiff
Definition: NumDiffDerivativesBase.hpp:108
void initialize_num_diff()
Overload this method to define the local pointers.
Definition: GenericConstraintsBase.hpp:151
Eigen::VectorXd GetConstraintsLowerBound()
Method to get the lower bound of the constraint.
Definition: GenericConstraintsBase.hpp:76
Eigen::VectorXd GetConstraintsUpperBound()
Method to get the upper bound of the constraint.
Definition: GenericConstraintsBase.hpp:82
Base class for numerical differentiation of vector functions.
std::shared_ptr< FunctionOperator > numdifoperator
Definition: NumDiffDerivativesBase.hpp:107
virtual Eigen::MatrixXd EvalFxJacobian(const Eigen::VectorXd &input)
To be overloaded by the derived class in case NumDiff is not required.
Definition: GenericConstraintsBase.hpp:131
void setConstraintsUpperBound(const Eigen::VectorXd &g_ub_candidate)
Method to set the upper bound of the constraint.
Definition: GenericConstraintsBase.hpp:147
virtual Eigen::VectorXd Evalfx(const Eigen::VectorXd &input)=0
To be overloaded by the derived class.
Base Class to define vector of constraints and its derivatives.
Definition: GenericConstraintsBase.hpp:44
void SetConstraintsLowerBound(const Eigen::VectorXd &g_lb_candidate)
Method to set the lower bound of the constraint.
Definition: GenericConstraintsBase.hpp:143
EIGEN_MAKE_ALIGNED_OPERATOR_NEW GenericConstraintsBase(int num_eq, int num_var)
Generic Constraint Constructor.
Definition: GenericConstraintsBase.hpp:55
virtual void fx(const Eigen::VectorXd &in, Eigen::VectorXd &out) override
Overload this method in the derived class to obtain numerical approximation of the gradient...
Definition: GenericConstraintsBase.hpp:125
This base class provides functionality for numerical differentiation of vector functions.
Definition: NumDiffDerivativesBase.hpp:44