10#ifndef ROL_TYPEU_ALGORITHM_DEF_H
11#define ROL_TYPEU_ALGORITHM_DEF_H
20template<
typename Real>
28template<
typename Real>
30 if (state_->iterateVec == nullPtr) {
31 state_->iterateVec = x.
clone();
33 state_->iterateVec->set(x);
34 if (state_->stepVec == nullPtr) {
35 state_->stepVec = x.
clone();
37 state_->stepVec->zero();
38 if (state_->gradientVec == nullPtr) {
39 state_->gradientVec = g.
clone();
41 state_->gradientVec->set(g);
42 if (state_->minIterVec == nullPtr) {
43 state_->minIterVec = x.
clone();
45 state_->minIterVec->set(x);
46 state_->minIter = state_->iter;
47 state_->minValue = state_->value;
50template<
typename Real>
59template<
typename Real>
61 std::ostream &outStream ) {
74template<
typename Real>
77 std::ostream &outStream ) {
78 run(x,x.
dual(),obj,outStream);
81template<
typename Real>
86 std::ostream &outStream ) {
87 run(x,x.
dual(),obj,linear_con,linear_mul,linear_mul.
dual(),outStream);
90template<
typename Real>
97 std::ostream &outStream ) {
98 Ptr<Vector<Real>> xfeas = x.
clone(); xfeas->set(x);
100 Ptr<Vector<Real>> s = x.
clone(); s->zero();
102 run(*s,g,*rlc.
transform(makePtrFromRef(obj)),outStream);
107template<
typename Real>
109 std::ios_base::fmtflags osFlags(os.flags());
111 os << std::setw(6) << std::left <<
"iter";
112 os << std::setw(15) << std::left <<
"value";
113 os << std::setw(15) << std::left <<
"gnorm";
114 os << std::setw(15) << std::left <<
"snorm";
115 os << std::setw(10) << std::left <<
"#fval";
116 os << std::setw(10) << std::left <<
"#grad";
121template<
typename Real>
126template<
typename Real>
128 std::ios_base::fmtflags osFlags(os.flags());
129 os << std::scientific << std::setprecision(6);
130 if ( write_header ) writeHeader(os);
131 if ( state_->iter == 0 ) {
133 os << std::setw(6) << std::left << state_->iter;
134 os << std::setw(15) << std::left << state_->value;
135 os << std::setw(15) << std::left << state_->gnorm;
140 os << std::setw(6) << std::left << state_->iter;
141 os << std::setw(15) << std::left << state_->value;
142 os << std::setw(15) << std::left << state_->gnorm;
143 os << std::setw(15) << std::left << state_->snorm;
144 os << std::setw(10) << std::left << state_->nfval;
145 os << std::setw(10) << std::left << state_->ngrad;
151template<
typename Real>
153 std::ios_base::fmtflags osFlags(os.flags());
154 os <<
"Optimization Terminated with Status: ";
160template<
typename Real>
166template<
typename Real>
Contains definitions of custom data types in ROL.
Provides an interface to check two status tests of optimization algorithms.
Defines the general constraint operator interface.
Provides the interface to evaluate objective functions.
const Ptr< Vector< Real > > & getPrimalOptimizationVector()
Get the primal optimization space vector.
const Ptr< Vector< Real > > & getDualOptimizationVector()
Get the dual optimization space vector.
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.
Performs null-space transformation for reducible linear equality constraints.
Ptr< const Vector< Real > > getFeasibleVector(void) const
Ptr< Objective< Real > > transform(const Ptr< Objective< Real > > &obj) const
void project(Vector< Real > &x, const Vector< Real > &y) const
Provides an interface to check status of optimization algorithms.
Algorithm()
Constructor, given a step and a status test.
const Ptr< CombinedStatusTest< Real > > status_
Ptr< const AlgorithmState< Real > > getState() const
void initialize(const Vector< Real > &x, const Vector< Real > &g)
virtual void writeExitStatus(std::ostream &os) const
virtual void writeHeader(std::ostream &os) const
Print iterate header.
virtual void writeName(std::ostream &os) const
Print step name.
void setStatusTest(const Ptr< StatusTest< Real > > &status, bool combineStatus=false)
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 writeOutput(std::ostream &os, const bool write_header=false) const
Print iterate status.
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 plus(const Vector &x)=0
Compute , where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
std::string EExitStatusToString(EExitStatus tr)