11 template <
size_t DERIVED_DIM,
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
16 sanityCheck(DERIVED_DIM, lb, ub);
19 constrSize_ = DERIVED_DIM;
20 Base::lb_.resize(DERIVED_DIM);
21 Base::ub_.resize(DERIVED_DIM);
22 sparsity_ = Eigen::Matrix<int, DERIVED_DIM, 1>::Ones();
23 sparsity_J_.resize(DERIVED_DIM, DERIVED_DIM);
24 sparsity_J_.setIdentity();
25 Base::lb_ = lb.template cast<SCALAR>();
26 Base::ub_ = ub.template cast<SCALAR>();
29 template <
size_t DERIVED_DIM,
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
32 const Eigen::VectorXi& sparsity_vec)
35 assert(sparsity_vec.maxCoeff() <= 1);
36 assert(sparsity_vec.minCoeff() >= 0);
38 constrSize_ = (size_t)sparsity_vec.sum();
41 sanityCheck(constrSize_, lb, ub);
43 Base::lb_.resize(constrSize_);
44 Base::ub_.resize(constrSize_);
45 sparsity_ = sparsity_vec;
46 sparsity_J_.resize(constrSize_, DERIVED_DIM);
47 sparsity_J_ = diagSparsityVecToSparsityMat(sparsity_vec, constrSize_);
48 Base::lb_ = lb.template cast<SCALAR>();
49 Base::ub_ = ub.template cast<SCALAR>();
52 template <
size_t DERIVED_DIM,
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
54 :
Base(arg), sparsity_(arg.sparsity_), sparsity_J_(arg.sparsity_J_), constrSize_(arg.constrSize_)
58 template <
size_t DERIVED_DIM,
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
63 template <
size_t DERIVED_DIM,
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
69 template <
size_t DERIVED_DIM,
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
72 const size_t& nConstr)
80 assert(spVec.rows() == DERIVED_DIM);
81 for (
size_t i = 0;
i < DERIVED_DIM;
i++)
93 template <
size_t DERIVED_DIM,
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
99 if ((lb.rows() !=
static_cast<int>(nCon)) | (ub.rows() !=
static_cast<int>(nCon)))
101 std::cout <<
"no. Constraints: " << nCon << std::endl;
102 std::cout <<
"BoxConstraintBase: lb " << lb.transpose() << std::endl;
103 std::cout <<
"BoxConstraintBase: ub " << ub.transpose() << std::endl;
104 throw std::runtime_error(
"BoxConstraintBase: wrong constraint sizes in StateConstraint");
108 for (
size_t i = 0;
i < nCon;
i++)
112 std::cout <<
"BoxConstraintBase: lb " << lb.transpose() << std::endl;
113 std::cout <<
"BoxConstraintBase: ub " << ub.transpose() << std::endl;
114 throw std::runtime_error(
"BoxConstraintBase: wrong boundaries: lb > ub");
120 template <
size_t DERIVED_DIM,
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
123 const size_t& constrSize,
127 Base::genSparseDiagonalIndices(sparsity_vec, rows, cols);
128 for (
size_t i = 0;
i < constrSize;
i++)
BoxConstraintBase(const decision_vector_t &vLow, const decision_vector_t &vHigh)
Constructor taking lower and upper state bounds directly. Assumes the box constraint is dense...
Definition: BoxConstraintBase-impl.h:12
Eigen::Matrix< SCALAR, Eigen::Dynamic, DERIVED_DIM > sparsity_matrix_t
Definition: BoxConstraintBase.h:36
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > VectorXs
Definition: ConstraintBase.h:31
for i
Definition: mpc_unittest_plotting.m:14
Eigen::Matrix< int, Eigen::Dynamic, 1 > VectorXi
Definition: BoxConstraintBase.h:32
Base for box constraint, templated on dimension of the decision vector of the derived class...
Definition: BoxConstraintBase.h:20
Base class for the constraints used in this toolbox.
Definition: ConstraintBase.h:21