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"
49
62namespace ROL {
63
64template<typename Real> class InactiveSet_PrimalVector;
65template<typename Real> class InactiveSet_DualVector;
66
67
68template<typename Real>
70
71 using V = Vector<Real>;
75
76private:
77
78 mutable Ptr<V> x_; // Current optimization iterate
79 Ptr<Bnd> bnd_;
80
81public:
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
132template<typename Real>
134
139
140private:
141
142 mutable Ptr<V> x_; // Current optimization iterate
143 Ptr<Bnd> bnd_;
144
145public:
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
Provides the interface to apply upper and lower bound constraints.
Provides the implementation of the ROL::Vector interface that handles scalings in the inner product....
void divide_scaling(const < V > &y) const
VectorWorkspace< Real > & getWorkspace() const
const Ptr< V > & getScalingVector()
Defines the a Vector which has a diagonally scaled dot product that neglects active set elements Used...
void const V & dual() const override
Ptr< V > basis(const int i) const override
const Ptr< const V > & getIterateVector() const
Ptr< V > clone() const override
Real dot(const V &x) const override
void setIterateVector(const Ptr< V > &x) const
InactiveSet_DualVector(const Ptr< V > &vec, const Ptr< V > &scaling_vec, const Ptr< V > &x, const Ptr< Bnd > &bnd)
Defines the a Vector which has a diagonally scaled dot product that neglects active set elements Used...
const Ptr< const V > & getIterateVector() const
Real dot(const V &x) const override
Ptr< V > basis(const int i) const override
InactiveSet_PrimalVector(const Ptr< V > &vec, const Ptr< V > &scaling_vec, const Ptr< V > &x, const Ptr< Bnd > &bnd)
void const V & dual() const override
void setIterateVector(const Ptr< V > &x) const
Provides the implementation of the ROL::Vector interface that handles scalings in the inner product....
VectorWorkspace< Real > & getWorkspace() const
const Ptr< V > & getScalingVector()
void multiply_scaling(const Ptr< V > &y) const
Defines the linear algebra or vector space interface.