11 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
16 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
18 : lb_(arg.lb_), ub_(arg.ub_), name_(arg.name_)
22 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
28 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
32 ct::core::ADCGScalar
t)
34 throw std::runtime_error(
"Term " + name_ +
" has no Implementation of evaluateCppaCg.");
38 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
44 throw std::runtime_error(
45 "This constraint function element is not implemented for the given term." 46 "Please use either auto-diff cost function or implement the analytical derivatives manually.");
49 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
55 throw std::runtime_error(
56 "This constraint function element is not implemented for the given term." 57 "Please use either auto-diff cost function or implement the analytical derivatives manually.");
60 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
67 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
74 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
77 constraintName = name_;
80 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
83 name_ = constraintName;
86 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
89 return STATE_DIM * getConstraintSize();
92 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
95 return CONTROL_DIM * getConstraintSize();
98 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
104 MatrixXs jacState = jacobianState(x, u, t);
106 VectorXs jac(Eigen::Map<VectorXs>(jacState.data(), jacState.rows() * jacState.cols()));
111 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
117 MatrixXs jacInput = jacobianInput(x, u, t);
119 VectorXs jac(Eigen::Map<VectorXs>(jacInput.data(), jacInput.rows() * jacInput.cols()));
123 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
126 genBlockIndices(getConstraintSize(), STATE_DIM, rows, cols);
129 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
132 genBlockIndices(getConstraintSize(), CONTROL_DIM, rows, cols);
135 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
137 Eigen::VectorXi& iRow_vec,
138 Eigen::VectorXi& jCol_vec)
140 iRow_vec.resize(num_elements);
141 jCol_vec.resize(num_elements);
145 for (
size_t i = 0;
i < num_elements; ++
i)
154 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
156 Eigen::VectorXi& iRow_vec,
157 Eigen::VectorXi& jCol_vec)
160 assert(diag_sparsity.maxCoeff() <= 1);
161 assert(diag_sparsity.minCoeff() >= 0);
163 const int num_elements = diag_sparsity.sum();
165 iRow_vec.resize(num_elements);
166 jCol_vec.resize(num_elements);
170 for (
int i = 0;
i < diag_sparsity.rows(); ++
i)
172 if (diag_sparsity(
i) == 1)
181 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
183 const size_t num_cols,
184 Eigen::VectorXi& iRow_vec,
185 Eigen::VectorXi& jCol_vec)
187 size_t num_gen_indices = num_rows * num_cols;
189 iRow_vec.resize(num_gen_indices);
190 jCol_vec.resize(num_gen_indices);
194 for (
size_t row = 0; row < num_rows; ++row)
196 for (
size_t col = 0; col < num_cols; ++col)
198 iRow_vec(count) = row;
199 jCol_vec(count) = col;
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
Eigen::Matrix< SCALAR, Eigen::Dynamic, Eigen::Dynamic > MatrixXs
Definition: ConstraintBase.h:32
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > VectorXs
Definition: ConstraintBase.h:31
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
CppAD::AD< CppAD::cg::CG< double > > SCALAR
for i
Definition: mpc_unittest_plotting.m:14
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
ConstraintBase(std::string name="Unnamed")
Custom constructor.
Definition: ConstraintBase-impl.h:12
Base class for the constraints used in this toolbox.
Definition: ConstraintBase.h:21