57 #include "Teuchos_oblackholestream.hpp" 58 #include "Teuchos_GlobalMPISession.hpp" 59 #include "Teuchos_XMLParameterListHelpers.hpp" 63 int main(
int argc,
char *argv[]) {
65 using namespace Teuchos;
67 typedef std::vector<RealT> vector;
71 GlobalMPISession mpiSession(&argc, &argv);
74 int iprint = argc - 1;
75 RCP<std::ostream> outStream;
78 outStream = rcp(&std::cout,
false);
80 outStream = rcp(&bhs,
false);
90 RCP<ParameterList> parlist = rcp(
new ParameterList());
91 std::string paramfile =
"parameters.xml";
92 updateParametersFromXmlFile(paramfile,parlist.ptr());
94 RCP<vector> x_rcp = rcp(
new vector(dim, 1.0) );
95 RCP<vector> k_rcp = rcp(
new vector(dim, 0.0) );
97 RCP<V> x = rcp(
new SV(x_rcp) );
98 RCP<V> k = rcp(
new SV(k_rcp) );
100 RCP<V> s = x->clone();
102 for(
int i=0; i<dim; ++i ) {
122 for(
int iter = 0; iter<10; ++iter ) {
124 ls.
update( opt, *s, state );
130 *outStream <<
"LS fval = " << state.
minValue << std::endl;
133 tr.
update( opt, *s, state );
139 *outStream <<
"TR fval = " << state.
minValue << std::endl;
146 catch (std::logic_error err) {
147 *outStream << err.what() <<
"\n";
152 std::cout <<
"End Result: TEST FAILED\n";
154 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.
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 std::vector implementation of 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[])
Contains definitions for the Zakharov function as evaluated using only the ROL::Vector interface...
Teuchos::RCP< Vector< Real > > minIterVec
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step.
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update step, if successful.
Teuchos::RCP< Vector< Real > > iterateVec
Provides the interface to compute optimization steps with trust regions.