44#ifndef ROL_TYPEE_AUGMENTEDLAGRANGIANALGORITHM_DEF_H
45#define ROL_TYPEE_AUGMENTEDLAGRANGIANALGORITHM_DEF_H
52template<
typename Real>
59 Real one(1), p1(0.1), p9(0.9), ten(1.e1), oe8(1.e8), oem8(1.e-8);
60 ParameterList& sublist = list.sublist(
"Step").sublist(
"Augmented Lagrangian");
62 state_->searchSize = sublist.get(
"Initial Penalty Parameter", ten);
66 penaltyUpdate_ = sublist.get(
"Penalty Parameter Growth Factor", ten);
78 print_ = sublist.get(
"Print Intermediate Optimization History",
false);
79 maxit_ = sublist.get(
"Subproblem Iteration Limit", 1000);
80 subStep_ = sublist.get(
"Subproblem Step Type",
"Trust Region");
83 list_.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
84 list_.sublist(
"Status Test").set(
"Use Relative Tolerances",
false);
86 verbosity_ = list.sublist(
"General").get(
"Output Level", 0);
94 useRelTol_ = list.sublist(
"Status Test").get(
"Use Relative Tolerances",
false);
97 fscale_ = sublist.get(
"Objective Scaling", one);
98 cscale_ = sublist.get(
"Constraint Scaling", one);
101template<
typename Real>
108 std::ostream &outStream ) {
109 const Real one(1), TOL(1.e-2);
136 Ptr<Vector<Real>> ji = x.
clone();
137 Real maxji(0), normji(0);
138 for (
int i = 0; i < c.
dimension(); ++i) {
141 maxji = std::max(normji,maxji);
143 cscale_ = one/std::max(one,maxji);
145 catch (std::exception &e) {
157 const Real oem8(1e-8), oem2(1e-2), two(2), ten(10);
158 state_->searchSize = std::max(oem8,
174 outStream << std::endl;
175 outStream <<
"Augmented Lagrangian Initialize" << std::endl;
176 outStream <<
"Objective Scaling: " <<
fscale_ << std::endl;
177 outStream <<
"Constraint Scaling: " <<
cscale_ << std::endl;
178 outStream << std::endl;
182template<
typename Real>
189 std::ostream &outStream ) {
190 const Real one(1), oem2(1e-2);
194 state_->searchSize,g,eres,emul,
196 initialize(x,g,emul,eres,alobj,econ,outStream);
197 Ptr<TypeU::Algorithm<Real>> algo;
207 algo->run(x,g,alobj,outStream);
217 state_->iterateVec->set(x);
245 state_->lagmultVec->set(emul);
263template<
typename Real>
265 std::stringstream hist;
267 hist << std::string(114,
'-') << std::endl;
268 hist <<
"Augmented Lagrangian status output definitions" << std::endl << std::endl;
269 hist <<
" iter - Number of iterates (steps taken)" << std::endl;
270 hist <<
" fval - Objective function value" << std::endl;
271 hist <<
" cnorm - Norm of the constraint violation" << std::endl;
272 hist <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
273 hist <<
" snorm - Norm of the step" << std::endl;
274 hist <<
" penalty - Penalty parameter" << std::endl;
275 hist <<
" feasTol - Feasibility tolerance" << std::endl;
276 hist <<
" optTol - Optimality tolerance" << std::endl;
277 hist <<
" #fval - Number of times the objective was computed" << std::endl;
278 hist <<
" #grad - Number of times the gradient was computed" << std::endl;
279 hist <<
" #cval - Number of times the constraint was computed" << std::endl;
280 hist <<
" subIter - Number of iterations to solve subproblem" << std::endl;
281 hist << std::string(114,
'-') << std::endl;
284 hist << std::setw(6) << std::left <<
"iter";
285 hist << std::setw(15) << std::left <<
"fval";
286 hist << std::setw(15) << std::left <<
"cnorm";
287 hist << std::setw(15) << std::left <<
"gLnorm";
288 hist << std::setw(15) << std::left <<
"snorm";
289 hist << std::setw(10) << std::left <<
"penalty";
290 hist << std::setw(10) << std::left <<
"feasTol";
291 hist << std::setw(10) << std::left <<
"optTol";
292 hist << std::setw(8) << std::left <<
"#fval";
293 hist << std::setw(8) << std::left <<
"#grad";
294 hist << std::setw(8) << std::left <<
"#cval";
295 hist << std::setw(8) << std::left <<
"subIter";
300template<
typename Real>
302 std::stringstream hist;
303 hist << std::endl <<
"Augmented Lagrangian Solver (Type E, Equality Constraints)";
305 hist <<
"Subproblem Solver: " <<
subStep_ << std::endl;
309template<
typename Real>
311 std::stringstream hist;
312 hist << std::scientific << std::setprecision(6);
315 if (
state_->iter == 0 ) {
317 hist << std::setw(6) << std::left <<
state_->iter;
318 hist << std::setw(15) << std::left <<
state_->value;
319 hist << std::setw(15) << std::left <<
state_->cnorm;
320 hist << std::setw(15) << std::left <<
state_->gnorm;
321 hist << std::setw(15) << std::left <<
"---";
322 hist << std::scientific << std::setprecision(2);
323 hist << std::setw(10) << std::left <<
state_->searchSize;
326 hist << std::scientific << std::setprecision(6);
327 hist << std::setw(8) << std::left <<
state_->nfval;
328 hist << std::setw(8) << std::left <<
state_->ngrad;
329 hist << std::setw(8) << std::left <<
state_->ncval;
330 hist << std::setw(8) << std::left <<
"---";
335 hist << std::setw(6) << std::left <<
state_->iter;
336 hist << std::setw(15) << std::left <<
state_->value;
337 hist << std::setw(15) << std::left <<
state_->cnorm;
338 hist << std::setw(15) << std::left <<
state_->gnorm;
339 hist << std::setw(15) << std::left <<
state_->snorm;
340 hist << std::scientific << std::setprecision(2);
341 hist << std::setw(10) << std::left <<
state_->searchSize;
344 hist << std::scientific << std::setprecision(6);
345 hist << std::setw(8) << std::left <<
state_->nfval;
346 hist << std::setw(8) << std::left <<
state_->ngrad;
347 hist << std::setw(8) << std::left <<
state_->ncval;
int getNumberConstraintEvaluations(void) const
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
int getNumberGradientEvaluations(void) const
void reset(const Vector< Real > &multiplier, const Real penaltyParameter)
Real getObjectiveValue(const Vector< Real > &x, Real &tol)
void setScaling(const Real fscale=1.0, const Real cscale=1.0)
int getNumberFunctionEvaluations(void) const
const Ptr< const Vector< Real > > getConstraintVec(const Vector< Real > &x, Real &tol)
const Ptr< const Vector< Real > > getObjectiveGradient(const Vector< Real > &x, Real &tol)
void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
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 .
const Ptr< CombinedStatusTest< Real > > status_
Algorithm()
Constructor, given a step and a status test.
const Ptr< AlgorithmState< Real > > state_
Real minPenaltyLowerBound_
virtual void writeName(std::ostream &os) const override
Print step name.
virtual void writeHeader(std::ostream &os) const override
Print iterate header.
Real feasToleranceInitial_
Real feasDecreaseExponent_
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 minPenaltyReciprocal_
Real optIncreaseExponent_
Real optToleranceInitial_
Real feasIncreaseExponent_
Real optDecreaseExponent_
virtual void writeOutput(std::ostream &os, const bool print_header=false) const override
Print iterate status.
virtual void scale(const Real alpha)=0
Compute where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual ROL::Ptr< Vector > basis(const int i) const
Return i-th basis vector.
virtual int dimension() const
Return dimension of the vector space.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
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 writeHeader(std::ostream &os) const override
Print iterate header.
virtual void writeOutput(std::ostream &os, const bool print_header=false) const override
Print iterate status.
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)
virtual void writeName(std::ostream &os) const override
Print step name.
AugmentedLagrangianAlgorithm(ParameterList &list)
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 ROL_EPSILON(void)
Platform-dependent machine epsilon.
Ptr< Algorithm< Real > > AlgorithmFactory(ParameterList &parlist)