24 #include "Teuchos_GlobalMPISession.hpp"
28 int main(
int argc,
char *argv[]) {
30 using namespace Teuchos;
32 typedef std::vector<RealT> vector;
36 GlobalMPISession mpiSession(&argc, &argv);
49 std::string paramfile =
"parameters.xml";
50 auto parlist = ROL::getParametersFromXmlFile( paramfile );
52 ROL::Ptr<vector> x_ptr = ROL::makePtr<vector>(
dim, 1.0);
53 ROL::Ptr<vector> k_ptr = ROL::makePtr<vector>(
dim, 0.0);
55 ROL::Ptr<V> x = ROL::makePtr<SV>(x_ptr);
56 ROL::Ptr<V> k = ROL::makePtr<SV>(k_ptr);
58 ROL::Ptr<V> s = x->clone();
60 for(
int i=0; i<
dim; ++i ) {
64 ROL::Ptr<ROL::Objective<RealT>> obj = ROL::makePtr<ROL::ZOO::Objective_Zakharov<RealT>>(k);
65 ROL::Ptr<ROL::BoundConstraint<RealT>> bnd = ROL::makePtr<ROL::BoundConstraint<RealT>>();
88 for(
int iter = 0; iter<10; ++iter ) {
102 *outStream <<
"LS fval = " << state.
minValue << std::endl;
117 *outStream <<
"TR fval = " << state.
minValue << std::endl;
124 catch (std::logic_error& err) {
125 *outStream << err.what() <<
"\n";
130 std::cout <<
"End Result: TEST FAILED\n";
132 std::cout <<
"End Result: TEST PASSED\n";
void initialize(Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Initialize step.
virtual Ptr< Objective< Real > > getObjective(void)
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update step, if successful.
Ptr< std::ostream > makeStreamPtr(std::ostream &os, bool noSuppressOutput=true)
Defines the linear algebra or vector space interface.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
void initialize(Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Initialize step with bound constraint.
State for algorithm class. Will be used for restarts.
Provides the interface to compute optimization steps with line search.
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step.
virtual Ptr< Vector< Real > > getSolutionVector(void)
ROL::Ptr< Vector< Real > > iterateVec
Contains definitions for the Zakharov function as evaluated using only the ROL::Vector interface...
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step.
int main(int argc, char *argv[])
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update step, if successful.
ROL::Ptr< Vector< Real > > minIterVec
Provides the interface to compute optimization steps with trust regions.