aligator  0.6.1
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
constraint.hpp
Go to the documentation of this file.
1
5#pragma once
6
8
9namespace aligator {
10
13template <typename Scalar> struct StageConstraintTpl {
14 shared_ptr<StageFunctionTpl<Scalar>> func;
15 shared_ptr<ConstraintSetBase<Scalar>> set;
16 long nr() const { return func->nr; }
17};
18
20template <typename Scalar> struct ConstraintStackTpl {
22 using ConstraintType = StageConstraintTpl<Scalar>;
25 using iterator = typename std::vector<ConstraintType>::iterator;
26
28
29 auto begin() { return storage_.begin(); }
30 auto end() { return storage_.end(); }
31
32 std::size_t size() const { return storage_.size(); }
33 bool empty() const { return size() == 0; }
34 void clear();
35
36 void pushBack(const ConstraintType &el, const long nr);
37 void pushBack(const ConstraintType &el);
38
40 const std::vector<long> &dims() const { return dims_; }
42 ALIGATOR_DEPRECATED const std::vector<long> &getDims() const { return dims_; }
43
44 long totalDim() const { return total_dim_; }
45
47 ConstraintType &operator[](std::size_t j) {
48 assert((j < this->storage_.size()) && "i exceeds number of constraints!");
49 return storage_[j];
50 }
51
53 const ConstraintType &operator[](std::size_t j) const {
54 assert((j < this->storage_.size()) && "i exceeds number of constraints!");
55 return storage_[j];
56 }
57
58protected:
59 std::vector<ConstraintType> storage_;
60 std::vector<long> indices_;
61 std::vector<long> dims_;
62 long total_dim_ = 0;
63};
64
65} // namespace aligator
66
67#include "aligator/core/constraint.hxx"
68
69#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
70#include "aligator/core/constraint.txx"
71#endif
Base definitions for ternary functions.
Main package namespace.
Convenience class to manage a stack of constraints.
const std::vector< long > & dims() const
Get the set of dimensions for each constraint in the stack.
void pushBack(const ConstraintType &el, const long nr)
ConstraintType & operator[](std::size_t j)
Get the i-th constraint.
std::size_t size() const
typename std::vector< ConstraintType >::iterator iterator
std::vector< long > indices_
std::vector< ConstraintType > storage_
StageConstraintTpl< Scalar > ConstraintType
std::vector< long > dims_
void pushBack(const ConstraintType &el)
const ConstraintType & operator[](std::size_t j) const
Get the i-th constraint.
ALIGATOR_DEPRECATED const std::vector< long > & getDims() const
Simple struct holding together a function and set, to describe a constraint.
shared_ptr< ConstraintSetBase< Scalar > > set
shared_ptr< StageFunctionTpl< Scalar > > func
const int nr
Function codimension.