10#ifndef ROL_TYPEE_AUGMENTEDLAGRANGIANALGORITHM_DEF_H
11#define ROL_TYPEE_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>
74 std::ostream &outStream ) {
75 const Real one(1), TOL(1.e-2);
102 Ptr<Vector<Real>> ji = x.
clone();
103 Real maxji(0), normji(0);
104 for (
int i = 0; i < c.
dimension(); ++i) {
107 maxji = std::max(normji,maxji);
109 cscale_ = one/std::max(one,maxji);
111 catch (std::exception &e) {
123 const Real oem8(1e-8), oem2(1e-2), two(2), ten(10);
124 state_->searchSize = std::max(oem8,
140 outStream << std::endl;
141 outStream <<
"Augmented Lagrangian Initialize" << std::endl;
142 outStream <<
"Objective Scaling: " <<
fscale_ << std::endl;
143 outStream <<
"Constraint Scaling: " <<
cscale_ << std::endl;
144 outStream << std::endl;
148template<
typename Real>
155 std::ostream &outStream ) {
156 const Real one(1), oem2(1e-2);
160 state_->searchSize,g,eres,emul,
162 initialize(x,g,emul,eres,alobj,econ,outStream);
163 Ptr<TypeU::Algorithm<Real>> algo;
173 algo->run(x,g,alobj,outStream);
183 state_->iterateVec->set(x);
211 state_->lagmultVec->set(emul);
229template<
typename Real>
231 std::ios_base::fmtflags osFlags(os.flags());
233 os << std::string(114,
'-') << std::endl;
234 os <<
"Augmented Lagrangian status output definitions" << std::endl << std::endl;
235 os <<
" iter - Number of iterates (steps taken)" << std::endl;
236 os <<
" fval - Objective function value" << std::endl;
237 os <<
" cnorm - Norm of the constraint violation" << std::endl;
238 os <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
239 os <<
" snorm - Norm of the step" << std::endl;
240 os <<
" penalty - Penalty parameter" << std::endl;
241 os <<
" feasTol - Feasibility tolerance" << std::endl;
242 os <<
" optTol - Optimality tolerance" << std::endl;
243 os <<
" #fval - Number of times the objective was computed" << std::endl;
244 os <<
" #grad - Number of times the gradient was computed" << std::endl;
245 os <<
" #cval - Number of times the constraint was computed" << std::endl;
246 os <<
" subIter - Number of iterations to solve subproblem" << std::endl;
247 os << std::string(114,
'-') << std::endl;
250 os << std::setw(6) << std::left <<
"iter";
251 os << std::setw(15) << std::left <<
"fval";
252 os << std::setw(15) << std::left <<
"cnorm";
253 os << std::setw(15) << std::left <<
"gLnorm";
254 os << std::setw(15) << std::left <<
"snorm";
255 os << std::setw(10) << std::left <<
"penalty";
256 os << std::setw(10) << std::left <<
"feasTol";
257 os << std::setw(10) << std::left <<
"optTol";
258 os << std::setw(8) << std::left <<
"#fval";
259 os << std::setw(8) << std::left <<
"#grad";
260 os << std::setw(8) << std::left <<
"#cval";
261 os << std::setw(8) << std::left <<
"subIter";
266template<
typename Real>
268 std::ios_base::fmtflags osFlags(os.flags());
269 os << std::endl <<
"Augmented Lagrangian Solver (Type E, Equality Constraints)";
271 os <<
"Subproblem Solver: " <<
subStep_ << std::endl;
275template<
typename Real>
277 std::ios_base::fmtflags osFlags(os.flags());
278 os << std::scientific << std::setprecision(6);
281 if (
state_->iter == 0 ) {
283 os << std::setw(6) << std::left <<
state_->iter;
284 os << std::setw(15) << std::left <<
state_->value;
285 os << std::setw(15) << std::left <<
state_->cnorm;
286 os << std::setw(15) << std::left <<
state_->gnorm;
287 os << std::setw(15) << std::left <<
"---";
288 os << std::scientific << std::setprecision(2);
289 os << std::setw(10) << std::left <<
state_->searchSize;
292 os << std::scientific << std::setprecision(6);
293 os << std::setw(8) << std::left <<
state_->nfval;
294 os << std::setw(8) << std::left <<
state_->ngrad;
295 os << std::setw(8) << std::left <<
state_->ncval;
296 os << std::setw(8) << std::left <<
"---";
301 os << std::setw(6) << std::left <<
state_->iter;
302 os << std::setw(15) << std::left <<
state_->value;
303 os << std::setw(15) << std::left <<
state_->cnorm;
304 os << std::setw(15) << std::left <<
state_->gnorm;
305 os << std::setw(15) << std::left <<
state_->snorm;
306 os << std::scientific << std::setprecision(2);
307 os << std::setw(10) << std::left <<
state_->searchSize;
310 os << std::scientific << std::setprecision(6);
311 os << std::setw(8) << std::left <<
state_->nfval;
312 os << std::setw(8) << std::left <<
state_->ngrad;
313 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 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.
const Ptr< CombinedStatusTest< Real > > status_
Algorithm()
Constructor, given a step and a status test.
const Ptr< AlgorithmState< Real > > state_
Provides interface for and implements limited-memory secant operators.
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
virtual void writeName(std::ostream &os) const override
Print step name.
Real minPenaltyLowerBound_
virtual void writeHeader(std::ostream &os) const override
Print iterate header.
Real feasDecreaseExponent_
AugmentedLagrangianAlgorithm(ParameterList &list, const Ptr< Secant< Real > > &secant=nullPtr)
void initialize(Vector< Real > &x, const Vector< Real > &g, const Vector< Real > &l, const Vector< Real > &c, AugmentedLagrangianObjective< Real > &alobj, Constraint< Real > &con, std::ostream &outStream=std::cout)
Real optIncreaseExponent_
Real feasToleranceInitial_
const Ptr< Secant< Real > > secant_
Real optDecreaseExponent_
Real minPenaltyReciprocal_
virtual void writeOutput(std::ostream &os, const bool print_header=false) const override
Print iterate status.
Real optToleranceInitial_
virtual void run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, Constraint< Real > &econ, Vector< Real > &emul, const Vector< Real > &eres, std::ostream &outStream=std::cout) override
Real feasIncreaseExponent_
Defines the linear algebra or vector space interface.
virtual void scale(const Real alpha)=0
Compute 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.