ROL
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
14#include "ROL_GlobalMPISession.hpp"
15
16#include "ROL_HS24.hpp"
17#include "ROL_Algorithm.hpp"
19
20int main(int argc, char *argv[]) {
21
22
23
24
25 typedef double RealT;
26
27 typedef ROL::Vector<RealT> V;
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
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}
Vector< Real > V
Contains definitions for W. Hock and K. Schittkowski 24th test problem which contains bound and inequ...
Provides the interface to apply upper and lower bound constraints.
Provides the interface to evaluate objective functions.
Defines the linear algebra or vector space interface.
Ptr< BoundConstraint< Real > > getSlackBoundConstraint(void) const
Definition ROL_HS24.hpp:181
Ptr< Constraint< Real > > getInequalityConstraint(void) const
Definition ROL_HS24.hpp:143
Ptr< Vector< Real > > getInitialGuess(void) const
Definition ROL_HS24.hpp:160
Ptr< Vector< Real > > getInequalityMultiplier(void) const
Definition ROL_HS24.hpp:176
Ptr< Vector< Real > > getSolution(const int i=0) const
Definition ROL_HS24.hpp:168
Ptr< Objective< Real > > getObjective(void) const
Definition ROL_HS24.hpp:139
Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
Definition ROL_HS24.hpp:147
int main(int argc, char *argv[])