ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
algorithm
TypeP
ROL_TypeP_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_TYPEP_ALGORITHM_H
11
#define ROL_TYPEP_ALGORITHM_H
12
13
#include "
ROL_CombinedStatusTest.hpp
"
14
#include "
ROL_Objective.hpp
"
15
#include "ROL_Problem.hpp"
16
20
21
namespace
ROL
{
22
namespace
TypeP
{
23
24
template
<
typename
Real>
25
struct
AlgorithmState
:
public
ROL::AlgorithmState
<Real> {
26
Real
searchSize
,
svalue
,
nvalue
;
27
Ptr<Vector<Real>>
stepVec
,
gradientVec
;
28
int
nprox
,
nsval
,
nnval
;
29
30
AlgorithmState
()
31
:
searchSize
(1),
32
svalue
(
ROL_INF
<Real>()),
33
nvalue
(
ROL_INF
<Real>()),
34
stepVec
(nullPtr),
35
gradientVec
(nullPtr),
36
nprox
(0),
37
nsval
(0),
38
nnval
(0) {}
39
40
void
reset
() {
41
ROL::AlgorithmState<Real>::reset
();
42
searchSize
=
static_cast<
Real
>
(1);
43
svalue
=
ROL_INF<Real>
();
44
nvalue
=
ROL_INF<Real>
();
45
if
(
stepVec
!= nullPtr)
46
stepVec
->zero();
47
if
(
gradientVec
!= nullPtr)
48
gradientVec
->zero();
49
nprox
= 0;
50
nsval
= 0;
51
nnval
= 0;
52
}
53
};
54
55
template
<
typename
Real>
56
class
Algorithm
{
57
protected
:
58
const
Ptr<CombinedStatusTest<Real>>
status_
;
59
const
Ptr<AlgorithmState<Real>>
state_
;
60
61
void
initialize
(
const
Vector<Real>
&x,
const
Vector<Real>
&g);
62
void
pgstep
(
Vector<Real>
&pgiter,
// pgiter = Prox(x - t dg)
63
Vector<Real>
&
pgstep
,
// pgstep = pgiter - x
64
Objective<Real>
&nobj,
// nobj = nonsmooth objective
65
const
Vector<Real>
&x,
// x = current iterate
66
const
Vector<Real>
&dg,
// dg = dual of current gradient
67
Real t,
// t = prox parameter
68
Real &tol)
const
;
69
70
public
:
71
72
virtual
~Algorithm
() {}
73
76
Algorithm
();
77
78
void
setStatusTest
(
const
Ptr<
StatusTest<Real>
> &status,
79
bool
combineStatus =
false
);
80
84
virtual
void
run
(
Problem<Real>
&problem,
85
std::ostream &outStream = std::cout );
86
90
virtual
void
run
(
Vector<Real>
&x,
91
Objective<Real>
&sobj,
92
Objective<Real>
&nobj,
93
std::ostream &outStream = std::cout );
94
99
virtual
void
run
(
Vector<Real>
&x,
100
const
Vector<Real>
&g,
101
Objective<Real>
&sobj,
102
Objective<Real>
&nobj,
103
std::ostream &outStream = std::cout) = 0;
104
107
virtual
void
writeHeader
( std::ostream& os )
const
;
108
111
virtual
void
writeName
( std::ostream& os )
const
;
112
115
virtual
void
writeOutput
( std::ostream& os,
bool
write_header =
false
)
const
;
116
117
virtual
void
writeExitStatus
( std::ostream& os )
const
;
118
119
//Ptr<const AlgorithmState<Real>>& getState() const;
120
Ptr<const AlgorithmState<Real>>
getState
()
const
;
121
122
void
reset
();
123
124
};
// class ROL::TypeP::Algorithm
125
}
// namespace TypeP
126
}
// namespace ROL
127
128
#include "
ROL_TypeP_Algorithm_Def.hpp
"
129
130
#endif
ROL_CombinedStatusTest.hpp
ROL_Objective.hpp
ROL_TypeP_Algorithm_Def.hpp
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::TypeP::Algorithm::pgstep
void pgstep(Vector< Real > &pgiter, Vector< Real > &pgstep, Objective< Real > &nobj, const Vector< Real > &x, const Vector< Real > &dg, Real t, Real &tol) const
Definition
ROL_TypeP_Algorithm_Def.hpp:46
ROL::TypeP::Algorithm::run
virtual void run(Problem< Real > &problem, std::ostream &outStream=std::cout)
Run algorithm on unconstrained problems (Type-U). This is the primary Type-U interface.
Definition
ROL_TypeP_Algorithm_Def.hpp:70
ROL::TypeP::Algorithm::writeName
virtual void writeName(std::ostream &os) const
Print step name.
Definition
ROL_TypeP_Algorithm_Def.hpp:109
ROL::TypeP::Algorithm::getState
Ptr< const AlgorithmState< Real > > getState() const
Definition
ROL_TypeP_Algorithm_Def.hpp:149
ROL::TypeP::Algorithm::state_
const Ptr< AlgorithmState< Real > > state_
Definition
ROL_TypeP_Algorithm.hpp:59
ROL::TypeP::Algorithm::Algorithm
Algorithm()
Constructor, given a step and a status test.
Definition
ROL_TypeP_Algorithm_Def.hpp:20
ROL::TypeP::Algorithm::writeHeader
virtual void writeHeader(std::ostream &os) const
Print iterate header.
Definition
ROL_TypeP_Algorithm_Def.hpp:94
ROL::TypeP::Algorithm::~Algorithm
virtual ~Algorithm()
Definition
ROL_TypeP_Algorithm.hpp:72
ROL::TypeP::Algorithm::writeExitStatus
virtual void writeExitStatus(std::ostream &os) const
Definition
ROL_TypeP_Algorithm_Def.hpp:140
ROL::TypeP::Algorithm::writeOutput
virtual void writeOutput(std::ostream &os, bool write_header=false) const
Print iterate status.
Definition
ROL_TypeP_Algorithm_Def.hpp:114
ROL::TypeP::Algorithm::status_
const Ptr< CombinedStatusTest< Real > > status_
Definition
ROL_TypeP_Algorithm.hpp:58
ROL::TypeP::Algorithm::setStatusTest
void setStatusTest(const Ptr< StatusTest< Real > > &status, bool combineStatus=false)
Definition
ROL_TypeP_Algorithm_Def.hpp:62
ROL::TypeP::Algorithm::reset
void reset()
Definition
ROL_TypeP_Algorithm_Def.hpp:154
ROL::TypeP::Algorithm::run
virtual void run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &sobj, Objective< Real > &nobj, std::ostream &outStream=std::cout)=0
Run algorithm on unconstrained problems (Type-U). This general interface supports the use of dual opt...
ROL::TypeP::Algorithm::initialize
void initialize(const Vector< Real > &x, const Vector< Real > &g)
Definition
ROL_TypeP_Algorithm_Def.hpp:28
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL::TypeP
Definition
ROL_TypeP_Algorithm.hpp:22
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::ROL_INF
Real ROL_INF(void)
Definition
ROL_Types.hpp:71
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::TypeP::AlgorithmState::gradientVec
Ptr< Vector< Real > > gradientVec
Definition
ROL_TypeP_Algorithm.hpp:27
ROL::TypeP::AlgorithmState::nprox
int nprox
Definition
ROL_TypeP_Algorithm.hpp:28
ROL::TypeP::AlgorithmState::nnval
int nnval
Definition
ROL_TypeP_Algorithm.hpp:28
ROL::TypeP::AlgorithmState::searchSize
Real searchSize
Definition
ROL_TypeP_Algorithm.hpp:26
ROL::TypeP::AlgorithmState::stepVec
Ptr< Vector< Real > > stepVec
Definition
ROL_TypeP_Algorithm.hpp:27
ROL::TypeP::AlgorithmState::nvalue
Real nvalue
Definition
ROL_TypeP_Algorithm.hpp:26
ROL::TypeP::AlgorithmState::nsval
int nsval
Definition
ROL_TypeP_Algorithm.hpp:28
ROL::TypeP::AlgorithmState::AlgorithmState
AlgorithmState()
Definition
ROL_TypeP_Algorithm.hpp:30
ROL::TypeP::AlgorithmState::svalue
Real svalue
Definition
ROL_TypeP_Algorithm.hpp:26
ROL::TypeP::AlgorithmState::reset
void reset()
Definition
ROL_TypeP_Algorithm.hpp:40
Generated by
1.17.0