44 #ifndef ROL_TYPEP_ALGORITHM_DEF_H
45 #define ROL_TYPEP_ALGORITHM_DEF_H
53 template<
typename Real>
61 template<
typename Real>
63 if (state_->iterateVec == nullPtr)
64 state_->iterateVec = x.
clone();
65 state_->iterateVec->set(x);
66 if (state_->stepVec == nullPtr)
67 state_->stepVec = x.
clone();
68 state_->stepVec->zero();
69 if (state_->gradientVec == nullPtr)
70 state_->gradientVec = g.
clone();
71 state_->gradientVec->set(g);
72 if (state_->minIterVec == nullPtr)
73 state_->minIterVec = x.
clone();
74 state_->minIterVec->set(x);
75 state_->minIter = state_->iter;
76 state_->minValue = state_->value;
79 template<
typename Real>
89 nobj.
prox(pgiter,pgstep,t,tol);
92 pgstep.
axpy(static_cast<Real>(-1),x);
95 template<
typename Real>
100 status_->add(status);
103 template<
typename Real>
105 std::ostream &outStream ) {
116 throw Exception::NotImplemented(
">>> ROL::TypeP::Algorithm::run : Optimization problem is not available for Type P problems!");
119 template<
typename Real>
123 std::ostream &outStream ) {
124 run(x,x.
dual(),sobj,nobj,outStream);
127 template<
typename Real>
129 std::ios_base::fmtflags osFlags(os.flags());
131 os << std::setw(6) << std::left <<
"iter";
132 os << std::setw(15) << std::left <<
"value";
133 os << std::setw(15) << std::left <<
"gnorm";
134 os << std::setw(15) << std::left <<
"snorm";
135 os << std::setw(10) << std::left <<
"#fval";
136 os << std::setw(10) << std::left <<
"#grad";
137 os << std::setw(10) << std::left <<
"#prox";
142 template<
typename Real>
147 template<
typename Real>
149 std::ios_base::fmtflags osFlags(os.flags());
150 os << std::scientific << std::setprecision(6);
151 if ( write_header ) writeHeader(os);
152 if ( state_->iter == 0 ) {
154 os << std::setw(6) << std::left << state_->iter;
155 os << std::setw(15) << std::left << state_->value;
156 os << std::setw(15) << std::left << state_->gnorm;
161 os << std::setw(6) << std::left << state_->iter;
162 os << std::setw(15) << std::left << state_->value;
163 os << std::setw(15) << std::left << state_->gnorm;
164 os << std::setw(15) << std::left << state_->snorm;
165 os << std::setw(10) << std::left << state_->nfval;
166 os << std::setw(10) << std::left << state_->ngrad;
167 os << std::setw(10) << std::left << state_->nprox;
173 template<
typename Real>
175 std::ios_base::fmtflags osFlags(os.flags());
176 os <<
"Optimization Terminated with Status: ";
182 template<
typename Real>
187 template<
typename Real>
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...
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Contains definitions of custom data types in ROL.
virtual void writeOutput(std::ostream &os, bool write_header=false) const
Print iterate status.
virtual void prox(Vector< Real > &Pv, const Vector< Real > &v, Real t, Real &tol)
void pgstep(Vector< Real > &pgiter, Vector< Real > &pgstep, Objective< Real > &nobj, const Vector< Real > &x, const Vector< Real > &dg, Real t, Real &tol) const
Defines the linear algebra or vector space interface.
void setStatusTest(const Ptr< StatusTest< Real >> &status, bool combineStatus=false)
virtual void writeHeader(std::ostream &os) const
Print iterate header.
virtual void writeName(std::ostream &os) const
Print step name.
std::string EExitStatusToString(EExitStatus tr)
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.
Provides an interface to check status of optimization algorithms.
const Ptr< CombinedStatusTest< Real > > status_
virtual void set(const Vector &x)
Set where .
Provides an interface to check two status tests of optimization algorithms.
virtual void writeExitStatus(std::ostream &os) 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.
void initialize(const Vector< Real > &x, const Vector< Real > &g)
Algorithm()
Constructor, given a step and a status test.
Ptr< const AlgorithmState< Real > > getState() const