ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
test
function
function/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
14
15
#include "
ROL_ColemanLiModel.hpp
"
16
#include "
ROL_HS2.hpp
"
17
#include "
ROL_StdVector.hpp
"
18
#include "
ROL_RandomVector.hpp
"
19
#include "
ROL_Stream.hpp
"
20
#include "ROL_GlobalMPISession.hpp"
21
//#include <fenv.h>
22
23
typedef
double
RealT
;
24
25
int
main
(
int
argc,
char
*argv[]) {
26
//feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
27
28
typedef
ROL::Vector<RealT>
V
;
29
typedef
ROL::Objective<RealT>
OBJ;
30
typedef
ROL::BoundConstraint<RealT>
CON;
31
32
ROL::GlobalMPISession mpiSession(&argc, &argv);
33
34
// This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
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
// Save the format state of the original std::cout.
44
ROL::nullstream
oldFormatState;
45
oldFormatState.copyfmt(std::cout);
46
47
RealT
zero
(0);
48
49
ROL::Ptr<V> x0;
50
ROL::Ptr<V> x;
51
ROL::Ptr<V> g;
52
ROL::Ptr<OBJ> obj;
53
ROL::Ptr<CON> con;
54
ROL::Ptr<OBJ> model;
55
56
ROL::ZOO::getHS2<RealT>
HS2;
57
obj = HS2.
getObjective
();
58
con = HS2.
getBoundConstraint
();
59
x0 = HS2.
getInitialGuess
();
60
x = HS2.
getSolution
();
61
62
g = x->dual().clone();
63
64
// Need to evaluate the gradient to construct the model
65
obj->gradient(*g,*x,
zero
);
66
67
model = ROL::makePtr<ROL::ColemanLiModel<RealT>>(*obj,*con,*x,*g);
68
69
ROL::Ptr<V> s = x->clone();
70
ROL::Ptr<V> v = x->clone();
71
ROL::Ptr<V> u = x->clone();
72
73
ROL::RandomizeVector
(*s,-1.0,1.0);
74
ROL::RandomizeVector
(*u,-1.0,1.0);
75
ROL::RandomizeVector
(*v,-1.0,1.0);
76
77
model->checkGradient(*s,*v);
78
model->checkHessVec(*s,*v);
79
model->checkHessSym(*s,*u,*v);
80
81
return
0;
82
}
83
84
V
Vector< Real > V
Definition
ROL_BlockOperator2Diagonal.hpp:46
ROL_ColemanLiModel.hpp
ROL_HS2.hpp
Contains definitions for W. Hock and K. Schittkowski 2nd test function.
zero
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0 zero)()
Definition
ROL_Objective_SerialSimOpt.hpp:77
ROL_RandomVector.hpp
ROL_StdVector.hpp
ROL_Stream.hpp
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
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::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL::ZOO::getHS2
Definition
ROL_HS2.hpp:114
ROL::ZOO::getHS2::getSolution
Ptr< Vector< Real > > getSolution(const int i=0) const
Definition
ROL_HS2.hpp:132
ROL::ZOO::getHS2::getBoundConstraint
Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
Definition
ROL_HS2.hpp:144
ROL::ZOO::getHS2::getObjective
Ptr< Objective< Real > > getObjective(void) const
Definition
ROL_HS2.hpp:118
ROL::ZOO::getHS2::getInitialGuess
Ptr< Vector< Real > > getInitialGuess(void) const
Definition
ROL_HS2.hpp:123
RealT
double RealT
Definition
function/constraint/test_01.cpp:29
main
int main(int argc, char *argv[])
Definition
function/test_11.cpp:25
ROL::RandomizeVector
void RandomizeVector(Vector< Real > &x, const Real &lower=0.0, const Real &upper=1.0)
Fill a ROL::Vector with uniformly-distributed random numbers in the interval [lower,...
Definition
ROL_RandomVector.hpp:30
ROL::details::nullstream
basic_nullstream< char, std::char_traits< char > > nullstream
Definition
ROL_Stream.hpp:36
Generated by
1.17.0