10#ifndef ROL_TYPEP_ALGORITHM_DEF_H
11#define ROL_TYPEP_ALGORITHM_DEF_H
19template<
typename Real>
27template<
typename Real>
29 if (
state_->iterateVec == nullPtr)
31 state_->iterateVec->set(x);
32 if (
state_->stepVec == nullPtr)
35 if (
state_->gradientVec == nullPtr)
37 state_->gradientVec->set(g);
38 if (
state_->minIterVec == nullPtr)
40 state_->minIterVec->set(x);
45template<
typename Real>
58 pgstep.axpy(
static_cast<Real
>(-1),x);
61template<
typename Real>
69template<
typename Real>
71 std::ostream &outStream ) {
85template<
typename Real>
89 std::ostream &outStream ) {
90 run(x,x.
dual(),sobj,nobj,outStream);
93template<
typename Real>
95 std::ios_base::fmtflags osFlags(os.flags());
97 os << std::setw(6) << std::left <<
"iter";
98 os << std::setw(15) << std::left <<
"value";
99 os << std::setw(15) << std::left <<
"gnorm";
100 os << std::setw(15) << std::left <<
"snorm";
101 os << std::setw(10) << std::left <<
"#fval";
102 os << std::setw(10) << std::left <<
"#grad";
103 os << std::setw(10) << std::left <<
"#prox";
108template<
typename Real>
113template<
typename Real>
115 std::ios_base::fmtflags osFlags(os.flags());
116 os << std::scientific << std::setprecision(6);
118 if (
state_->iter == 0 ) {
120 os << std::setw(6) << std::left <<
state_->iter;
121 os << std::setw(15) << std::left <<
state_->value;
122 os << std::setw(15) << std::left <<
state_->gnorm;
127 os << std::setw(6) << std::left <<
state_->iter;
128 os << std::setw(15) << std::left <<
state_->value;
129 os << std::setw(15) << std::left <<
state_->gnorm;
130 os << std::setw(15) << std::left <<
state_->snorm;
131 os << std::setw(10) << std::left <<
state_->nfval;
132 os << std::setw(10) << std::left <<
state_->ngrad;
133 os << std::setw(10) << std::left <<
state_->nprox;
139template<
typename Real>
141 std::ios_base::fmtflags osFlags(os.flags());
142 os <<
"Optimization Terminated with Status: ";
148template<
typename Real>
153template<
typename Real>
Contains definitions of custom data types in ROL.
Provides an interface to check two status tests of optimization algorithms.
Provides the interface to evaluate objective functions.
virtual void prox(Vector< Real > &Pv, const Vector< Real > &v, Real t, Real &tol)
Compute the proximity operator.
const Ptr< Vector< Real > > & getPrimalOptimizationVector()
Get the primal optimization space vector.
const Ptr< Vector< Real > > & getDualOptimizationVector()
Get the dual optimization space vector.
const Ptr< Objective< Real > > & getProximableObjective()
Get proximable objective.
EProblem getProblemType()
Get the optimization problem type (U, B, E, or G).
void finalizeIteration()
Transform the optimization variables to the native parameterization after an optimization algorithm h...
const Ptr< Objective< Real > > & getObjective()
Get the objective function.
Provides an interface to check status of optimization algorithms.
void pgstep(Vector< Real > &pgiter, Vector< Real > &pgstep, Objective< Real > &nobj, const Vector< Real > &x, const Vector< Real > &dg, Real t, Real &tol) const
virtual void run(Problem< Real > &problem, std::ostream &outStream=std::cout)
Run algorithm on unconstrained problems (Type-U). This is the primary Type-U interface.
virtual void writeName(std::ostream &os) const
Print step name.
Ptr< const AlgorithmState< Real > > getState() const
const Ptr< AlgorithmState< Real > > state_
Algorithm()
Constructor, given a step and a status test.
virtual void writeHeader(std::ostream &os) const
Print iterate header.
virtual void writeExitStatus(std::ostream &os) const
virtual void writeOutput(std::ostream &os, bool write_header=false) const
Print iterate status.
const Ptr< CombinedStatusTest< Real > > status_
virtual void run(Vector< Real > &x, Objective< Real > &sobj, Objective< Real > &nobj, std::ostream &outStream=std::cout)
Run algorithm on unconstrained problems (Type-U). This is the primary Type-U interface.
void setStatusTest(const Ptr< StatusTest< Real > > &status, bool combineStatus=false)
void initialize(const Vector< Real > &x, const Vector< Real > &g)
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 ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
std::string EExitStatusToString(EExitStatus tr)