ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
algorithm
TypeB
ROL_TypeB_Algorithm.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_TYPEB_ALGORITHM_H
11
#define ROL_TYPEB_ALGORITHM_H
12
13
#include "
ROL_CombinedStatusTest.hpp
"
14
#include "
ROL_Objective.hpp
"
15
#include "
ROL_Constraint.hpp
"
16
#include "
ROL_BoundConstraint.hpp
"
17
#include "
ROL_PolyhedralProjectionFactory.hpp
"
18
#include "ROL_Problem.hpp"
19
23
24
namespace
ROL
{
25
namespace
TypeB
{
26
27
template
<
typename
Real>
28
struct
AlgorithmState
:
public
ROL::AlgorithmState
<Real> {
29
Real
searchSize
;
30
Ptr<Vector<Real>>
stepVec
;
31
Ptr<Vector<Real>>
gradientVec
;
32
int
nproj
;
33
34
AlgorithmState
()
35
:
searchSize
(1),
36
stepVec
(nullPtr),
37
gradientVec
(nullPtr),
38
nproj
(0) {}
39
40
void
reset
() {
41
ROL::AlgorithmState<Real>::reset
();
42
searchSize
=
static_cast<
Real
>
(1);
43
if
(
stepVec
!= nullPtr)
stepVec
->zero();
44
if
(
gradientVec
!= nullPtr)
gradientVec
->zero();
45
nproj
= 0;
46
}
47
};
48
49
template
<
typename
Real>
50
class
Algorithm
{
51
protected
:
52
const
Ptr<CombinedStatusTest<Real>>
status_
;
53
const
Ptr<AlgorithmState<Real>>
state_
;
54
Ptr<PolyhedralProjection<Real>>
proj_
;
55
56
void
initialize
(
const
Vector<Real>
&x,
const
Vector<Real>
&g);
57
58
Real
optimalityCriterion
(
const
Vector<Real>
&x,
const
Vector<Real>
&g,
Vector<Real>
&primal,
59
std::ostream &outStream = std::cout)
const
;
60
61
public
:
62
63
virtual
~Algorithm
() {}
64
67
Algorithm
();
68
69
void
setStatusTest
(
const
Ptr<
StatusTest<Real>
> &status,
70
const
bool
combineStatus =
false
);
71
75
virtual
void
run
(
Problem<Real>
&problem,
76
std::ostream &outStream = std::cout );
77
81
virtual
void
run
(
Vector<Real>
&x,
82
Objective<Real>
&obj,
83
BoundConstraint<Real>
&bnd,
84
std::ostream &outStream = std::cout );
85
90
virtual
void
run
(
Vector<Real>
&x,
91
const
Vector<Real>
&g,
92
Objective<Real>
&obj,
93
BoundConstraint<Real>
&bnd,
94
std::ostream &outStream = std::cout) = 0;
95
101
virtual
void
run
(
Vector<Real>
&x,
102
Objective<Real>
&obj,
103
BoundConstraint<Real>
&bnd,
104
Constraint<Real>
&linear_econ,
105
Vector<Real>
&linear_emul,
106
std::ostream &outStream = std::cout );
107
113
virtual
void
run
(
Vector<Real>
&x,
114
const
Vector<Real>
&g,
115
Objective<Real>
&obj,
116
BoundConstraint<Real>
&bnd,
117
Constraint<Real>
&linear_econ,
118
Vector<Real>
&linear_emul,
119
const
Vector<Real>
&linear_eres,
120
std::ostream &outStream = std::cout );
121
127
virtual
void
run
(
Vector<Real>
&x,
128
Objective<Real>
&obj,
129
BoundConstraint<Real>
&bnd,
130
Constraint<Real>
&linear_icon,
131
Vector<Real>
&linear_imul,
132
BoundConstraint<Real>
&linear_ibnd,
133
std::ostream &outStream = std::cout );
134
140
virtual
void
run
(
Vector<Real>
&x,
141
const
Vector<Real>
&g,
142
Objective<Real>
&obj,
143
BoundConstraint<Real>
&bnd,
144
Constraint<Real>
&linear_icon,
145
Vector<Real>
&linear_imul,
146
BoundConstraint<Real>
&linear_ibnd,
147
const
Vector<Real>
&linear_ires,
148
std::ostream &outStream = std::cout );
149
155
virtual
void
run
(
Vector<Real>
&x,
156
Objective<Real>
&obj,
157
BoundConstraint<Real>
&bnd,
158
Constraint<Real>
&linear_econ,
159
Vector<Real>
&linear_emul,
160
Constraint<Real>
&linear_icon,
161
Vector<Real>
&linear_imul,
162
BoundConstraint<Real>
&linear_ibnd,
163
std::ostream &outStream = std::cout );
164
170
virtual
void
run
(
Vector<Real>
&x,
171
const
Vector<Real>
&g,
172
Objective<Real>
&obj,
173
BoundConstraint<Real>
&bnd,
174
Constraint<Real>
&linear_econ,
175
Vector<Real>
&linear_emul,
176
const
Vector<Real>
&linear_eres,
177
Constraint<Real>
&linear_icon,
178
Vector<Real>
&linear_imul,
179
BoundConstraint<Real>
&linear_ibnd,
180
const
Vector<Real>
&linear_ires,
181
std::ostream &outStream = std::cout );
182
185
virtual
void
writeHeader
( std::ostream& os )
const
;
186
189
virtual
void
writeName
( std::ostream& os )
const
;
190
193
virtual
void
writeOutput
( std::ostream& os,
const
bool
write_header =
false
)
const
;
194
195
virtual
void
writeExitStatus
( std::ostream& os )
const
;
196
197
//Ptr<const AlgorithmState<Real>>& getState() const;
198
Ptr<const AlgorithmState<Real>>
getState
()
const
;
199
200
void
reset
();
201
202
};
// class ROL::Type::Algorithm
203
204
}
// namespace TypeB
205
}
// namespace ROL
206
207
#include "
ROL_TypeB_Algorithm_Def.hpp
"
208
209
#endif
ROL_BoundConstraint.hpp
ROL_CombinedStatusTest.hpp
ROL_Constraint.hpp
ROL_Objective.hpp
ROL_PolyhedralProjectionFactory.hpp
ROL_TypeB_Algorithm_Def.hpp
ROL::BoundConstraint
Provides the interface to apply upper and lower bound constraints.
Definition
ROL_BoundConstraint.hpp:39
ROL::Constraint
Defines the general constraint operator interface.
Definition
ROL_Constraint.hpp:52
ROL::Objective
Provides the interface to evaluate objective functions.
Definition
ROL_Objective.hpp:44
ROL::Problem
Definition
function/prox/ROL_Problem.hpp:27
ROL::StatusTest
Provides an interface to check status of optimization algorithms.
Definition
ROL_StatusTest.hpp:24
ROL::TypeB::Algorithm::run
virtual void run(Problem< Real > &problem, std::ostream &outStream=std::cout)
Run algorithm on bound constrained problems (Type-B). This is the primary Type-B interface.
Definition
ROL_TypeB_Algorithm_Def.hpp:73
ROL::TypeB::Algorithm::~Algorithm
virtual ~Algorithm()
Definition
ROL_TypeB_Algorithm.hpp:63
ROL::TypeB::Algorithm::reset
void reset()
Definition
ROL_TypeB_Algorithm_Def.hpp:285
ROL::TypeB::Algorithm::proj_
Ptr< PolyhedralProjection< Real > > proj_
Definition
ROL_TypeB_Algorithm.hpp:54
ROL::TypeB::Algorithm::initialize
void initialize(const Vector< Real > &x, const Vector< Real > &g)
Definition
ROL_TypeB_Algorithm_Def.hpp:29
ROL::TypeB::Algorithm::writeHeader
virtual void writeHeader(std::ostream &os) const
Print iterate header.
Definition
ROL_TypeB_Algorithm_Def.hpp:226
ROL::TypeB::Algorithm::optimalityCriterion
Real optimalityCriterion(const Vector< Real > &x, const Vector< Real > &g, Vector< Real > &primal, std::ostream &outStream=std::cout) const
Definition
ROL_TypeB_Algorithm_Def.hpp:51
ROL::TypeB::Algorithm::Algorithm
Algorithm()
Constructor, given a step and a status test.
Definition
ROL_TypeB_Algorithm_Def.hpp:20
ROL::TypeB::Algorithm::writeExitStatus
virtual void writeExitStatus(std::ostream &os) const
Definition
ROL_TypeB_Algorithm_Def.hpp:270
ROL::TypeB::Algorithm::writeName
virtual void writeName(std::ostream &os) const
Print step name.
Definition
ROL_TypeB_Algorithm_Def.hpp:240
ROL::TypeB::Algorithm::state_
const Ptr< AlgorithmState< Real > > state_
Definition
ROL_TypeB_Algorithm.hpp:53
ROL::TypeB::Algorithm::status_
const Ptr< CombinedStatusTest< Real > > status_
Definition
ROL_TypeB_Algorithm.hpp:52
ROL::TypeB::Algorithm::writeOutput
virtual void writeOutput(std::ostream &os, const bool write_header=false) const
Print iterate status.
Definition
ROL_TypeB_Algorithm_Def.hpp:245
ROL::TypeB::Algorithm::getState
Ptr< const AlgorithmState< Real > > getState() const
Definition
ROL_TypeB_Algorithm_Def.hpp:280
ROL::TypeB::Algorithm::run
virtual void run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, std::ostream &outStream=std::cout)=0
Run algorithm on bound constrained problems (Type-B). This general interface supports the use of dual...
ROL::TypeB::Algorithm::setStatusTest
void setStatusTest(const Ptr< StatusTest< Real > > &status, const bool combineStatus=false)
Definition
ROL_TypeB_Algorithm_Def.hpp:64
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL::TypeB
Definition
ROL_TypeB_Algorithm.hpp:25
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::ROL::AlgorithmState
State for algorithm class. Will be used for restarts.
Definition
ROL_Constraint_SerialSimOpt.hpp:109
ROL::ROL::AlgorithmState::reset
void reset(void)
Definition
ROL_Constraint_SerialSimOpt.hpp:140
ROL::TypeB::AlgorithmState::searchSize
Real searchSize
Definition
ROL_TypeB_Algorithm.hpp:29
ROL::TypeB::AlgorithmState::stepVec
Ptr< Vector< Real > > stepVec
Definition
ROL_TypeB_Algorithm.hpp:30
ROL::TypeB::AlgorithmState::reset
void reset()
Definition
ROL_TypeB_Algorithm.hpp:40
ROL::TypeB::AlgorithmState::AlgorithmState
AlgorithmState()
Definition
ROL_TypeB_Algorithm.hpp:34
ROL::TypeB::AlgorithmState::gradientVec
Ptr< Vector< Real > > gradientVec
Definition
ROL_TypeB_Algorithm.hpp:31
ROL::TypeB::AlgorithmState::nproj
int nproj
Definition
ROL_TypeB_Algorithm.hpp:32
Generated by
1.17.0