src/math/constraint-inequality.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017 CNRS
3 //
4 // This file is part of tsid
5 // tsid is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 // tsid is distributed in the hope that it will be
10 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Lesser Public License for more details. You should have
13 // received a copy of the GNU Lesser General Public License along with
14 // tsid If not, see
15 // <http://www.gnu.org/licenses/>.
16 //
17 
19 
20 using namespace tsid::math;
21 
23  : ConstraintBase(name) {}
24 
26  const unsigned int rows,
27  const unsigned int cols)
29  m_lb(Vector::Zero(rows)),
30  m_ub(Vector::Zero(rows)) {}
31 
35  : ConstraintBase(name, A), m_lb(lb), m_ub(ub) {
36  PINOCCHIO_CHECK_INPUT_ARGUMENT(A.rows() == lb.rows(),
37  "The number of rows of A and lb do not match");
38  PINOCCHIO_CHECK_INPUT_ARGUMENT(A.rows() == ub.rows(),
39  "The number of rows of A and ub do not match");
40 }
41 
42 unsigned int ConstraintInequality::rows() const {
43  assert(m_A.rows() == m_lb.rows());
44  assert(m_A.rows() == m_ub.rows());
45  return (unsigned int)m_A.rows();
46 }
47 
48 unsigned int ConstraintInequality::cols() const {
49  return (unsigned int)m_A.cols();
50 }
51 
52 void ConstraintInequality::resize(const unsigned int r, const unsigned int c) {
53  m_A.setZero(r, c);
54  m_lb.setZero(r);
55  m_ub.setZero(r);
56 }
57 
58 bool ConstraintInequality::isEquality() const { return false; }
59 bool ConstraintInequality::isInequality() const { return true; }
60 bool ConstraintInequality::isBound() const { return false; }
61 
63  assert(false);
64  return m_lb;
65 }
66 const Vector& ConstraintInequality::lowerBound() const { return m_lb; }
67 const Vector& ConstraintInequality::upperBound() const { return m_ub; }
68 
70  assert(false);
71  return m_lb;
72 }
75 
77  assert(false);
78  return false;
79 }
81  m_lb = lb;
82  return true;
83 }
85  m_ub = ub;
86  return true;
87 }
88 
90  return ((m_A * x).array() <= m_ub.array() + tol).all() &&
91  ((m_A * x).array() >= m_lb.array() - tol).all();
92 }
ex_4_plan_LIPM_romeo.A
A
Definition: ex_4_plan_LIPM_romeo.py:110
test_Constraint.ub
ub
Definition: test_Constraint.py:13
PINOCCHIO_CHECK_INPUT_ARGUMENT
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...)
tsid::math::ConstraintInequality::isInequality
bool isInequality() const override
Definition: src/math/constraint-inequality.cpp:59
tsid::math::ConstraintInequality::vector
const Vector & vector() const override
Definition: src/math/constraint-inequality.cpp:62
tsid::math::ConstraintBase
Abstract class representing a linear equality/inequality constraint. Equality constraints are represe...
Definition: constraint-base.hpp:35
c
Vec3f c
rows
int rows
tsid::math::ConstraintInequality::cols
unsigned int cols() const override
Definition: src/math/constraint-inequality.cpp:48
tsid::math::ConstraintBase::m_A
Matrix m_A
Definition: constraint-base.hpp:75
tsid::math::ConstraintInequality::lowerBound
const Vector & lowerBound() const override
Definition: src/math/constraint-inequality.cpp:66
tsid::math::ConstraintInequality::isBound
bool isBound() const override
Definition: src/math/constraint-inequality.cpp:60
tsid::math
Definition: constraint-base.hpp:26
tsid::math::ConstraintInequality::setVector
bool setVector(ConstRefVector b) override
Definition: src/math/constraint-inequality.cpp:76
tsid::math::ConstraintInequality::isEquality
bool isEquality() const override
Definition: src/math/constraint-inequality.cpp:58
r
FCL_REAL r
test_Constraint.tol
int tol
Definition: test_Constraint.py:10
tsid::math::ConstraintInequality::setUpperBound
bool setUpperBound(ConstRefVector ub) override
Definition: src/math/constraint-inequality.cpp:84
tsid::math::ConstraintInequality::setLowerBound
bool setLowerBound(ConstRefVector lb) override
Definition: src/math/constraint-inequality.cpp:80
tsid::math::ConstraintInequality::resize
void resize(unsigned int r, unsigned int c) override
Definition: src/math/constraint-inequality.cpp:52
tsid::math::ConstraintInequality::m_lb
Vector m_lb
Definition: math/constraint-inequality.hpp:61
tsid::math::ConstraintInequality::checkConstraint
bool checkConstraint(ConstRefVector x, double tol=1e-6) const override
Definition: src/math/constraint-inequality.cpp:89
test_Constraint.lb
float lb
Definition: test_Constraint.py:12
setup.name
name
Definition: setup.in.py:179
tsid::math::ConstRefVector
const typedef Eigen::Ref< const Vector > ConstRefVector
Definition: math/fwd.hpp:48
tsid::math::Vector
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: math/fwd.hpp:35
tsid::math::ConstraintInequality::ConstraintInequality
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ConstraintInequality(const std::string &name)
Definition: src/math/constraint-inequality.cpp:22
constraint-inequality.hpp
test_Solvers.x
x
Definition: test_Solvers.py:67
tsid::math::ConstRefMatrix
const typedef Eigen::Ref< const Matrix > ConstRefMatrix
Definition: math/fwd.hpp:51
tsid::math::ConstraintInequality::upperBound
const Vector & upperBound() const override
Definition: src/math/constraint-inequality.cpp:67
cols
int cols
tsid::math::ConstraintInequality::rows
unsigned int rows() const override
Definition: src/math/constraint-inequality.cpp:42
tsid::math::ConstraintInequality::m_ub
Vector m_ub
Definition: math/constraint-inequality.hpp:62


tsid
Author(s): Andrea Del Prete, Justin Carpentier
autogenerated on Thu Apr 3 2025 02:47:15