qpmad
Eigen-based C++ QP solver.
active_set.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4 
5  @copyright 2017 Alexander Sherikov. Licensed under the Apache License,
6  Version 2.0. (see LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
7 
8  @brief
9 */
10 
11 #pragma once
12 
13 
14 namespace qpmad
15 {
16  template<int t_primal_size>
17  class ActiveSet
18  {
19  public:
20  Eigen::Array<MatrixIndex, t_primal_size, 1> active_constraints_indices_;
24 
25 
26  public:
27  void initialize(const MatrixIndex max_size)
28  {
29  active_constraints_indices_.resize(max_size);
30  size_ = 0;
31  num_equalities_ = 0;
33  }
34 
35 
36  MatrixIndex getIndex(const MatrixIndex index) const
37  {
38  return (active_constraints_indices_[index]);
39  }
40 
41 
42  bool hasEmptySpace() const
43  {
44  return (size_ < active_constraints_indices_.size());
45  }
46 
47 
48  void addEquality(const MatrixIndex index)
49  {
51  ++size_;
53  }
54 
55 
56  void addInequality(const MatrixIndex index)
57  {
59  ++size_;
61  }
62 
63 
64  void removeInequality(const MatrixIndex index)
65  {
67  --size_;
69  }
70  };
71 } // namespace qpmad
MatrixIndex num_equalities_
Definition: active_set.h:22
void addInequality(const MatrixIndex index)
Definition: active_set.h:56
bool hasEmptySpace() const
Definition: active_set.h:42
Eigen::Array< MatrixIndex, t_primal_size, 1 > active_constraints_indices_
Definition: active_set.h:20
EIGEN_DEFAULT_DENSE_INDEX_TYPE MatrixIndex
Definition: common.h:32
void initialize(const MatrixIndex max_size)
Definition: active_set.h:27
MatrixIndex size_
Definition: active_set.h:21
void addEquality(const MatrixIndex index)
Definition: active_set.h:48
void removeInequality(const MatrixIndex index)
Definition: active_set.h:64
MatrixIndex num_inequalities_
Definition: active_set.h:23
void dropElementWithoutResize(t_VectorType &vector, const MatrixIndex index, const MatrixIndex size)
Definition: common.h:39
MatrixIndex getIndex(const MatrixIndex index) const
Definition: active_set.h:36