ROL
ROL_InactiveSetVector.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_INACTIVE_SET_VECTOR_HPP
11 #define ROL_INACTIVE_SET_VECTOR_HPP
12 
13 #include "ROL_ScaledVector.hpp"
14 #include "ROL_BoundConstraint.hpp"
15 
28 namespace ROL {
29 
30 template<typename Real> class InactiveSet_PrimalVector;
31 template<typename Real> class InactiveSet_DualVector;
32 
33 
34 template<typename Real>
35 class InactiveSet_PrimalVector : public PrimalScaledVector<Real> {
36 
37  using V = Vector<Real>;
41 
42 private:
43 
44  mutable Ptr<V> x_; // Current optimization iterate
45  Ptr<Bnd> bnd_;
46 
47 public:
48 
49  InactiveSet_PrimalVector( const Ptr<V>& vec,
50  const Ptr<V>& scaling_vec,
51  const Ptr<V>& x,
52  const Ptr<Bnd>& bnd ) :
53  PrimalScaledVector<Real>(vec,scaling_vec_), x_(x), bnd_(bnd) {}
54 
56 
57 
58  Real dot( const V& x ) const override {
59 
60  auto& w = this->getWorkspace();
61  auto y = w.copy(x);
62 
63  this->multiply_scaling( *y );
64 
65  // Set elements of y corresponsing the the active set of X to zero
66  bnd_->pruneActive( *y, *x_ );
67 
68  return y->dot( *this->getVector() );
69  }
70 
71  Ptr<V> clone() const override {
72  return makePtr<Primal>( this->getVector()->clone(),
73  this->getScalingVector(),
74  x_, bnd_ );
75  }
76 
77  Ptr<V> basis( const int i ) const override {
78  return makePtr<Primal>( this->getVector()->basis(i),
79  this->getScalingVector(),
80  x_, bnd_ );
81  }
82 
83  void const V& dual() const override {
84  auto& w = this->getWorkspace();
85  auto dual_vec = w.copy( this->getVector() );
86  this->multiply_scaling( dual_vec );
87  return makePtr<Dual>( dual_vec, this->getScalingVector(), x_, bnd_ );
88  }
89 
90  void setIterateVector( const Ptr<V>& x ) const { x_->set(x); }
91  const Ptr<V>& getIterateVector() { return x_; }
92  const Ptr<const V>& getIterateVector() const { return x_; }
93 
94 
95 }; // class InactiveSet_PrimalVector
96 
97 
98 template<typename Real>
99 class InactiveSet_DualVector : public DualScaledVector<Real> {
100 
101  using V = Vector<Real>;
105 
106 private:
107 
108  mutable Ptr<V> x_; // Current optimization iterate
109  Ptr<Bnd> bnd_;
110 
111 public:
112 
113  InactiveSet_DualVector( const Ptr<V>& vec,
114  const Ptr<V>& scaling_vec,
115  const Ptr<V>& x,
116  const Ptr<Bnd>& bnd ) :
117  PrimalScaledVector<Real>(vec,scaling_vec_), x_(x), bnd_(bnd) {}
118 
120 
121  Real dot( const V& x ) const override {
122 
123  auto& w = this->getWorkspace();
124  auto y = w.copy(x);
125  this->divide_scaling( *y, this->getScalingVector() );
126 
127  // Set elements of y corresponsing the the active set of X to zero
128  bnd_->pruneActive( *y, *x_ );
129 
130  return y->dot( *this->getVector() );
131  }
132 
133  Ptr<V> clone() const override {
134  return makePtr<Primal>( this->getVector()->clone(),
135  this->getScalingVector(),
136  x_, bnd_ );
137  }
138 
139  Ptr<V> basis( const int i ) const override {
140  return makePtr<Primal>( this->getVector()->basis(i),
141  this->getScalingVector(),
142  x_, bnd_ );
143  }
144 
145  void const V& dual() const override {
146  auto& w = this->getWorkspace();
147  auto dual_vec = w.copy( this->getVector() );
148  this->multiply( dual_vec );
149  return *( makePtr<Dual>( dual_vec, this->getScalingVector(), x_, bnd_ ) );
150  }
151 
152  void setIterateVector( const Ptr<V>& x ) const { x_->set(x); }
153  const Ptr<V>& getIterateVector() { return x_; }
154  const Ptr<const V>& getIterateVector() const { return x_; }
155 
156 }; // class InactiveSet_PrimalVector
157 
158 
159 
160 
161 
162 } // namespace ROL
163 
164 
165 
166 #endif // ROL_INACTIVE_SET_VECTOR_HPP
const Ptr< V > & getScalingVector()
VectorWorkspace< Real > & getWorkspace() const
void const V & dual() const override
void multiply_scaling(const Ptr< V > &y) const
Defines the a Vector which has a diagonally scaled dot product that neglects active set elements Used...
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
const Ptr< V > & getVector()
const Ptr< const V > & getIterateVector() const
Provides the implementation of the ROL::Vector interface that handles scalings in the inner product...
Defines the a Vector which has a diagonally scaled dot product that neglects active set elements Used...
void const V & dual() const override
InactiveSet_DualVector(const Ptr< V > &vec, const Ptr< V > &scaling_vec, const Ptr< V > &x, const Ptr< Bnd > &bnd)
Ptr< V > basis(const int i) const override
VectorWorkspace< Real > & getWorkspace() const
Ptr< V > basis(const int i) const override
Real dot(const V &x) const override
const Ptr< V > & getScalingVector()
Provides the interface to apply upper and lower bound constraints.
Ptr< V > clone() const override
void divide_scaling(const < V > &y) const
const Ptr< const V > & getIterateVector() const
InactiveSet_PrimalVector(const Ptr< V > &vec, const Ptr< V > &scaling_vec, const Ptr< V > &x, const Ptr< Bnd > &bnd)
Real dot(const V &x) const override
void setIterateVector(const Ptr< V > &x) const
Ptr< V > clone() const override
void setIterateVector(const Ptr< V > &x) const