ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
test
step
trustregion
step/trustregion/test_01.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_OptimizationSolver.hpp
"
15
#include "ROL_GlobalMPISession.hpp"
16
17
#include "
ROL_Stream.hpp
"
18
#include "
ROL_RandomVector.hpp
"
19
#include "
ROL_Rosenbrock.hpp
"
20
#include "ROL_ConicApproximationModel.hpp"
21
22
#include <iostream>
23
24
25
int
main
(
int
argc,
char
*argv[]) {
26
27
using
RealT
= double;
28
using namespace
ROL
;
29
30
ROL::GlobalMPISession mpiSession(&argc, &argv);
31
32
// This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
33
auto
outStream =
makeStreamPtr
( std::cout, argc > 1 );
34
35
int
errorFlag = 0;
36
37
// *** Test body.
38
39
try
{
40
41
ZOO::getRosenbrock<RealT>
rosenbrock;
42
43
auto
x = rosenbrock.
getInitialGuess
();
44
auto
a = x->clone();
45
auto
s = x->clone();
46
auto
d = x->clone();
47
auto
obj = rosenbrock.
getObjective
();
48
49
RandomizeVector
( *s );
50
RandomizeVector
( *a );
51
RandomizeVector
( *d );
52
53
ConicApproximationModel<RealT>
conic( obj, x, s, a );
54
conic.checkGradient( *x, *d,
true
, *outStream );
55
56
}
57
catch
(std::logic_error& err) {
58
*outStream << err.what() << std::endl;
59
errorFlag = -1000;
60
};
// end try
61
62
if
(errorFlag != 0)
63
std::cout <<
"End Result: TEST FAILED"
<< std::endl;
64
else
65
std::cout <<
"End Result: TEST PASSED"
<< std::endl;
66
67
return
0;
68
69
}
70
ROL_OptimizationSolver.hpp
ROL_RandomVector.hpp
ROL_Rosenbrock.hpp
Contains definitions for Rosenbrock's function.
ROL_Stream.hpp
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
ConicApproximationModel
Provides the interface to evaluate conic approximation function.
ROL::ZOO::getRosenbrock
Definition
ROL_Rosenbrock.hpp:135
ROL::ZOO::getRosenbrock::getObjective
Ptr< Objective< Real > > getObjective(void) const
Definition
ROL_Rosenbrock.hpp:139
ROL::ZOO::getRosenbrock::getInitialGuess
Ptr< Vector< Real > > getInitialGuess(void) const
Definition
ROL_Rosenbrock.hpp:144
RealT
double RealT
Definition
function/constraint/test_01.cpp:29
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
Definition
ROL_ElementwiseVector.hpp:27
ROL::makeStreamPtr
Ptr< std::ostream > makeStreamPtr(std::ostream &os, bool noSuppressOutput=true)
Definition
ROL_Stream.hpp:39
main
int main(int argc, char *argv[])
Definition
step/trustregion/test_01.cpp:25
Generated by
1.17.0