ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
test
step
step/test_11.cpp
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
13
14
#include "ROL_GlobalMPISession.hpp"
15
16
#include "
ROL_HS24.hpp
"
17
#include "
ROL_Algorithm.hpp
"
18
#include "
ROL_ObjectiveFromBoundConstraint.hpp
"
19
20
int
main
(
int
argc,
char
*argv[]) {
21
22
23
24
25
typedef
double
RealT
;
26
27
typedef
ROL::Vector<RealT>
V
;
28
typedef
ROL::BoundConstraint<RealT>
BC;
29
typedef
ROL::Objective<RealT>
OBJ;
30
31
32
33
ROL::GlobalMPISession mpiSession(&argc, &argv);
34
35
int
iprint = argc - 1;
36
ROL::Ptr<std::ostream> outStream;
37
ROL::nullstream
bhs;
// outputs nothing
38
if
(iprint > 0)
39
outStream = ROL::makePtrFromRef(std::cout);
40
else
41
outStream = ROL::makePtrFromRef(bhs);
42
43
int
errorFlag = 0;
44
45
try
{
46
47
ROL::ZOO::getHS24<RealT>
HS24;
48
auto
x = HS24.
getInitialGuess
();
49
auto
xs = HS24.
getSolution
();
50
auto
inmul = HS24.
getInequalityMultiplier
();
51
52
auto
bnd = HS24.
getBoundConstraint
();
53
auto
obj = HS24.
getObjective
();
54
auto
incon = HS24.
getInequalityConstraint
();
55
auto
inbnd = HS24.
getSlackBoundConstraint
();
56
57
58
59
std::string stepname =
"Interior Point"
;
60
61
RealT
mu = 0.1;
// Initial penalty parameter
62
RealT
factor = 0.1;
// Penalty reduction factor
63
64
// Set solver parameters
65
parlist->sublist(
"Step"
).sublist(
"Interior Point"
).set(
"Initial Barrier Penalty"
,mu);
66
parlist->sublist(
"Step"
).sublist(
"Interior Point"
).set(
"Minimium Barrier Penalty"
,1e-8);
67
parlist->sublist(
"Step"
).sublist(
"Interior Point"
).set(
"Barrier Penalty Reduction Factor"
,factor);
68
parlist->sublist(
"Step"
).sublist(
"Interior Point"
).set(
"Subproblem Iteration Limit"
,30);
69
70
parlist->sublist(
"Step"
).sublist(
"Composite Step"
).sublist(
"Optimality System Solver"
).set(
"Nominal Relative Tolerance"
,1.e-4);
71
parlist->sublist(
"Step"
).sublist(
"Composite Step"
).sublist(
"Optimality System Solver"
).set(
"Fix Tolerance"
,
true
);
72
parlist->sublist(
"Step"
).sublist(
"Composite Step"
).sublist(
"Tangential Subproblem Solver"
).set(
"Iteration Limit"
,20);
73
parlist->sublist(
"Step"
).sublist(
"Composite Step"
).sublist(
"Tangential Subproblem Solver"
).set(
"Relative Tolerance"
,1e-2);
74
parlist->sublist(
"Step"
).sublist(
"Composite Step"
).set(
"Output Level"
,0);
75
76
parlist->sublist(
"Status Test"
).set(
"Gradient Tolerance"
,1.e-12);
77
parlist->sublist(
"Status Test"
).set(
"Constraint Tolerance"
,1.e-8);
78
parlist->sublist(
"Status Test"
).set(
"Step Tolerance"
,1.e-8);
79
parlist->sublist(
"Status Test"
).set(
"Iteration Limit"
,100);
80
81
// Define Optimization Problem
82
ROL::OptimizationProblem<RealT>
problem( obj, x, bnd, incon, inmul, inbnd );
83
84
ROL::Ptr<V> d = x->clone();
85
RandomizeVector(*d);
86
87
// problem.checkObjectiveGradient(*d);
88
// problem.checkObjectiveHessVec(*d);
89
90
// Define algorithm.
91
ROL::Ptr<ROL::Algorithm<RealT> > algo;
92
algo = ROL::makePtr<ROL::Algorithm<RealT>>(stepname,*parlist);
93
94
algo->run(problem,
true
,*outStream);
95
96
x->axpy(-1.0,*xs);
97
98
if
( x->norm()>= 1e-4 )
99
{
100
++errorFlag;
101
}
102
103
}
104
catch
(std::logic_error& err) {
105
*outStream << err.what() <<
"\n"
;
106
errorFlag = -1000;
107
};
// end try
108
109
if
(errorFlag != 0)
110
std::cout <<
"End Result: TEST FAILED\n"
;
111
else
112
std::cout <<
"End Result: TEST PASSED\n"
;
113
114
return
0;
115
116
117
118
}
ROL_Algorithm.hpp
V
Vector< Real > V
Definition
ROL_BlockOperator2Diagonal.hpp:46
ROL_HS24.hpp
Contains definitions for W. Hock and K. Schittkowski 24th test problem which contains bound and inequ...
ROL_ObjectiveFromBoundConstraint.hpp
ROL::BoundConstraint
Provides the interface to apply upper and lower bound constraints.
Definition
ROL_BoundConstraint.hpp:39
ROL::Objective
Provides the interface to evaluate objective functions.
Definition
ROL_Objective.hpp:44
ROL::OptimizationProblem
Definition
ROL_OptimizationProblem.hpp:54
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL::ZOO::getHS24
Definition
ROL_HS24.hpp:135
ROL::ZOO::getHS24::getSlackBoundConstraint
Ptr< BoundConstraint< Real > > getSlackBoundConstraint(void) const
Definition
ROL_HS24.hpp:181
ROL::ZOO::getHS24::getInequalityConstraint
Ptr< Constraint< Real > > getInequalityConstraint(void) const
Definition
ROL_HS24.hpp:143
ROL::ZOO::getHS24::getInitialGuess
Ptr< Vector< Real > > getInitialGuess(void) const
Definition
ROL_HS24.hpp:160
ROL::ZOO::getHS24::getInequalityMultiplier
Ptr< Vector< Real > > getInequalityMultiplier(void) const
Definition
ROL_HS24.hpp:176
ROL::ZOO::getHS24::getSolution
Ptr< Vector< Real > > getSolution(const int i=0) const
Definition
ROL_HS24.hpp:168
ROL::ZOO::getHS24::getObjective
Ptr< Objective< Real > > getObjective(void) const
Definition
ROL_HS24.hpp:139
ROL::ZOO::getHS24::getBoundConstraint
Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
Definition
ROL_HS24.hpp:147
RealT
double RealT
Definition
function/constraint/test_01.cpp:29
ROL::details::nullstream
basic_nullstream< char, std::char_traits< char > > nullstream
Definition
ROL_Stream.hpp:36
main
int main(int argc, char *argv[])
Definition
step/test_11.cpp:20
Generated by
1.17.0