ROL
ROL_InactiveSetVector.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 #ifndef ROL_INACTIVE_SET_VECTOR_HPP
45 #define ROL_INACTIVE_SET_VECTOR_HPP
46 
47 #include "ROL_ScaledVector.hpp"
48 #include "ROL_BoundConstraint.hpp"
49 
62 namespace ROL {
63 
64 template<typename Real> class InactiveSet_PrimalVector;
65 template<typename Real> class InactiveSet_DualVector;
66 
67 
68 template<typename Real>
69 class InactiveSet_PrimalVector : public PrimalScaledVector<Real> {
70 
71  using V = Vector<Real>;
75 
76 private:
77 
78  mutable Ptr<V> x_; // Current optimization iterate
79  Ptr<Bnd> bnd_;
80 
81 public:
82 
83  InactiveSet_PrimalVector( const Ptr<V>& vec,
84  const Ptr<V>& scaling_vec,
85  const Ptr<V>& x,
86  const Ptr<Bnd>& bnd ) :
87  PrimalScaledVector<Real>(vec,scaling_vec_), x_(x), bnd_(bnd) {}
88 
90 
91 
92  Real dot( const V& x ) const override {
93 
94  auto& w = this->getWorkspace();
95  auto y = w.copy(x);
96 
97  this->multiply_scaling( *y );
98 
99  // Set elements of y corresponsing the the active set of X to zero
100  bnd_->pruneActive( *y, *x_ );
101 
102  return y->dot( *this->getVector() );
103  }
104 
105  Ptr<V> clone() const override {
106  return makePtr<Primal>( this->getVector()->clone(),
107  this->getScalingVector(),
108  x_, bnd_ );
109  }
110 
111  Ptr<V> basis( const int i ) const override {
112  return makePtr<Primal>( this->getVector()->basis(i),
113  this->getScalingVector(),
114  x_, bnd_ );
115  }
116 
117  void const V& dual() const override {
118  auto& w = this->getWorkspace();
119  auto dual_vec = w.copy( this->getVector() );
120  this->multiply_scaling( dual_vec );
121  return makePtr<Dual>( dual_vec, this->getScalingVector(), x_, bnd_ );
122  }
123 
124  void setIterateVector( const Ptr<V>& x ) const { x_->set(x); }
125  const Ptr<V>& getIterateVector() { return x_; }
126  const Ptr<const V>& getIterateVector() const { return x_; }
127 
128 
129 }; // class InactiveSet_PrimalVector
130 
131 
132 template<typename Real>
133 class InactiveSet_DualVector : public DualScaledVector<Real> {
134 
135  using V = Vector<Real>;
139 
140 private:
141 
142  mutable Ptr<V> x_; // Current optimization iterate
143  Ptr<Bnd> bnd_;
144 
145 public:
146 
147  InactiveSet_DualVector( const Ptr<V>& vec,
148  const Ptr<V>& scaling_vec,
149  const Ptr<V>& x,
150  const Ptr<Bnd>& bnd ) :
151  PrimalScaledVector<Real>(vec,scaling_vec_), x_(x), bnd_(bnd) {}
152 
154 
155  Real dot( const V& x ) const override {
156 
157  auto& w = this->getWorkspace();
158  auto y = w.copy(x);
159  this->divide_scaling( *y, this->getScalingVector() );
160 
161  // Set elements of y corresponsing the the active set of X to zero
162  bnd_->pruneActive( *y, *x_ );
163 
164  return y->dot( *this->getVector() );
165  }
166 
167  Ptr<V> clone() const override {
168  return makePtr<Primal>( this->getVector()->clone(),
169  this->getScalingVector(),
170  x_, bnd_ );
171  }
172 
173  Ptr<V> basis( const int i ) const override {
174  return makePtr<Primal>( this->getVector()->basis(i),
175  this->getScalingVector(),
176  x_, bnd_ );
177  }
178 
179  void const V& dual() const override {
180  auto& w = this->getWorkspace();
181  auto dual_vec = w.copy( this->getVector() );
182  this->multiply( dual_vec );
183  return *( makePtr<Dual>( dual_vec, this->getScalingVector(), x_, bnd_ ) );
184  }
185 
186  void setIterateVector( const Ptr<V>& x ) const { x_->set(x); }
187  const Ptr<V>& getIterateVector() { return x_; }
188  const Ptr<const V>& getIterateVector() const { return x_; }
189 
190 }; // class InactiveSet_PrimalVector
191 
192 
193 
194 
195 
196 } // namespace ROL
197 
198 
199 
200 #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:80
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
void setIterateVector(const Ptr< V > &x) const