container.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018 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 
18 #ifndef __tsid_python_util_container_hpp__
19 #define __tsid_python_util_container_hpp__
20 
22 
23 #include "tsid/solvers/fwd.hpp"
27 
28 using namespace std;
29 namespace tsid
30 {
31  namespace python
32  {
35 
37  {
38  public:
41 
42  inline void print (){
43  stringstream ss;
44  for(ConstraintLevel::const_iterator iit=m_std_const.begin(); iit!=m_std_const.end(); iit++)
45  {
46  auto c = iit->second;
47  ss<<" - "<<c->name()<<": w="<<iit->first<<", ";
48  if(c->isEquality())
49  ss<<"equality, ";
50  else if(c->isInequality())
51  ss<<"inequality, ";
52  else
53  ss<<"bound, ";
54  ss<<c->rows()<<"x"<<c->cols()<<endl;
55  }
56  cout << ss.str() << endl;
57  }
58  inline ConstraintLevel& get (){
59  return m_std_const;
60  }
61 
62  inline void append_eq (double num, std::shared_ptr<math::ConstraintEquality> i){
63  m_std_const.push_back(solvers::make_pair<double, std::shared_ptr<math::ConstraintBase> >(num, i));
64  }
65  inline void append_ineq (double num, std::shared_ptr<math::ConstraintInequality> i){
66  m_std_const.push_back(solvers::make_pair<double, std::shared_ptr<math::ConstraintBase> >(num, i));
67  }
68  inline void append_bound (double num, std::shared_ptr<math::ConstraintBound> i){
69  m_std_const.push_back(solvers::make_pair<double, std::shared_ptr<math::ConstraintBase> >(num, i));
70  }
71  private:
72  ConstraintLevel m_std_const;
73  };
74 
75  class HQPDatas
76  {
77  public:
80 
81  inline void resize (size_t i) {
82  m_std_hqp.resize(i);
83  }
84 
85  inline void print () const {
86  stringstream ss;
87  unsigned int priority = 0;
88  for(HQPData::const_iterator it=m_std_hqp.begin(); it!=m_std_hqp.end(); it++)
89  {
90  ss<<"Level "<< priority<<endl;
91  for(ConstraintLevel::const_iterator iit=it->begin(); iit!=it->end(); iit++)
92  {
93  auto c = iit->second;
94  ss<<" - "<<c->name()<<": w="<<iit->first<<", ";
95  if(c->isEquality())
96  ss<<"equality, ";
97  else if(c->isInequality())
98  ss<<"inequality, ";
99  else
100  ss<<"bound, ";
101  ss<<c->rows()<<"x"<<c->cols()<<endl;
102  }
103  priority++;
104  }
105  cout << ss.str() << endl;
106  }
107  // inline void append (ConstraintLevel cons){
108  // m_std_hqp.push_back(cons);
109  // }
110  inline void append_helper (ConstraintLevels* cons){
111  m_std_hqp.push_back(cons->get());
112  }
113 
114  inline HQPData get (){
115  return m_std_hqp;
116  }
117  inline bool set (HQPData data){
118  m_std_hqp = data;
119  return true;
120  }
121 
122  private:
123  HQPData m_std_hqp;
124  };
125  }
126 }
127 
128 
129 #endif // ifndef __tsid_python_util_container_hpp__
tsid::solvers::make_pair
aligned_pair< T1, T2 > make_pair(const T1 &t1, const T2 &t2)
Definition: fwd.hpp:85
tsid::python::ConstraintLevels::append_eq
void append_eq(double num, std::shared_ptr< math::ConstraintEquality > i)
Definition: container.hpp:62
tsid::python::HQPDatas::set
bool set(HQPData data)
Definition: container.hpp:117
tsid::solvers::ConstraintLevel
pinocchio::container::aligned_vector< aligned_pair< double, std::shared_ptr< math::ConstraintBase > > > ConstraintLevel
Definition: fwd.hpp:89
constraint-equality.hpp
tsid::python::HQPDatas::get
HQPData get()
Definition: container.hpp:114
tsid::python::ConstraintLevels
Definition: container.hpp:36
tsid::python::HQPDatas::HQPDatas
HQPDatas()
Definition: container.hpp:78
tsid::python::ConstraintLevels::ConstraintLevels
ConstraintLevels()
Definition: container.hpp:39
tsid::python::ConstraintLevel
solvers::ConstraintLevel ConstraintLevel
Definition: container.hpp:33
constraint-inequality.hpp
tsid::python::HQPDatas
Definition: container.hpp:75
tsid
Definition: constraint-bound.hpp:26
tsid::python::HQPDatas::~HQPDatas
~HQPDatas()
Definition: container.hpp:79
tsid::python::ConstraintLevels::append_ineq
void append_ineq(double num, std::shared_ptr< math::ConstraintInequality > i)
Definition: container.hpp:65
tsid::python::ConstraintLevels::append_bound
void append_bound(double num, std::shared_ptr< math::ConstraintBound > i)
Definition: container.hpp:68
constraint-bound.hpp
tsid::python::ConstraintLevels::~ConstraintLevels
~ConstraintLevels()
Definition: container.hpp:40
tsid::python::HQPDatas::resize
void resize(size_t i)
Definition: container.hpp:81
fwd.hpp
tsid::python::ConstraintLevels::print
void print()
Definition: container.hpp:42
tsid::python::HQPDatas::print
void print() const
Definition: container.hpp:85
tsid::solvers::HQPData
pinocchio::container::aligned_vector< ConstraintLevel > HQPData
Definition: fwd.hpp:91
tsid::python::HQPDatas::append_helper
void append_helper(ConstraintLevels *cons)
Definition: container.hpp:110
tsid::python::ConstraintLevels::get
ConstraintLevel & get()
Definition: container.hpp:58
tsid::python::HQPData
solvers::HQPData HQPData
Definition: container.hpp:34
fwd.hpp