10#ifndef ROL_TYPEG_AUGMENTEDLAGRANGIANALGORITHM_DEF_H
11#define ROL_TYPEG_AUGMENTEDLAGRANGIANALGORITHM_DEF_H
18template<
typename Real>
25 Real one(1), p1(0.1), p9(0.9), ten(1.e1), oe8(1.e8), oem8(1.e-8);
26 ParameterList& sublist = list.sublist(
"Step").sublist(
"Augmented Lagrangian");
28 state_->searchSize = sublist.get(
"Initial Penalty Parameter", ten);
32 penaltyUpdate_ = sublist.get(
"Penalty Parameter Growth Factor", ten);
44 print_ = sublist.get(
"Print Intermediate Optimization History",
false);
45 maxit_ = sublist.get(
"Subproblem Iteration Limit", 1000);
46 subStep_ = sublist.get(
"Subproblem Step Type",
"Trust Region");
49 list_.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
50 list_.sublist(
"Status Test").set(
"Use Relative Tolerances",
false);
52 verbosity_ = list.sublist(
"General").get(
"Output Level", 0);
60 useRelTol_ = list.sublist(
"Status Test").get(
"Use Relative Tolerances",
false);
63 fscale_ = sublist.get(
"Objective Scaling", one);
64 cscale_ = sublist.get(
"Constraint Scaling", one);
67template<
typename Real>
75 std::ostream &outStream ) {
77 if (
proj_ == nullPtr) {
78 proj_ = makePtr<PolyhedralProjection<Real>>(makePtrFromRef(bnd));
81 proj_->project(x,outStream);
83 const Real one(1), TOL(1.e-2);
110 Ptr<Vector<Real>> ji = x.
clone();
111 Real maxji(0), normji(0);
112 for (
int i = 0; i < c.
dimension(); ++i) {
115 maxji = std::max(normji,maxji);
117 cscale_ = one/std::max(one,maxji);
119 catch (std::exception &e) {
127 proj_->project(x,outStream);
134 const Real oem8(1e-8), oem2(1e-2), two(2), ten(10);
135 state_->searchSize = std::max(oem8,
152 outStream << std::endl;
153 outStream <<
"Augmented Lagrangian Initialize" << std::endl;
154 outStream <<
"Objective Scaling: " <<
fscale_ << std::endl;
155 outStream <<
"Constraint Scaling: " <<
cscale_ << std::endl;
156 outStream <<
"Penalty Parameter: " <<
state_->searchSize << std::endl;
157 outStream << std::endl;
161template<
typename Real>
169 std::ostream &outStream ) {
170 const Real one(1), oem2(1e-2);
174 state_->searchSize,g,eres,emul,
176 initialize(x,g,emul,eres,alobj,bnd,econ,outStream);
177 Ptr<TypeB::Algorithm<Real>> algo;
188 *
proj_->getMultiplier(),*
proj_->getResidual(),
190 else algo->run(x,g,alobj,bnd,outStream);
200 state_->iterateVec->set(x);
209 proj_->project(x,outStream);
231 state_->lagmultVec->set(emul);
249template<
typename Real>
251 std::ios_base::fmtflags osFlags(os.flags());
253 os << std::string(114,
'-') << std::endl;
254 os <<
"Augmented Lagrangian status output definitions" << std::endl << std::endl;
255 os <<
" iter - Number of iterates (steps taken)" << std::endl;
256 os <<
" fval - Objective function value" << std::endl;
257 os <<
" cnorm - Norm of the constraint violation" << std::endl;
258 os <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
259 os <<
" snorm - Norm of the step" << std::endl;
260 os <<
" penalty - Penalty parameter" << std::endl;
261 os <<
" feasTol - Feasibility tolerance" << std::endl;
262 os <<
" optTol - Optimality tolerance" << std::endl;
263 os <<
" #fval - Number of times the objective was computed" << std::endl;
264 os <<
" #grad - Number of times the gradient was computed" << std::endl;
265 os <<
" #cval - Number of times the constraint was computed" << std::endl;
266 os <<
" subIter - Number of iterations to solve subproblem" << std::endl;
267 os << std::string(114,
'-') << std::endl;
270 os << std::setw(6) << std::left <<
"iter";
271 os << std::setw(15) << std::left <<
"fval";
272 os << std::setw(15) << std::left <<
"cnorm";
273 os << std::setw(15) << std::left <<
"gLnorm";
274 os << std::setw(15) << std::left <<
"snorm";
275 os << std::setw(10) << std::left <<
"penalty";
276 os << std::setw(10) << std::left <<
"feasTol";
277 os << std::setw(10) << std::left <<
"optTol";
278 os << std::setw(8) << std::left <<
"#fval";
279 os << std::setw(8) << std::left <<
"#grad";
280 os << std::setw(8) << std::left <<
"#cval";
281 os << std::setw(8) << std::left <<
"subIter";
286template<
typename Real>
288 std::ios_base::fmtflags osFlags(os.flags());
289 os << std::endl <<
"Augmented Lagrangian Solver (Type G, General Constraints)";
291 os <<
"Subproblem Solver: " <<
subStep_ << std::endl;
295template<
typename Real>
297 std::ios_base::fmtflags osFlags(os.flags());
298 os << std::scientific << std::setprecision(6);
301 if (
state_->iter == 0 ) {
303 os << std::setw(6) << std::left <<
state_->iter;
304 os << std::setw(15) << std::left <<
state_->value;
305 os << std::setw(15) << std::left <<
state_->cnorm;
306 os << std::setw(15) << std::left <<
state_->gnorm;
307 os << std::setw(15) << std::left <<
"---";
308 os << std::scientific << std::setprecision(2);
309 os << std::setw(10) << std::left <<
state_->searchSize;
312 os << std::scientific << std::setprecision(6);
313 os << std::setw(8) << std::left <<
state_->nfval;
314 os << std::setw(8) << std::left <<
state_->ngrad;
315 os << std::setw(8) << std::left <<
state_->ncval;
316 os << std::setw(8) << std::left <<
"---";
321 os << std::setw(6) << std::left <<
state_->iter;
322 os << std::setw(15) << std::left <<
state_->value;
323 os << std::setw(15) << std::left <<
state_->cnorm;
324 os << std::setw(15) << std::left <<
state_->gnorm;
325 os << std::setw(15) << std::left <<
state_->snorm;
326 os << std::scientific << std::setprecision(2);
327 os << std::setw(10) << std::left <<
state_->searchSize;
330 os << std::scientific << std::setprecision(6);
331 os << std::setw(8) << std::left <<
state_->nfval;
332 os << std::setw(8) << std::left <<
state_->ngrad;
333 os << std::setw(8) << std::left <<
state_->ncval;
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.
Provides the interface to evaluate the augmented Lagrangian.
void reset(const Vector< Real > &multiplier, const Real penaltyParameter)
int getNumberGradientEvaluations(void) const
void update(const Vector< Real > &x, UpdateType type, int iter=-1)
int getNumberFunctionEvaluations(void) const
Real getObjectiveValue(const Vector< Real > &x, Real &tol)
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
void setScaling(const Real fscale=1.0, const Real cscale=1.0)
const Ptr< const Vector< Real > > getObjectiveGradient(const Vector< Real > &x, Real &tol)
const Ptr< const Vector< Real > > getConstraintVec(const Vector< Real > &x, Real &tol)
int getNumberConstraintEvaluations(void) const
Provides the interface to apply upper and lower bound constraints.
Provides an interface to check status of optimization algorithms for problems with equality constrain...
Defines the general constraint operator interface.
virtual void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the adjoint of the the constraint Jacobian at , , to vector .
Provides the interface to evaluate objective functions.
Provides interface for and implements limited-memory secant operators.
Algorithm()
Constructor, given a step and a status test.
void initialize(const Vector< Real > &x, const Vector< Real > &g, const Vector< Real > &mul, const Vector< Real > &c)
virtual void writeExitStatus(std::ostream &os) const
const Ptr< CombinedStatusTest< Real > > status_
Ptr< PolyhedralProjection< Real > > proj_
const Ptr< AlgorithmState< Real > > state_
Real optIncreaseExponent_
void writeOutput(std::ostream &os, const bool print_header=false) const override
Print iterate status.
Real optDecreaseExponent_
Real feasDecreaseExponent_
AugmentedLagrangianAlgorithm(ParameterList &list, const Ptr< Secant< Real > > &secant=nullPtr)
Real minPenaltyLowerBound_
void writeName(std::ostream &os) const override
Print step name.
void run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, Constraint< Real > &econ, Vector< Real > &emul, const Vector< Real > &eres, std::ostream &outStream=std::cout) override
Run algorithm on general constrained problems (Type-G). This is the primary Type-G interface.
Real feasIncreaseExponent_
void initialize(Vector< Real > &x, const Vector< Real > &g, const Vector< Real > &l, const Vector< Real > &c, AugmentedLagrangianObjective< Real > &alobj, BoundConstraint< Real > &bnd, Constraint< Real > &con, std::ostream &outStream=std::cout)
Real feasToleranceInitial_
const Ptr< Secant< Real > > secant_
Real minPenaltyReciprocal_
void writeHeader(std::ostream &os) const override
Print iterate header.
Real optToleranceInitial_
Defines the linear algebra or vector space interface.
virtual Real norm() const =0
Returns where .
virtual void set(const Vector &x)
Set where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual int dimension() const
Return dimension of the vector space.
virtual ROL::Ptr< Vector > basis(const int i) const
Return i-th basis vector.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Ptr< Algorithm< Real > > AlgorithmFactory(ParameterList &parlist, const Ptr< Secant< Real > > &secant=nullPtr)
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.