20 template <
typename SCALAR>
24 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
25 using VectorXs = Eigen::Matrix<SCALAR, Eigen::Dynamic, 1>;
74 virtual void genSparsityPattern(Eigen::VectorXi& iRow_vec, Eigen::VectorXi& jCol_vec) = 0;
87 throw std::runtime_error(
88 "genSparsityPatternHessian() for DiscreteConstraintBase not implemented. Use Hessian approximation.");
101 const Eigen::VectorXd& lambda,
102 Eigen::VectorXd& sparseHes)
104 throw std::runtime_error(
105 "sparseHessianValues() for DiscreteConstraintBase not implemented. Use Hessian approximation.");
140 const size_t num_elements,
141 Eigen::VectorXi& iRow_vec,
142 Eigen::VectorXi& jCol_vec,
143 const size_t indexNumber);
161 const size_t num_rows,
162 const size_t num_cols,
163 Eigen::VectorXi& iRow_vec,
164 Eigen::VectorXi& jCol_vec,
165 const size_t indexNumber);
171 template <
typename SCALAR>
173 const size_t num_elements,
174 Eigen::VectorXi& iRow_vec,
175 Eigen::VectorXi& jCol_vec,
176 const size_t indexNumber)
178 Eigen::VectorXi new_row_indices;
179 Eigen::VectorXi new_col_indices;
180 new_row_indices.resize(num_elements);
181 new_col_indices.resize(num_elements);
185 for (
size_t i = 0;
i < num_elements; ++
i)
187 new_row_indices(count) =
i;
188 new_col_indices(count) = col_start +
i;
192 assert(count == num_elements);
194 iRow_vec.segment(indexNumber, num_elements) = new_row_indices;
195 jCol_vec.segment(indexNumber, num_elements) = new_col_indices;
200 template <
typename SCALAR>
202 const size_t num_rows,
203 const size_t num_cols,
204 Eigen::VectorXi& iRow_vec,
205 Eigen::VectorXi& jCol_vec,
206 const size_t indexNumber)
208 size_t num_gen_indices = num_rows * num_cols;
210 Eigen::VectorXi new_row_indices;
211 Eigen::VectorXi new_col_indices;
212 new_row_indices.resize(num_gen_indices);
213 new_col_indices.resize(num_gen_indices);
217 for (
size_t row = 0; row < num_rows; ++row)
219 for (
size_t col = col_start; col < col_start + num_cols; ++col)
221 new_row_indices(count) = row;
222 new_col_indices(count) = col;
227 assert(count == num_gen_indices);
229 iRow_vec.segment(indexNumber, num_gen_indices) = new_row_indices;
230 jCol_vec.segment(indexNumber, num_gen_indices) = new_col_indices;
232 return num_gen_indices;
virtual size_t getNumNonZerosJacobian()=0
Returns the number of non zero elements of the jacobian.
virtual VectorXs eval()=0
Evaluates the constraint violation.
virtual ~DiscreteConstraintBase()=default
Destructor.
virtual VectorXs evalSparseJacobian()=0
Returns the non zero elements of the eval method with respect to the optimization variables...
virtual void sparseHessianValues(const Eigen::VectorXd &optVec, const Eigen::VectorXd &lambda, Eigen::VectorXd &sparseHes)
Returns the non zero elements (values) of the Hessian matrix of this constraint.
Definition: DiscreteConstraintBase.h:100
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > VectorXs
Definition: DiscreteConstraintBase.h:25
Eigen::VectorXi & iRowHessian()
Definition: DiscreteConstraintBase.h:123
size_t genBlockIndices(const size_t col_start, const size_t num_rows, const size_t num_cols, Eigen::VectorXi &iRow_vec, Eigen::VectorXi &jCol_vec, const size_t indexNumber)
This method generates Row and Column vectors which indicate the sparsity pattern of the constraint ja...
Definition: DiscreteConstraintBase.h:201
Implements an abstract base class from which all the discrete custom NLP constraints should derive...
Definition: DiscreteConstraintBase.h:21
Eigen::VectorXi & jColHessian()
Definition: DiscreteConstraintBase.h:124
virtual void genSparsityPatternHessian(Eigen::VectorXi &iRow_vec, Eigen::VectorXi &jCol_vec)
Returns the sparsity structure of the constraint hessian.
Definition: DiscreteConstraintBase.h:85
virtual VectorXs getLowerBound()=0
Returns the lower bound of the constraint.
Eigen::VectorXi iRowHessian_
Definition: DiscreteConstraintBase.h:167
DiscreteConstraintBase()=default
Default constructor.
for i
Definition: mpc_unittest_plotting.m:14
virtual size_t getConstraintSize()=0
Returns size of the constraint vector.
virtual VectorXs getUpperBound()=0
Returns the upper bound of the constraint.
size_t genDiagonalIndices(const size_t col_start, const size_t num_elements, Eigen::VectorXi &iRow_vec, Eigen::VectorXi &jCol_vec, const size_t indexNumber)
This method generates Row and Column vectors which indicate the sparsity pattern of the constraint ja...
Definition: DiscreteConstraintBase.h:172
virtual void genSparsityPattern(Eigen::VectorXi &iRow_vec, Eigen::VectorXi &jCol_vec)=0
Returns the sparsity structure of the constraint jacobian.
Eigen::VectorXi jColHessian_
Definition: DiscreteConstraintBase.h:168