44 #ifndef ROL_TYPEU_ALGORITHM_DEF_H
45 #define ROL_TYPEU_ALGORITHM_DEF_H
54 template<
typename Real>
62 template<
typename Real>
64 if (state_->iterateVec == nullPtr) {
65 state_->iterateVec = x.
clone();
67 state_->iterateVec->set(x);
68 if (state_->stepVec == nullPtr) {
69 state_->stepVec = x.
clone();
71 state_->stepVec->zero();
72 if (state_->gradientVec == nullPtr) {
73 state_->gradientVec = g.
clone();
75 state_->gradientVec->set(g);
76 if (state_->minIterVec == nullPtr) {
77 state_->minIterVec = x.
clone();
79 state_->minIterVec->set(x);
80 state_->minIter = state_->iter;
81 state_->minValue = state_->value;
84 template<
typename Real>
93 template<
typename Real>
95 std::ostream &outStream ) {
108 template<
typename Real>
111 std::ostream &outStream ) {
112 run(x,x.
dual(),obj,outStream);
115 template<
typename Real>
120 std::ostream &outStream ) {
121 run(x,x.
dual(),obj,linear_con,linear_mul,linear_mul.
dual(),outStream);
124 template<
typename Real>
131 std::ostream &outStream ) {
132 Ptr<Vector<Real>> xfeas = x.
clone(); xfeas->set(x);
134 Ptr<Vector<Real>> s = x.
clone(); s->zero();
136 run(*s,g,*rlc.
transform(makePtrFromRef(obj)),outStream);
141 template<
typename Real>
143 std::ios_base::fmtflags osFlags(os.flags());
145 os << std::setw(6) << std::left <<
"iter";
146 os << std::setw(15) << std::left <<
"value";
147 os << std::setw(15) << std::left <<
"gnorm";
148 os << std::setw(15) << std::left <<
"snorm";
149 os << std::setw(10) << std::left <<
"#fval";
150 os << std::setw(10) << std::left <<
"#grad";
155 template<
typename Real>
160 template<
typename Real>
162 std::ios_base::fmtflags osFlags(os.flags());
163 os << std::scientific << std::setprecision(6);
164 if ( write_header ) writeHeader(os);
165 if ( state_->iter == 0 ) {
167 os << std::setw(6) << std::left << state_->iter;
168 os << std::setw(15) << std::left << state_->value;
169 os << std::setw(15) << std::left << state_->gnorm;
174 os << std::setw(6) << std::left << state_->iter;
175 os << std::setw(15) << std::left << state_->value;
176 os << std::setw(15) << std::left << state_->gnorm;
177 os << std::setw(15) << std::left << state_->snorm;
178 os << std::setw(10) << std::left << state_->nfval;
179 os << std::setw(10) << std::left << state_->ngrad;
185 template<
typename Real>
187 std::ios_base::fmtflags osFlags(os.flags());
188 os <<
"Optimization Terminated with Status: ";
194 template<
typename Real>
200 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...
const Ptr< Vector< Real > > & getPrimalOptimizationVector()
Get the primal optimization space vector.
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void plus(const Vector &x)=0
Compute , where .
void project(Vector< Real > &x, const Vector< Real > &y) const
Performs null-space transformation for reducible linear equality constraints.
Contains definitions of custom data types in ROL.
Ptr< const AlgorithmState< Real > > getState() const
void initialize(const Vector< Real > &x, const Vector< Real > &g)
Algorithm()
Constructor, given a step and a status test.
Defines the linear algebra or vector space interface.
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.
std::string EExitStatusToString(EExitStatus tr)
const Ptr< Objective< Real > > & getObjective()
Get the objective function.
Ptr< Objective< Real > > transform(const Ptr< Objective< Real >> &obj) const
void setStatusTest(const Ptr< StatusTest< Real >> &status, bool combineStatus=false)
void finalizeIteration()
Transform the optimization variables to the native parameterization after an optimization algorithm h...
Provides an interface to check status of optimization algorithms.
EProblem getProblemType()
Get the optimization problem type (U, B, E, or G).
virtual void writeName(std::ostream &os) const
Print step name.
virtual void writeOutput(std::ostream &os, const bool write_header=false) const
Print iterate status.
Ptr< const Vector< Real > > getFeasibleVector(void) const
virtual void writeExitStatus(std::ostream &os) const
Provides an interface to check two status tests of optimization algorithms.
const Ptr< CombinedStatusTest< Real > > status_
const Ptr< Vector< Real > > & getDualOptimizationVector()
Get the dual optimization space vector.
Defines the general constraint operator interface.
virtual void writeHeader(std::ostream &os) const
Print iterate header.