ROL
src
status
ROL_ConstraintStatusTest.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_CONSTRAINTSTATUSTEST_H
11
#define ROL_CONSTRAINTSTATUSTEST_H
12
13
#include "
ROL_StatusTest.hpp
"
14
19
20
21
namespace
ROL
{
22
23
template
<
class
Real>
24
class
ConstraintStatusTest
:
public
StatusTest
<Real> {
25
private
:
26
27
Real
gtol_
,
gtol0_
;
28
Real
ctol_
,
ctol0_
;
29
Real
stol_
,
stol0_
;
30
int
max_iter_
;
31
bool
use_rel_
;
32
33
public
:
34
35
virtual
~ConstraintStatusTest
() {}
36
37
ConstraintStatusTest
( ROL::ParameterList &parlist ) {
38
Real em6(1e-6);
39
gtol_
= parlist.sublist(
"Status Test"
).get(
"Gradient Tolerance"
, em6);
40
ctol_
= parlist.sublist(
"Status Test"
).get(
"Constraint Tolerance"
, em6);
41
stol_
= parlist.sublist(
"Status Test"
).get(
"Step Tolerance"
, em6*
gtol_
);
42
max_iter_
= parlist.sublist(
"Status Test"
).get(
"Iteration Limit"
, 100);
43
use_rel_
= parlist.sublist(
"Status Test"
).get(
"Use Relative Tolerances"
,
false
);
44
gtol0_
=
gtol_
;
45
ctol0_
=
ctol_
;
46
stol0_
=
stol_
;
47
}
48
49
ConstraintStatusTest
( Real gtol = 1e-6, Real ctol = 1e-6, Real stol = 1e-12,
int
max_iter = 100,
bool
use_rel =
false
) :
50
gtol_
(gtol),
gtol0_
(gtol),
ctol_
(ctol),
ctol0_
(ctol),
stol_
(stol),
stol0_
(stol),
max_iter_
(max_iter),
use_rel_
(use_rel) {}
51
54
virtual
bool
check
(
AlgorithmState<Real>
&state ) {
55
if
(state.
iter
==0 &&
use_rel_
) {
56
gtol_
=
gtol0_
*std::max(state.
gnorm
,
static_cast<
Real
>
(1e-2));
57
ctol_
=
ctol0_
*std::max(state.
cnorm
,
static_cast<
Real
>
(1e-2));
58
stol_
=
stol0_
*std::max(std::min(state.
gnorm
,state.
cnorm
),
static_cast<
Real
>
(1e-2));
59
}
60
if
( ((state.
gnorm
>
gtol_
) || (state.
cnorm
>
ctol_
)) &&
61
(state.
snorm
>
stol_
) &&
62
(state.
iter
<
max_iter_
) ) {
63
return
true
;
64
}
65
else
{
66
state.
statusFlag
= ((state.
gnorm
<=
gtol_
) && (state.
cnorm
<=
ctol_
) ?
EXITSTATUS_CONVERGED
67
: state.
snorm
<=
stol_
?
EXITSTATUS_STEPTOL
68
: state.
iter
>=
max_iter_
?
EXITSTATUS_MAXITER
69
:
EXITSTATUS_LAST
);
70
return
false
;
71
}
72
}
73
74
};
// class ConstraintStatusTest
75
76
}
// namespace ROL
77
78
#endif
ROL_StatusTest.hpp
ROL::ConstraintStatusTest::ConstraintStatusTest
ConstraintStatusTest(ROL::ParameterList &parlist)
Definition
ROL_ConstraintStatusTest.hpp:37
ROL::ConstraintStatusTest::stol0_
Real stol0_
Definition
ROL_ConstraintStatusTest.hpp:29
ROL::ConstraintStatusTest::ConstraintStatusTest
ConstraintStatusTest(Real gtol=1e-6, Real ctol=1e-6, Real stol=1e-12, int max_iter=100, bool use_rel=false)
Definition
ROL_ConstraintStatusTest.hpp:49
ROL::ConstraintStatusTest::~ConstraintStatusTest
virtual ~ConstraintStatusTest()
Definition
ROL_ConstraintStatusTest.hpp:35
ROL::ConstraintStatusTest::ctol0_
Real ctol0_
Definition
ROL_ConstraintStatusTest.hpp:28
ROL::ConstraintStatusTest::check
virtual bool check(AlgorithmState< Real > &state)
Check algorithm status.
Definition
ROL_ConstraintStatusTest.hpp:54
ROL::ConstraintStatusTest::gtol_
Real gtol_
Definition
ROL_ConstraintStatusTest.hpp:27
ROL::ConstraintStatusTest::ctol_
Real ctol_
Definition
ROL_ConstraintStatusTest.hpp:28
ROL::ConstraintStatusTest::gtol0_
Real gtol0_
Definition
ROL_ConstraintStatusTest.hpp:27
ROL::ConstraintStatusTest::stol_
Real stol_
Definition
ROL_ConstraintStatusTest.hpp:29
ROL::ConstraintStatusTest::use_rel_
bool use_rel_
Definition
ROL_ConstraintStatusTest.hpp:31
ROL::ConstraintStatusTest::max_iter_
int max_iter_
Definition
ROL_ConstraintStatusTest.hpp:30
ROL::ROL::StatusTest::StatusTest
StatusTest(ParameterList &parlist)
Definition
ROL_Constraint_SerialSimOpt.hpp:36
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::EXITSTATUS_STEPTOL
@ EXITSTATUS_STEPTOL
Definition
ROL_Types.hpp:86
ROL::EXITSTATUS_MAXITER
@ EXITSTATUS_MAXITER
Definition
ROL_Types.hpp:85
ROL::EXITSTATUS_CONVERGED
@ EXITSTATUS_CONVERGED
Definition
ROL_Types.hpp:84
ROL::EXITSTATUS_LAST
@ EXITSTATUS_LAST
Definition
ROL_Types.hpp:89
ROL::AlgorithmState
State for algorithm class. Will be used for restarts.
Definition
ROL_Types.hpp:109
ROL::AlgorithmState::cnorm
Real cnorm
Definition
ROL_Types.hpp:118
ROL::AlgorithmState::gnorm
Real gnorm
Definition
ROL_Types.hpp:117
ROL::AlgorithmState::snorm
Real snorm
Definition
ROL_Types.hpp:119
ROL::AlgorithmState::statusFlag
EExitStatus statusFlag
Definition
ROL_Types.hpp:126
ROL::AlgorithmState::iter
int iter
Definition
ROL_Types.hpp:110
Generated by
1.15.0