ActiveSet.h
Go to the documentation of this file.
1 /* Copyright 2020 CNRS-AIST JRL */
2 
3 #pragma once
4 
5 #include <iosfwd>
6 #include <vector>
7 
8 #include <jrl-qp/api.h>
9 #include <jrl-qp/enums.h>
10 
12 {
24 {
25 public:
27  ActiveSet();
33  ActiveSet(int nCstr, int nBnd = 0);
42  ActiveSet(const std::vector<ActivationStatus> & as, int nBnd);
43 
49  void resize(int nCstr, int nBnd = 0);
50 
52  void reset();
53 
57  bool isActive(int cstrIdx) const;
61  bool isActiveBnd(int bndIdx) const;
65  ActivationStatus activationStatus(int cstrIdx) const;
69  ActivationStatus activationStatusBnd(int bndIdx) const;
73  const std::vector<ActivationStatus> & activationStatus() const;
74 
76  int operator[](int activeIdx) const
77  {
78  return activeSet_[activeIdx];
79  }
80 
89  void activate(int cstrIdx, ActivationStatus status);
95  void deactivate(int activeIdx);
96 
98  int nbCstr() const
99  {
100  return nbCstr_;
101  }
103  int nbBnd() const
104  {
105  return nbBnd_;
106  }
108  int nbAll() const
109  {
110  return nbCstr_ + nbBnd_;
111  }
112 
113  int nbActiveCstr() const
114  {
115  return me_ + mi_ + mb_;
116  }
117  int nbActiveEquality() const
118  {
119  return me_;
120  }
121  int nbActiveInequality() const
122  {
123  return mi_;
124  }
126  {
127  return ml_;
128  }
130  {
131  return mu_;
132  }
133  int nbActiveBound() const
134  {
135  return mb_;
136  }
137  int nbActiveLowerBound() const
138  {
139  return mbl_;
140  }
141  int nbActiveUpperBound() const
142  {
143  return mbu_;
144  }
145  int nbFixedVariable() const
146  {
147  return mbe_;
148  }
149 
150 private:
152  std::vector<ActivationStatus> status_;
157  std::vector<int> activeSet_;
158 
159  int nbCstr_; // number of constraints
160  int nbBnd_; // number of bounds
161  int me_; // number of constraints active as equality
162  int mi_; // number of constraints active as general inequality
163  int ml_; // number of inequality constraints active as their lower bound
164  int mu_; // number of inequality constraints active as their upper bound
165  int mb_; // number of constraints active as bound
166  int mbl_; // number of bound constraints active as their lower bound
167  int mbu_; // number of bound constraints active as their upper bound
168  int mbe_; // number of fixed variable
169 };
170 
172 std::ostream & operator<<(std::ostream & os, const ActiveSet & a);
173 } // namespace jrl::qp::internal
jrl::qp::internal::ActiveSet::nbActiveBound
int nbActiveBound() const
Definition: ActiveSet.h:133
jrl::qp::internal::ActiveSet::nbActiveEquality
int nbActiveEquality() const
Definition: ActiveSet.h:117
jrl::qp::internal::ActiveSet::nbActiveCstr
int nbActiveCstr() const
Definition: ActiveSet.h:113
jrl::qp::internal::ActiveSet::nbBnd
int nbBnd() const
Definition: ActiveSet.h:103
jrl::qp::internal::ActiveSet::nbCstr
int nbCstr() const
Definition: ActiveSet.h:98
jrl::qp::internal::ActiveSet::nbActiveUpperBound
int nbActiveUpperBound() const
Definition: ActiveSet.h:141
jrl::qp::internal::ActiveSet::nbActiveInequality
int nbActiveInequality() const
Definition: ActiveSet.h:121
jrl::qp::internal
Definition: ActiveSet.h:11
jrl::qp::ActivationStatus
ActivationStatus
Definition: enums.h:14
jrl::qp::internal::ActiveSet::nbActiveUpperInequality
int nbActiveUpperInequality() const
Definition: ActiveSet.h:129
jrl::qp::internal::ActiveSet::nbAll
int nbAll() const
Definition: ActiveSet.h:108
jrl::qp::internal::operator<<
std::ostream & operator<<(std::ostream &os, const ActiveSet &a)
Definition: ActiveSet.cpp:170
JRLQP_DLLAPI
#define JRLQP_DLLAPI
Definition: api.h:35
jrl::qp::internal::ActiveSet::nbActiveLowerBound
int nbActiveLowerBound() const
Definition: ActiveSet.h:137
enums.h
jrl::qp::internal::ActiveSet::operator[]
int operator[](int activeIdx) const
Definition: ActiveSet.h:76
jrl::qp::internal::ActiveSet::nbFixedVariable
int nbFixedVariable() const
Definition: ActiveSet.h:145
jrl::qp::internal::ActiveSet::nbActiveLowerInequality
int nbActiveLowerInequality() const
Definition: ActiveSet.h:125
jrl::qp::internal::ActiveSet
Definition: ActiveSet.h:23
api.h