10#ifndef ROL_ALGORITHM_H
11#define ROL_ALGORITHM_H
33 ROL::Ptr<AlgorithmState<Real> >
state_;
45 bool printHeader =
false ) {
48 state_ = ROL::makePtr<AlgorithmState<Real>>();
58 bool printHeader =
false ) {
71 std::ostream &outStream = std::cout,
72 bool printVectors =
false,
73 std::ostream &vectorStream = std::cout ) {
76 return run(x,x.
dual(),obj,bnd,print,outStream,printVectors,vectorStream);
87 std::ostream &outStream = std::cout,
88 bool printVectors =
false,
89 std::ostream &vectorStream = std::cout ) {
92 return run(x,g,obj,bnd,print,outStream,printVectors,vectorStream);
102 std::ostream &outStream = std::cout,
103 bool printVectors =
false,
104 std::ostream &vectorStream = std::cout ) {
105 return run(x,x.
dual(),obj,bnd,print,outStream,printVectors,vectorStream);
117 std::ostream &outStream = std::cout,
118 bool printVectors =
false,
119 std::ostream &vectorStream = std::cout ) {
121 x.
print(vectorStream);
124 std::vector<std::string> output;
127 if (
state_->iterateVec == ROL::nullPtr ) {
130 state_->iterateVec->set(x);
133 ROL::Ptr<Vector<Real> > s = x.
clone();
143 if (
state_->minIterVec == ROL::nullPtr ) {
146 state_->minIterVec->set(x);
156 x.
print(vectorStream);
171 std::stringstream hist;
172 hist <<
"Optimization Terminated with Status: ";
175 output.push_back(hist.str());
177 outStream << hist.str();
191 std::ostream &outStream = std::cout,
192 bool printVectors =
false,
193 std::ostream &vectorStream = std::cout ) {
195 return run(x, x.
dual(), l, l.
dual(), obj, con, print, outStream, printVectors, vectorStream);
211 std::ostream &outStream = std::cout,
212 bool printVectors =
false,
213 std::ostream &vectorStream = std::cout ) {
215 x.
print(vectorStream);
218 std::vector<std::string> output;
221 if (
state_->iterateVec == ROL::nullPtr ) {
224 state_->iterateVec->set(x);
227 if (
state_->lagmultVec == ROL::nullPtr ) {
230 state_->lagmultVec->set(l);
233 ROL::Ptr<Vector<Real> > s = x.
clone();
243 if (
state_->minIterVec == ROL::nullPtr ) {
246 state_->minIterVec->set(x);
256 x.
print(vectorStream);
264 std::stringstream hist;
265 hist <<
"Optimization Terminated with Status: ";
268 output.push_back(hist.str());
270 outStream << hist.str();
284 std::ostream &outStream = std::cout,
285 bool printVectors =
false,
286 std::ostream &vectorStream = std::cout) {
287 return run(x,x.
dual(),l,l.
dual(),obj,con,bnd,print,outStream,printVectors,vectorStream);
302 std::ostream &outStream = std::cout,
303 bool printVectors =
false,
304 std::ostream &vectorStream = std::cout ) {
306 x.
print(vectorStream);
309 std::vector<std::string> output;
312 if (
state_->iterateVec == ROL::nullPtr ) {
315 state_->iterateVec->set(x);
318 if (
state_->lagmultVec == ROL::nullPtr ) {
321 state_->lagmultVec->set(l);
324 ROL::Ptr<Vector<Real> > s = x.
clone();
327 step_->initialize(x, g, l, c, obj, con, bnd, *
state_);
334 if (
state_->minIterVec == ROL::nullPtr ) {
337 state_->minIterVec->set(x);
346 x.
print(vectorStream);
353 std::stringstream hist;
354 hist <<
"Optimization Terminated with Status: ";
357 output.push_back(hist.str());
359 outStream << hist.str();
365 return step_->printHeader();
372 ROL::Ptr<const AlgorithmState<Real> >
getState(
void)
const {
Contains definitions of custom data types in ROL.
Provides an interface to run optimization algorithms.
ROL::Ptr< Step< Real > > step_
ROL::Ptr< StatusTest< Real > > status_
std::string getIterInfo(bool withHeader=false)
Algorithm(const ROL::Ptr< Step< Real > > &step, const ROL::Ptr< StatusTest< Real > > &status, const ROL::Ptr< AlgorithmState< Real > > &state, bool printHeader=false)
Constructor, given a step, a status test, and a previously defined algorithm state.
virtual std::vector< std::string > run(Vector< Real > &x, Objective< Real > &obj, bool print=false, std::ostream &outStream=std::cout, bool printVectors=false, std::ostream &vectorStream=std::cout)
Run algorithm on unconstrained problems (Type-U). This is the primary Type-U interface.
ROL::Ptr< AlgorithmState< Real > > state_
virtual std::vector< std::string > run(Vector< Real > &x, Vector< Real > &l, Objective< Real > &obj, Constraint< Real > &con, bool print=false, std::ostream &outStream=std::cout, bool printVectors=false, std::ostream &vectorStream=std::cout)
Run algorithm on equality constrained problems (Type-E). This is the primary Type-E interface.
Algorithm(const ROL::Ptr< Step< Real > > &step, const ROL::Ptr< StatusTest< Real > > &status, bool printHeader=false)
Constructor, given a step and a status test.
ROL::Ptr< const AlgorithmState< Real > > getState(void) const
std::string getIterHeader(void)
virtual std::vector< std::string > run(Vector< Real > &x, Vector< Real > &l, Objective< Real > &obj, Constraint< Real > &con, BoundConstraint< Real > &bnd, bool print=false, std::ostream &outStream=std::cout, bool printVectors=false, std::ostream &vectorStream=std::cout)
Run algorithm on equality and bound constrained problems (Type-EB). This is the primary Type-EB inter...
virtual std::vector< std::string > run(Vector< Real > &x, const Vector< Real > &g, Vector< Real > &l, const Vector< Real > &c, Objective< Real > &obj, Constraint< Real > &con, BoundConstraint< Real > &bnd, bool print=false, std::ostream &outStream=std::cout, bool printVectors=false, std::ostream &vectorStream=std::cout)
Run algorithm on equality and bound constrained problems (Type-EB). This general interface supports t...
virtual std::vector< std::string > run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, bool print=false, std::ostream &outStream=std::cout, bool printVectors=false, std::ostream &vectorStream=std::cout)
Run algorithm on bound constrained problems (Type-B). This general interface supports the use of dual...
virtual std::vector< std::string > run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, bool print=false, std::ostream &outStream=std::cout, bool printVectors=false, std::ostream &vectorStream=std::cout)
Run algorithm on unconstrained problems (Type-U). This general interface supports the use of dual opt...
virtual std::vector< std::string > run(Vector< Real > &x, const Vector< Real > &g, Vector< Real > &l, const Vector< Real > &c, Objective< Real > &obj, Constraint< Real > &con, bool print=false, std::ostream &outStream=std::cout, bool printVectors=false, std::ostream &vectorStream=std::cout)
Run algorithm on equality constrained problems (Type-E). This general interface supports the use of d...
virtual std::vector< std::string > run(Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, bool print=false, std::ostream &outStream=std::cout, bool printVectors=false, std::ostream &vectorStream=std::cout)
Run algorithm on bound constrained problems (Type-B). This is the primary Type-B interface.
Provides the interface to apply upper and lower bound constraints.
void deactivate(void)
Turn off bounds.
Defines the general constraint operator interface.
Provides the interface to evaluate objective functions.
Provides an interface to check status of optimization algorithms.
Provides the interface to compute optimization steps.
Defines the linear algebra or vector space interface.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis,...
virtual void print(std::ostream &outStream) const
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
std::string EExitStatusToString(EExitStatus tr)
State for algorithm class. Will be used for restarts.