44#ifndef ROL_TYPEP_ALGORITHM_DEF_H
45#define ROL_TYPEP_ALGORITHM_DEF_H
53template<
typename Real>
61template<
typename Real>
63 if (
state_->iterateVec == nullPtr)
65 state_->iterateVec->set(x);
66 if (
state_->stepVec == nullPtr)
69 if (
state_->gradientVec == nullPtr)
71 state_->gradientVec->set(g);
72 if (
state_->minIterVec == nullPtr)
74 state_->minIterVec->set(x);
79template<
typename Real>
92 pgstep.axpy(
static_cast<Real
>(-1),x);
95template<
typename Real>
103template<
typename Real>
105 std::ostream &outStream ) {
116 throw Exception::NotImplemented(
">>> ROL::TypeP::Algorithm::run : Optimization problem is not available for Type P problems!");
119template<
typename Real>
123 std::ostream &outStream ) {
124 run(x,x.
dual(),sobj,nobj,outStream);
127template<
typename Real>
129 std::stringstream hist;
131 hist << std::setw(6) << std::left <<
"iter";
132 hist << std::setw(15) << std::left <<
"value";
133 hist << std::setw(15) << std::left <<
"gnorm";
134 hist << std::setw(15) << std::left <<
"snorm";
135 hist << std::setw(10) << std::left <<
"#fval";
136 hist << std::setw(10) << std::left <<
"#grad";
137 hist << std::setw(10) << std::left <<
"#prox";
142template<
typename Real>
147template<
typename Real>
149 std::stringstream hist;
150 hist << std::scientific << std::setprecision(6);
152 if (
state_->iter == 0 ) {
154 hist << std::setw(6) << std::left <<
state_->iter;
155 hist << std::setw(15) << std::left <<
state_->value;
156 hist << std::setw(15) << std::left <<
state_->gnorm;
161 hist << std::setw(6) << std::left <<
state_->iter;
162 hist << std::setw(15) << std::left <<
state_->value;
163 hist << std::setw(15) << std::left <<
state_->gnorm;
164 hist << std::setw(15) << std::left <<
state_->snorm;
165 hist << std::setw(10) << std::left <<
state_->nfval;
166 hist << std::setw(10) << std::left <<
state_->ngrad;
167 hist << std::setw(10) << std::left <<
state_->nprox;
173template<
typename Real>
175 std::stringstream hist;
176 hist <<
"Optimization Terminated with Status: ";
182template<
typename Real>
187template<
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)
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)