44#ifndef ROL_ALGORITHM_H
45#define ROL_ALGORITHM_H
67 ROL::Ptr<AlgorithmState<Real> >
state_;
79 bool printHeader =
false ) {
82 state_ = ROL::makePtr<AlgorithmState<Real>>();
92 bool printHeader =
false ) {
105 std::ostream &outStream = std::cout,
106 bool printVectors =
false,
107 std::ostream &vectorStream = std::cout ) {
110 return run(x,x.
dual(),obj,bnd,print,outStream,printVectors,vectorStream);
121 std::ostream &outStream = std::cout,
122 bool printVectors =
false,
123 std::ostream &vectorStream = std::cout ) {
126 return run(x,g,obj,bnd,print,outStream,printVectors,vectorStream);
136 std::ostream &outStream = std::cout,
137 bool printVectors =
false,
138 std::ostream &vectorStream = std::cout ) {
139 return run(x,x.
dual(),obj,bnd,print,outStream,printVectors,vectorStream);
151 std::ostream &outStream = std::cout,
152 bool printVectors =
false,
153 std::ostream &vectorStream = std::cout ) {
155 x.
print(vectorStream);
158 std::vector<std::string> output;
161 if (
state_->iterateVec == ROL::nullPtr ) {
164 state_->iterateVec->set(x);
167 ROL::Ptr<Vector<Real> > s = x.
clone();
177 if (
state_->minIterVec == ROL::nullPtr ) {
180 state_->minIterVec->set(x);
190 x.
print(vectorStream);
205 std::stringstream hist;
206 hist <<
"Optimization Terminated with Status: ";
209 output.push_back(hist.str());
211 outStream << hist.str();
225 std::ostream &outStream = std::cout,
226 bool printVectors =
false,
227 std::ostream &vectorStream = std::cout ) {
229 return run(x, x.
dual(), l, l.
dual(), obj, con, print, outStream, printVectors, vectorStream);
245 std::ostream &outStream = std::cout,
246 bool printVectors =
false,
247 std::ostream &vectorStream = std::cout ) {
249 x.
print(vectorStream);
252 std::vector<std::string> output;
255 if (
state_->iterateVec == ROL::nullPtr ) {
258 state_->iterateVec->set(x);
261 if (
state_->lagmultVec == ROL::nullPtr ) {
264 state_->lagmultVec->set(l);
267 ROL::Ptr<Vector<Real> > s = x.
clone();
277 if (
state_->minIterVec == ROL::nullPtr ) {
280 state_->minIterVec->set(x);
290 x.
print(vectorStream);
298 std::stringstream hist;
299 hist <<
"Optimization Terminated with Status: ";
302 output.push_back(hist.str());
304 outStream << hist.str();
318 std::ostream &outStream = std::cout,
319 bool printVectors =
false,
320 std::ostream &vectorStream = std::cout) {
321 return run(x,x.
dual(),l,l.
dual(),obj,con,bnd,print,outStream,printVectors,vectorStream);
336 std::ostream &outStream = std::cout,
337 bool printVectors =
false,
338 std::ostream &vectorStream = std::cout ) {
340 x.
print(vectorStream);
343 std::vector<std::string> output;
346 if (
state_->iterateVec == ROL::nullPtr ) {
349 state_->iterateVec->set(x);
352 if (
state_->lagmultVec == ROL::nullPtr ) {
355 state_->lagmultVec->set(l);
358 ROL::Ptr<Vector<Real> > s = x.
clone();
361 step_->initialize(x, g, l, c, obj, con, bnd, *
state_);
368 if (
state_->minIterVec == ROL::nullPtr ) {
371 state_->minIterVec->set(x);
380 x.
print(vectorStream);
387 std::stringstream hist;
388 hist <<
"Optimization Terminated with Status: ";
391 output.push_back(hist.str());
393 outStream << hist.str();
399 return step_->printHeader();
406 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.