ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
vector
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
27
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>
;
38
using
Primal
=
InactiveSet_PrimalVector<Real>
;
39
using
Dual
=
InactiveSet_DualVector<Real>
;
40
using
Bnd
=
BoundConstraint<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
55
virtual
~InactiveSet_PrimalVector
() {}
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>
;
102
using
Primal
=
InactiveSet_PrimalVector<Real>
;
103
using
Dual
=
InactiveSet_DualVector<Real>
;
104
using
Bnd
=
BoundConstraint<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
119
virtual
~InactiveSet_PrimalVector
() {}
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
ROL_BoundConstraint.hpp
ROL_ScaledVector.hpp
ROL::BoundConstraint
Provides the interface to apply upper and lower bound constraints.
Definition
ROL_BoundConstraint.hpp:39
ROL::DualScaledVector::scaling_vec_
Ptv< V > scaling_vec_
Definition
ROL_ScaledVector.hpp:107
ROL::DualScaledVector::divide_scaling
void divide_scaling(const < V > &y) const
Definition
ROL_ScaledVector.hpp:117
ROL::DualScaledVector::DualScaledVector
DualScaledVector(const Ptr< V > &vec, const Ptr< V > &scaling_vec)
Definition
ROL_ScaledVector.hpp:123
ROL::DualScaledVector::getWorkspace
VectorWorkspace< Real > & getWorkspace() const
Definition
ROL_ScaledVector.hpp:114
ROL::DualScaledVector::getScalingVector
const Ptr< V > & getScalingVector()
Definition
ROL_ScaledVector.hpp:148
ROL::InactiveSet_DualVector
Defines the a Vector which has a diagonally scaled dot product that neglects active set elements Used...
Definition
ROL_InactiveSetVector.hpp:99
ROL::InactiveSet_DualVector::bnd_
Ptr< Bnd > bnd_
Definition
ROL_InactiveSetVector.hpp:109
ROL::InactiveSet_DualVector::dual
void const V & dual() const override
Definition
ROL_InactiveSetVector.hpp:145
ROL::InactiveSet_DualVector::basis
Ptr< V > basis(const int i) const override
Definition
ROL_InactiveSetVector.hpp:139
ROL::InactiveSet_DualVector::x_
Ptr< V > x_
Definition
ROL_InactiveSetVector.hpp:108
ROL::InactiveSet_DualVector::V
Vector< Real > V
Definition
ROL_InactiveSetVector.hpp:101
ROL::InactiveSet_DualVector::getIterateVector
const Ptr< const V > & getIterateVector() const
Definition
ROL_InactiveSetVector.hpp:154
ROL::InactiveSet_DualVector::Primal
InactiveSet_PrimalVector< Real > Primal
Definition
ROL_InactiveSetVector.hpp:102
ROL::InactiveSet_DualVector::Bnd
BoundConstraint< Real > Bnd
Definition
ROL_InactiveSetVector.hpp:104
ROL::InactiveSet_DualVector::clone
Ptr< V > clone() const override
Definition
ROL_InactiveSetVector.hpp:133
ROL::InactiveSet_DualVector::dot
Real dot(const V &x) const override
Definition
ROL_InactiveSetVector.hpp:121
ROL::InactiveSet_DualVector::getIterateVector
const Ptr< V > & getIterateVector()
Definition
ROL_InactiveSetVector.hpp:153
ROL::InactiveSet_DualVector::Dual
InactiveSet_DualVector< Real > Dual
Definition
ROL_InactiveSetVector.hpp:103
ROL::InactiveSet_DualVector::~InactiveSet_PrimalVector
virtual ~InactiveSet_PrimalVector()
Definition
ROL_InactiveSetVector.hpp:119
ROL::InactiveSet_DualVector::setIterateVector
void setIterateVector(const Ptr< V > &x) const
Definition
ROL_InactiveSetVector.hpp:152
ROL::InactiveSet_DualVector::InactiveSet_DualVector
InactiveSet_DualVector(const Ptr< V > &vec, const Ptr< V > &scaling_vec, const Ptr< V > &x, const Ptr< Bnd > &bnd)
Definition
ROL_InactiveSetVector.hpp:113
ROL::InactiveSet_PrimalVector
Defines the a Vector which has a diagonally scaled dot product that neglects active set elements Used...
Definition
ROL_InactiveSetVector.hpp:35
ROL::InactiveSet_PrimalVector::bnd_
Ptr< Bnd > bnd_
Definition
ROL_InactiveSetVector.hpp:45
ROL::InactiveSet_PrimalVector::~InactiveSet_PrimalVector
virtual ~InactiveSet_PrimalVector()
Definition
ROL_InactiveSetVector.hpp:55
ROL::InactiveSet_PrimalVector::Dual
InactiveSet_DualVector< Real > Dual
Definition
ROL_InactiveSetVector.hpp:39
ROL::InactiveSet_PrimalVector::V
Vector< Real > V
Definition
ROL_InactiveSetVector.hpp:37
ROL::InactiveSet_PrimalVector::x_
Ptr< V > x_
Definition
ROL_InactiveSetVector.hpp:44
ROL::InactiveSet_PrimalVector::getIterateVector
const Ptr< const V > & getIterateVector() const
Definition
ROL_InactiveSetVector.hpp:92
ROL::InactiveSet_PrimalVector::dot
Real dot(const V &x) const override
Definition
ROL_InactiveSetVector.hpp:58
ROL::InactiveSet_PrimalVector::getIterateVector
const Ptr< V > & getIterateVector()
Definition
ROL_InactiveSetVector.hpp:91
ROL::InactiveSet_PrimalVector::Primal
InactiveSet_PrimalVector< Real > Primal
Definition
ROL_InactiveSetVector.hpp:38
ROL::InactiveSet_PrimalVector::clone
Ptr< V > clone() const override
Definition
ROL_InactiveSetVector.hpp:71
ROL::InactiveSet_PrimalVector::basis
Ptr< V > basis(const int i) const override
Definition
ROL_InactiveSetVector.hpp:77
ROL::InactiveSet_PrimalVector::InactiveSet_PrimalVector
InactiveSet_PrimalVector(const Ptr< V > &vec, const Ptr< V > &scaling_vec, const Ptr< V > &x, const Ptr< Bnd > &bnd)
Definition
ROL_InactiveSetVector.hpp:49
ROL::InactiveSet_PrimalVector::Bnd
BoundConstraint< Real > Bnd
Definition
ROL_InactiveSetVector.hpp:40
ROL::InactiveSet_PrimalVector::dual
void const V & dual() const override
Definition
ROL_InactiveSetVector.hpp:83
ROL::InactiveSet_PrimalVector::setIterateVector
void setIterateVector(const Ptr< V > &x) const
Definition
ROL_InactiveSetVector.hpp:90
ROL::PrimalScaledVector
Provides the implementation of the ROL::Vector interface that handles scalings in the inner product....
Definition
ROL_WrappedVector.hpp:32
ROL::PrimalScaledVector::scaling_vec_
Ptv< V > scaling_vec_
Definition
ROL_ScaledVector.hpp:46
ROL::PrimalScaledVector::getVector
const Ptr< V > & getVector()
Definition
ROL_WrappedVector.hpp:97
ROL::PrimalScaledVector::getWorkspace
VectorWorkspace< Real > & getWorkspace() const
Definition
ROL_ScaledVector.hpp:53
ROL::PrimalScaledVector::getScalingVector
const Ptr< V > & getScalingVector()
Definition
ROL_ScaledVector.hpp:87
ROL::PrimalScaledVector::multiply_scaling
void multiply_scaling(const Ptr< V > &y) const
Definition
ROL_ScaledVector.hpp:56
ROL::PrimalScaledVector::PrimalScaledVector
PrimalScaledVector(const Ptr< V > &vec, const Ptr< V > &scaling_vec)
Definition
ROL_ScaledVector.hpp:62
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0