58 #include "Teuchos_GlobalMPISession.hpp"
62 int main(
int argc,
char *argv[]) {
64 using namespace Teuchos;
66 typedef std::vector<RealT> vector;
70 GlobalMPISession mpiSession(&argc, &argv);
83 std::string paramfile =
"parameters.xml";
84 auto parlist = ROL::getParametersFromXmlFile( paramfile );
86 ROL::Ptr<vector> x_ptr = ROL::makePtr<vector>(dim, 1.0);
87 ROL::Ptr<vector> k_ptr = ROL::makePtr<vector>(dim, 0.0);
89 ROL::Ptr<V> x = ROL::makePtr<SV>(x_ptr);
90 ROL::Ptr<V> k = ROL::makePtr<SV>(k_ptr);
92 ROL::Ptr<V> s = x->clone();
94 for(
int i=0; i<dim; ++i ) {
98 ROL::Ptr<ROL::Objective<RealT> > obj = ROL::makePtr<ROL::ZOO::Objective_Zakharov<RealT>>(k);
114 for(
int iter = 0; iter<10; ++iter ) {
116 ls.
update( opt, *s, state );
122 *outStream <<
"LS fval = " << state.
minValue << std::endl;
125 tr.
update( opt, *s, state );
131 *outStream <<
"TR fval = " << state.
minValue << std::endl;
138 catch (std::logic_error err) {
139 *outStream << err.what() <<
"\n";
144 std::cout <<
"End Result: TEST FAILED\n";
146 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.
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update step, if successful.
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...
Ptr< ostream > makeStreamPtr(ostream &os, bool noSuppressOutput=true)
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.
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.