44 #ifndef ROL_ALGORITHM_H
45 #define ROL_ALGORITHM_H
76 ROL::Ptr<AlgorithmState<Real> >
state_;
88 bool printHeader =
false ) {
91 state_ = ROL::makePtr<AlgorithmState<Real>>();
101 bool printHeader =
false ) {
113 ROL::ParameterList &parlist,
114 bool printHeader =
false) {
122 std::invalid_argument,
123 "Invalid step name in algorithm constructor!");
128 state_ = ROL::makePtr<AlgorithmState<Real>>();
138 std::ostream &outStream = std::cout,
139 bool printVectors =
false,
140 std::ostream &vectorStream = std::cout ) {
143 return run(x,x.
dual(),obj,bnd,print,outStream,printVectors,vectorStream);
154 std::ostream &outStream = std::cout,
155 bool printVectors =
false,
156 std::ostream &vectorStream = std::cout ) {
159 return run(x,g,obj,bnd,print,outStream,printVectors,vectorStream);
169 std::ostream &outStream = std::cout,
170 bool printVectors =
false,
171 std::ostream &vectorStream = std::cout ) {
172 return run(x,x.
dual(),obj,bnd,print,outStream,printVectors,vectorStream);
184 std::ostream &outStream = std::cout,
185 bool printVectors =
false,
186 std::ostream &vectorStream = std::cout ) {
188 x.
print(vectorStream);
191 std::vector<std::string> output;
194 if (
state_->iterateVec == ROL::nullPtr ) {
197 state_->iterateVec->set(x);
200 ROL::Ptr<Vector<Real> > s = x.
clone();
210 if (
state_->minIterVec == ROL::nullPtr ) {
213 state_->minIterVec->set(x);
223 x.
print(vectorStream);
238 std::stringstream hist;
239 hist <<
"Optimization Terminated with Status: ";
242 output.push_back(hist.str());
244 outStream << hist.str();
258 std::ostream &outStream = std::cout,
259 bool printVectors =
false,
260 std::ostream &vectorStream = std::cout ) {
262 return run(x, x.
dual(), l, l.
dual(), obj, con, print, outStream, printVectors, vectorStream);
278 std::ostream &outStream = std::cout,
279 bool printVectors =
false,
280 std::ostream &vectorStream = std::cout ) {
282 x.
print(vectorStream);
285 std::vector<std::string> output;
288 if (
state_->iterateVec == ROL::nullPtr ) {
291 state_->iterateVec->set(x);
294 if (
state_->lagmultVec == ROL::nullPtr ) {
297 state_->lagmultVec->set(l);
300 ROL::Ptr<Vector<Real> > s = x.
clone();
310 if (
state_->minIterVec == ROL::nullPtr ) {
313 state_->minIterVec->set(x);
323 x.
print(vectorStream);
331 std::stringstream hist;
332 hist <<
"Optimization Terminated with Status: ";
335 output.push_back(hist.str());
337 outStream << hist.str();
351 std::ostream &outStream = std::cout,
352 bool printVectors =
false,
353 std::ostream &vectorStream = std::cout) {
354 return run(x,x.
dual(),l,l.
dual(),obj,con,bnd,print,outStream,printVectors,vectorStream);
369 std::ostream &outStream = std::cout,
370 bool printVectors =
false,
371 std::ostream &vectorStream = std::cout ) {
373 x.
print(vectorStream);
376 std::vector<std::string> output;
379 if (
state_->iterateVec == ROL::nullPtr ) {
382 state_->iterateVec->set(x);
385 if (
state_->lagmultVec == ROL::nullPtr ) {
388 state_->lagmultVec->set(l);
391 ROL::Ptr<Vector<Real> > s = x.
clone();
394 step_->initialize(x, g, l, c, obj, con, bnd, *
state_);
401 if (
state_->minIterVec == ROL::nullPtr ) {
404 state_->minIterVec->set(x);
413 x.
print(vectorStream);
420 std::stringstream hist;
421 hist <<
"Optimization Terminated with Status: ";
424 output.push_back(hist.str());
426 outStream << hist.str();
435 std::ostream &outStream = std::cout ) {
444 if ( con == ROL::nullPtr ) {
445 if ( bnd == ROL::nullPtr ) {
446 return run(*x,*obj,print,outStream);
449 return run(*x,*obj,*bnd,print,outStream);
453 if ( bnd == ROL::nullPtr ) {
454 return run(*x,*l,*obj,*con,print,outStream);
457 return run(*x,*l,*obj,*con,*bnd,print,outStream);
463 return step_->printHeader();
470 ROL::Ptr<const AlgorithmState<Real> >
getState(
void)
const {
Provides the interface to evaluate objective functions.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
ROL::Ptr< Step< Real > > step_
ROL::Ptr< StatusTest< Real > > getStatusTest(const std::string step, ROL::ParameterList &parlist)
EStep StringToEStep(std::string s)
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void print(std::ostream &outStream) const
void stepFactory(ROL::ParameterList &parlist, ROL::Ptr< ROL::Step< Real > > &step)
A minimalist step factory which specializes the Step Type depending on whether a Trust-Region or Line...
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...
ROL::Ptr< Step< Real > > getStep(const std::string &type, ROL::ParameterList &parlist) const
Provides the interface to compute optimization steps.
Contains definitions of custom data types in ROL.
ROL::Ptr< AlgorithmState< Real > > state_
virtual Ptr< Objective< Real > > getObjective(void)
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.
virtual Ptr< BoundConstraint< Real > > getBoundConstraint(void)
Defines the linear algebra or vector space interface.
Algorithm(const std::string &stepname, ROL::ParameterList &parlist, bool printHeader=false)
Constructor, given a string, for the step, and a parameter list of various options. The status test is determined based on the step string.
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...
State for algorithm class. Will be used for restarts.
virtual std::vector< std::string > run(OptimizationProblem< Real > &opt, bool print=false, std::ostream &outStream=std::cout)
Run algorithm using a ROL::OptimizationProblem.
std::string EExitStatusToString(EExitStatus tr)
virtual Ptr< Vector< Real > > getSolutionVector(void)
Provides an interface to run optimization algorithms.
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, 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.
ROL::Ptr< const AlgorithmState< Real > > getState(void) const
Provides an interface to check status of optimization algorithms.
virtual Ptr< Vector< Real > > getMultiplierVector(void)
Provides the interface to apply upper and lower bound constraints.
int isValidStep(EStep ls)
Verifies validity of a TrustRegion enum.
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...
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...
std::string getIterInfo(bool withHeader=false)
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...
void deactivate(void)
Turn off bounds.
EStep
Enumeration of step types.
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< StatusTest< Real > > status_
Defines the general constraint operator interface.
virtual Ptr< Constraint< Real > > getConstraint(void)
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...
std::string getIterHeader(void)