25 #ifndef SRC_OPTIMAL_CONTROL_INCLUDE_CORBO_OPTIMAL_CONTROL_STRUCTURED_OCP_EDGES_TRAPEZOIDAL_COLLOCATION_EDGES_H_ 26 #define SRC_OPTIMAL_CONTROL_INCLUDE_CORBO_OPTIMAL_CONTROL_STRUCTURED_OCP_EDGES_TRAPEZOIDAL_COLLOCATION_EDGES_H_ 43 using Ptr = std::shared_ptr<TrapezoidalCollocationDynamicsOnlyEdge>;
44 using UPtr = std::unique_ptr<TrapezoidalCollocationDynamicsOnlyEdge>;
59 bool isLinear()
const override {
return false; }
80 values.noalias() = 0.5 * dt->
value() * (
_f1 +
_f2) - (x2->
values() - x1->values());
98 using Ptr = std::shared_ptr<TrapezoidalCollocationIntegralCostEdge>;
99 using UPtr = std::unique_ptr<TrapezoidalCollocationIntegralCostEdge>;
103 :
Edge<
VectorVertex,
VectorVertex,
VectorVertex,
VectorVertex,
ScalarVertex>(x1, u1, u2, x2, dt), _stage_cost(stage_cost), _k(k)
106 assert(stage_cost->getIntegralStateControlTermDimension(_k) == 1);
131 _stage_cost->computeIntegralStateControlTerm(_k, x1->
values(), u1->
values(), _cost1);
132 _stage_cost->computeIntegralStateControlTerm(_k, x2->
values(), u2->
values(), _cost2);
133 values[0] = 0.5 * dt->
value() * (_cost1[0] + _cost2[0]);
151 using Ptr = std::shared_ptr<TrapezoidalCollocationIntegralEqualityDynamicsEdge>;
152 using UPtr = std::unique_ptr<TrapezoidalCollocationIntegralEqualityDynamicsEdge>;
162 _dim_dyn =
_dynamics->getStateDimension();
163 _dim_int_eq = _stage_eq ? _stage_eq->getIntegralStateControlTermDimension(_k) : 0;
164 _dim_eq = _dim_dyn + _dim_int_eq;
166 _eq1.resize(_dim_int_eq);
167 _eq2.resize(_dim_int_eq);
169 _f1.resize(_dim_dyn);
170 _f2.resize(_dim_dyn);
199 _stage_eq->computeIntegralStateControlTerm(_k, x1->
values(), u1->
values(), _eq1);
200 _stage_eq->computeIntegralStateControlTerm(_k, x2->
values(), u2->
values(), _eq2);
201 values.tail(_dim_int_eq).noalias() = 0.5 * dt->
value() * (_eq1 + _eq2);
229 using Ptr = std::shared_ptr<TrapezoidalCollocationIntegralEqualityEdge>;
230 using UPtr = std::unique_ptr<TrapezoidalCollocationIntegralEqualityEdge>;
234 :
Edge<
VectorVertex,
VectorVertex,
VectorVertex,
VectorVertex,
ScalarVertex>(x1, u1, u2, x2, dt), _stage_eq(stage_eq), _k(k)
236 _dim_eq = _stage_eq ? _stage_eq->getIntegralStateControlTermDimension(_k) : 0;
238 _eq1.resize(_dim_eq);
239 _eq2.resize(_dim_eq);
261 _stage_eq->computeIntegralStateControlTerm(_k, x1->
values(), u1->
values(), _eq1);
262 _stage_eq->computeIntegralStateControlTerm(_k, x2->
values(), u2->
values(), _eq2);
263 values.noalias() = 0.5 * dt->
value() * (_eq1 + _eq2);
283 using Ptr = std::shared_ptr<TrapezoidalCollocationIntegralInequalityEdge>;
284 using UPtr = std::unique_ptr<TrapezoidalCollocationIntegralInequalityEdge>;
288 :
Edge<
VectorVertex,
VectorVertex,
VectorVertex,
VectorVertex,
ScalarVertex>(x1, u1, u2, x2, dt), _stage_ineq(stage_ineq), _k(k)
290 _dim_ineq = _stage_ineq ? _stage_ineq->getIntegralStateControlTermDimension(_k) : 0;
292 _ineq1.resize(_dim_ineq);
293 _ineq2.resize(_dim_ineq);
316 _stage_ineq->computeIntegralStateControlTerm(_k, x1->
values(), u1->
values(), _ineq1);
317 _stage_ineq->computeIntegralStateControlTerm(_k, x2->
values(), u2->
values(), _ineq2);
318 values.noalias() = 0.5 * dt->
value() * (_ineq1 + _ineq2);
337 #endif // SRC_OPTIMAL_CONTROL_INCLUDE_CORBO_OPTIMAL_CONTROL_STRUCTURED_OCP_EDGES_TRAPEZOIDAL_COLLOCATION_EDGES_H_ TrapezoidalCollocationIntegralCostEdge(VectorVertex &x1, VectorVertex &u1, VectorVertex &u2, VectorVertex &x2, ScalarVertex &dt, StageCost::Ptr stage_cost, int k)
void computeValues(Eigen::Ref< Eigen::VectorXd > values) override
Compute function values.
bool isLeastSquaresForm() const override
Defines if the edge is formulated as Least-Squares form.
void computeValues(Eigen::Ref< Eigen::VectorXd > values) override
Compute function values.
bool isLeastSquaresForm() const override
Defines if the edge is formulated as Least-Squares form.
TrapezoidalCollocationDynamicsOnlyEdge(SystemDynamicsInterface::Ptr dynamics, VectorVertex &x1, VectorVertex &u1, VectorVertex &u2, VectorVertex &x2, ScalarVertex &dt)
std::unique_ptr< TrapezoidalCollocationDynamicsOnlyEdge > UPtr
TrapezoidalCollocationIntegralInequalityEdge(VectorVertex &x1, VectorVertex &u1, VectorVertex &u2, VectorVertex &x2, ScalarVertex &dt, StageInequalityConstraint::Ptr stage_ineq, int k)
TrapezoidalCollocationIntegralEqualityEdge(VectorVertex &x1, VectorVertex &u1, VectorVertex &u2, VectorVertex &x2, ScalarVertex &dt, StageEqualityConstraint::Ptr stage_eq, int k)
bool isLinear() const override
Return true if the edge is linear (and hence its Hessian is always zero)
bool isLinear() const override
Return true if the edge is linear (and hence its Hessian is always zero)
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW
bool isLinear() const override
Return true if the edge is linear (and hence its Hessian is always zero)
std::unique_ptr< TrapezoidalCollocationIntegralEqualityDynamicsEdge > UPtr
bool isLeastSquaresForm() const override
Defines if the edge is formulated as Least-Squares form.
Vertex implementation for scalar values.
bool isLeastSquaresForm() const override
Defines if the edge is formulated as Least-Squares form.
StageEqualityConstraint::Ptr _stage_eq
std::shared_ptr< StageEqualityConstraint > Ptr
int getDimension() const override
Get dimension of the edge (dimension of the cost-function/constraint value vector) ...
std::shared_ptr< StageInequalityConstraint > Ptr
std::unique_ptr< TrapezoidalCollocationIntegralCostEdge > UPtr
void computeValues(Eigen::Ref< Eigen::VectorXd > values) override
Compute function values.
bool isLeastSquaresForm() const override
Defines if the edge is formulated as Least-Squares form.
std::shared_ptr< TrapezoidalCollocationIntegralEqualityEdge > Ptr
virtual ~TrapezoidalCollocationDynamicsOnlyEdge()=default
TrapezoidalCollocationIntegralEqualityDynamicsEdge(SystemDynamicsInterface::Ptr dynamics, VectorVertex &x1, VectorVertex &u1, VectorVertex &u2, VectorVertex &x2, ScalarVertex &dt, StageEqualityConstraint::Ptr stage_eq, int k)
std::unique_ptr< TrapezoidalCollocationIntegralEqualityEdge > UPtr
bool isLinear() const override
Return true if the edge is linear (and hence its Hessian is always zero)
StageEqualityConstraint::Ptr _stage_eq
std::shared_ptr< TrapezoidalCollocationIntegralCostEdge > Ptr
const double & value() const
Get underlying value.
std::shared_ptr< TrapezoidalCollocationDynamicsOnlyEdge > Ptr
A matrix or vector expression mapping an existing expression.
void computeValues(Eigen::Ref< Eigen::VectorXd > values) override
Compute function values.
int getDimension() const override
Get dimension of the edge (dimension of the cost-function/constraint value vector) ...
int getDimension() const override
Get dimension of the edge (dimension of the cost-function/constraint value vector) ...
std::shared_ptr< TrapezoidalCollocationIntegralEqualityDynamicsEdge > Ptr
int getDimension() const override
Get dimension of the edge (dimension of the cost-function/constraint value vector) ...
bool isLinear() const override
Return true if the edge is linear (and hence its Hessian is always zero)
Templated base edge class that stores an arbitary number of value.
Vertex implementation that stores an Eigen::VectorXd (dynamic dimension)
StageCost::Ptr _stage_cost
std::shared_ptr< StageCost > Ptr
const Eigen::VectorXd & values() const
Read-access to the underlying value vector.
const VertexContainer _vertices
Vertex container.
SystemDynamicsInterface::Ptr _dynamics
SystemDynamicsInterface::Ptr _dynamics
std::unique_ptr< TrapezoidalCollocationIntegralInequalityEdge > UPtr
std::shared_ptr< TrapezoidalCollocationIntegralInequalityEdge > Ptr
int getDimension() const override
Get dimension of the edge (dimension of the cost-function/constraint value vector) ...
void computeValues(Eigen::Ref< Eigen::VectorXd > values) override
Compute function values.
std::shared_ptr< SystemDynamicsInterface > Ptr
StageInequalityConstraint::Ptr _stage_ineq