Loading...
Searching...
No Matches
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
28using namespace std;
29namespace 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
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__
Definition: container.hpp:37
void print()
Definition: container.hpp:42
~ConstraintLevels()
Definition: container.hpp:40
ConstraintLevel & get()
Definition: container.hpp:58
ConstraintLevels()
Definition: container.hpp:39
void append_bound(double num, std::shared_ptr< math::ConstraintBound > i)
Definition: container.hpp:68
void append_eq(double num, std::shared_ptr< math::ConstraintEquality > i)
Definition: container.hpp:62
void append_ineq(double num, std::shared_ptr< math::ConstraintInequality > i)
Definition: container.hpp:65
Definition: container.hpp:76
HQPData get()
Definition: container.hpp:114
void append_helper(ConstraintLevels *cons)
Definition: container.hpp:110
HQPDatas()
Definition: container.hpp:78
~HQPDatas()
Definition: container.hpp:79
void print() const
Definition: container.hpp:85
bool set(HQPData data)
Definition: container.hpp:117
void resize(size_t i)
Definition: container.hpp:81
solvers::HQPData HQPData
Definition: container.hpp:34
solvers::ConstraintLevel ConstraintLevel
Definition: container.hpp:33
pinocchio::container::aligned_vector< ConstraintLevel > HQPData
Definition: fwd.hpp:91
aligned_pair< T1, T2 > make_pair(const T1 &t1, const T2 &t2)
Definition: fwd.hpp:85
pinocchio::container::aligned_vector< aligned_pair< double, std::shared_ptr< math::ConstraintBase > > > ConstraintLevel
Definition: fwd.hpp:89
Definition: constraint-bound.hpp:27