10#ifndef ROL_TYPEB_ALGORITHM_DEF_H
11#define ROL_TYPEB_ALGORITHM_DEF_H
19template<
typename Real>
28template<
typename Real>
30 if (
state_->iterateVec == nullPtr) {
33 state_->iterateVec->set(x);
34 if (
state_->stepVec == nullPtr) {
38 if (
state_->gradientVec == nullPtr) {
41 state_->gradientVec->set(g);
42 if (
state_->minIterVec == nullPtr) {
45 state_->minIterVec->set(x);
50template<
typename Real>
54 std::ostream &outStream)
const {
63template<
typename Real>
72template<
typename Real>
74 std::ostream &outStream ) {
89template<
typename Real>
93 std::ostream &outStream ) {
94 run(x,x.
dual(),obj,bnd,outStream);
97template<
typename Real>
103 std::ostream &outStream ) {
104 run(x,x.
dual(),obj,bnd,linear_econ,linear_emul,linear_emul.
dual(),outStream);
107template<
typename Real>
115 std::ostream &outStream ) {
116 ParameterList parlist;
118 run(x,g,obj,bnd,outStream);
121template<
typename Real>
128 std::ostream &outStream ) {
129 run(x,x.
dual(),obj,bnd,linear_icon,linear_imul,linear_ibnd,linear_imul.
dual(),outStream);
132template<
typename Real>
141 std::ostream &outStream ) {
142 Ptr<Vector<Real>> gp = g.
clone(), irp = linear_ires.
clone();
144 makePtrFromRef(x),gp);
147 makePtrFromRef(linear_icon),
148 makePtrFromRef(linear_imul),
149 makePtrFromRef(linear_ibnd),irp);
150 problem.
finalize(
false,
false,outStream);
151 run(problem,outStream);
165template<
typename Real>
174 std::ostream &outStream ) {
175 run(x,x.
dual(),obj,bnd,linear_econ,linear_emul,linear_emul.
dual(),
176 linear_icon,linear_imul,linear_ibnd,linear_imul.
dual(),outStream);
179template<
typename Real>
191 std::ostream &outStream ) {
192 Ptr<Vector<Real>> gp = g.
clone(), erp = linear_eres.
clone(), irp = linear_ires.
clone();
194 makePtrFromRef(x),gp);
197 makePtrFromRef(linear_econ),
198 makePtrFromRef(linear_emul),erp);
200 makePtrFromRef(linear_icon),
201 makePtrFromRef(linear_imul),
202 makePtrFromRef(linear_ibnd),irp);
203 problem.
finalize(
false,
false,outStream);
204 run(problem,outStream);
225template<
typename Real>
227 std::ios_base::fmtflags osFlags(os.flags());
229 os << std::setw(6) << std::left <<
"iter";
230 os << std::setw(15) << std::left <<
"value";
231 os << std::setw(15) << std::left <<
"gnorm";
232 os << std::setw(15) << std::left <<
"snorm";
233 os << std::setw(10) << std::left <<
"#fval";
234 os << std::setw(10) << std::left <<
"#grad";
239template<
typename Real>
244template<
typename Real>
246 std::ios_base::fmtflags osFlags(os.flags());
247 os << std::scientific << std::setprecision(6);
249 if (
state_->iter == 0 ) {
251 os << std::setw(6) << std::left <<
state_->iter;
252 os << std::setw(15) << std::left <<
state_->value;
253 os << std::setw(15) << std::left <<
state_->gnorm;
258 os << std::setw(6) << std::left <<
state_->iter;
259 os << std::setw(15) << std::left <<
state_->value;
260 os << std::setw(15) << std::left <<
state_->gnorm;
261 os << std::setw(15) << std::left <<
state_->snorm;
262 os << std::setw(10) << std::left <<
state_->nfval;
263 os << std::setw(10) << std::left <<
state_->ngrad;
269template<
typename Real>
271 std::ios_base::fmtflags osFlags(os.flags());
272 os <<
"Optimization Terminated with Status: ";
278template<
typename Real>
284template<
typename Real>
Provides the interface to apply upper and lower bound constraints.
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< PolyhedralProjection< Real > > & getPolyhedralProjection()
Get the polyhedral projection object. This is a null pointer if no linear constraints and/or bounds a...
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 addLinearConstraint(std::string name, const Ptr< Constraint< Real > > &linear_econ, const Ptr< Vector< Real > > &linear_emul, const Ptr< Vector< Real > > &linear_eres=nullPtr, bool reset=false)
Add a linear equality constraint.
void addBoundConstraint(const Ptr< BoundConstraint< Real > > &bnd)
Add a bound constraint.
void finalizeIteration()
Transform the optimization variables to the native parameterization after an optimization algorithm h...
const Ptr< Objective< Real > > & getObjective()
Get the objective function.
const Ptr< BoundConstraint< Real > > & getBoundConstraint()
Get the bound constraint.
virtual void finalize(bool lumpConstraints=false, bool printToStream=false, std::ostream &outStream=std::cout)
Tranform user-supplied constraints to consist of only bounds and equalities. Optimization problem can...
Provides an interface to check status of optimization algorithms.
virtual void run(Problem< Real > &problem, std::ostream &outStream=std::cout)
Run algorithm on bound constrained problems (Type-B). This is the primary Type-B interface.
Ptr< PolyhedralProjection< Real > > proj_
void initialize(const Vector< Real > &x, const Vector< Real > &g)
virtual void writeHeader(std::ostream &os) const
Print iterate header.
Real optimalityCriterion(const Vector< Real > &x, const Vector< Real > &g, Vector< Real > &primal, std::ostream &outStream=std::cout) const
Algorithm()
Constructor, given a step and a status test.
virtual void writeExitStatus(std::ostream &os) const
virtual void writeName(std::ostream &os) const
Print step name.
const Ptr< AlgorithmState< Real > > state_
const Ptr< CombinedStatusTest< Real > > status_
virtual void writeOutput(std::ostream &os, const bool write_header=false) const
Print iterate status.
Ptr< const AlgorithmState< Real > > getState() const
void setStatusTest(const Ptr< StatusTest< Real > > &status, const bool combineStatus=false)
Defines the linear algebra or vector space interface.
virtual Real norm() const =0
Returns where .
virtual void set(const Vector &x)
Set where .
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 .
Ptr< PolyhedralProjection< Real > > PolyhedralProjectionFactory(const Vector< Real > &xprim, const Vector< Real > &xdual, const Ptr< BoundConstraint< Real > > &bnd, const Ptr< Constraint< Real > > &con, const Vector< Real > &mul, const Vector< Real > &res, ParameterList &list)
std::string EExitStatusToString(EExitStatus tr)