10#ifndef ROL_TYPEE_STABILIZEDLCLALGORITHM_DEF_H
11#define ROL_TYPEE_STABILIZEDLCLALGORITHM_DEF_H
19template<
typename Real>
26 Real one(1), p1(0.1), p9(0.9), ten(1.e1), oe8(1.e8), oem8(1.e-8);
27 ParameterList& sublist = list.sublist(
"Step").sublist(
"Stabilized LCL");
29 state_->searchSize = sublist.get(
"Initial Penalty Parameter", ten);
30 sigma_ = sublist.get(
"Initial Elastic Penalty Parameter", ten*ten);
33 penaltyUpdate_ = sublist.get(
"Penalty Parameter Growth Factor", ten);
35 sigmaMax_ = sublist.get(
"Maximum Elastic Penalty Parameter", oe8);
36 sigmaUpdate_ = sublist.get(
"Elastic Penalty Parameter Growth Rate", ten);
46 maxit_ = sublist.get(
"Subproblem Iteration Limit", 1000);
47 subStep_ = sublist.get(
"Subproblem Step Type",
"Trust Region");
50 list_.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
52 verbosity_ = list.sublist(
"General").get(
"Output Level", 0);
62 fscale_ = sublist.get(
"Objective Scaling", one);
63 cscale_ = sublist.get(
"Constraint Scaling", one);
66template<
typename Real>
73 std::ostream &outStream ) {
74 const Real one(1), TOL(1.e-2);
101 Ptr<Vector<Real>> ji = x.
clone();
102 Real maxji(0), normji(0);
103 for (
int i = 0; i < c.
dimension(); ++i) {
106 maxji = std::max(normji,maxji);
108 cscale_ = one/std::max(one,maxji);
110 catch (std::exception &e) {
121 const Real oem8(1e-8), oem2(1e-2), two(2), ten(10);
122 state_->searchSize = std::max(oem8,
137 outStream << std::endl;
138 outStream <<
"Stabilized LCL Initialize" << std::endl;
139 outStream <<
"Objective Scaling: " <<
fscale_ << std::endl;
140 outStream <<
"Constraint Scaling: " <<
cscale_ << std::endl;
141 outStream <<
"Penalty Parameter: " <<
state_->searchSize << std::endl;
142 outStream << std::endl;
146template<
typename Real>
148 std::ostream &outStream ) {
166template<
typename Real>
173 std::ostream &outStream ) {
174 const Real one(1), oem2(1e-2);
180 initialize(x,g,emul,eres,alobj,econ,outStream);
182 Ptr<Vector<Real>> u = eres.
clone(), v = eres.
clone(), c = eres.
clone();
183 Ptr<Vector<Real>> gu = emul.
clone(), gv = emul.
clone(), l = emul.
clone();
185 Ptr<ElasticLinearConstraint<Real>> lcon
186 = makePtr<ElasticLinearConstraint<Real>>(makePtrFromRef(x),
187 makePtrFromRef(econ),
188 makePtrFromRef(eres));
189 std::vector<Ptr<Vector<Real>>> vecList = {s,u,v};
190 Ptr<PartitionedVector<Real>> xp = makePtr<PartitionedVector<Real>>(vecList);
191 Ptr<PartitionedVector<Real>> gxp = makePtr<PartitionedVector<Real>>({gs,gu,gv});
192 Ptr<Vector<Real>> lb = u->clone(); lb->zero();
193 std::vector<Ptr<BoundConstraint<Real>>> bndList(3);
194 bndList[0] = makePtr<BoundConstraint<Real>>(); bndList[0]->deactivate();
195 bndList[1] = makePtr<Bounds<Real>>(*lb,
true);
196 bndList[2] = makePtr<Bounds<Real>>(*lb,
true);
197 Ptr<BoundConstraint<Real>> xbnd
198 = makePtr<BoundConstraint_Partitioned<Real>>(bndList,vecList);
199 ParameterList ppa_list;
200 if (c->dimension() == 1)
201 ppa_list.sublist(
"General").sublist(
"Polyhedral Projection").set(
"Type",
"Dai-Fletcher");
203 ppa_list.sublist(
"General").sublist(
"Polyhedral Projection").set(
"Type",
"Semismooth Newton");
208 Ptr<Vector<Real>> b2 = eres.
clone(), xpwa = xp->clone(), mul = emul.
clone();
212 Ptr<TypeB::Algorithm<Real>> algo;
218 lcon->setAnchor(
state_->iterateVec);
225 algo->run(elc,outStream);
242 cnorm = cvec->norm();
245 state_->iterateVec->set(x);
247 state_->constraintVec->set(*cvec);
272 state_->lagmultVec->set(emul);
291template<
typename Real>
293 std::ios_base::fmtflags osFlags(os.flags());
295 os << std::string(114,
'-') << std::endl;
296 os <<
"Stabilized LCL status output definitions" << std::endl << std::endl;
297 os <<
" iter - Number of iterates (steps taken)" << std::endl;
298 os <<
" fval - Objective function value" << std::endl;
299 os <<
" cnorm - Norm of the constraint violation" << std::endl;
300 os <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
301 os <<
" snorm - Norm of the step" << std::endl;
302 os <<
" penalty - Penalty parameter" << std::endl;
303 os <<
" sigma - Elastic Penalty parameter" << std::endl;
304 os <<
" feasTol - Feasibility tolerance" << std::endl;
305 os <<
" optTol - Optimality tolerance" << std::endl;
306 os <<
" #fval - Number of times the objective was computed" << std::endl;
307 os <<
" #grad - Number of times the gradient was computed" << std::endl;
308 os <<
" #cval - Number of times the constraint was computed" << std::endl;
309 os <<
" subIter - Number of iterations to solve subproblem" << std::endl;
310 os << std::string(114,
'-') << std::endl;
313 os << std::setw(6) << std::left <<
"iter";
314 os << std::setw(15) << std::left <<
"fval";
315 os << std::setw(15) << std::left <<
"cnorm";
316 os << std::setw(15) << std::left <<
"gLnorm";
317 os << std::setw(15) << std::left <<
"snorm";
318 os << std::setw(10) << std::left <<
"penalty";
319 os << std::setw(10) << std::left <<
"sigma";
320 os << std::setw(10) << std::left <<
"feasTol";
321 os << std::setw(10) << std::left <<
"optTol";
322 os << std::setw(8) << std::left <<
"#fval";
323 os << std::setw(8) << std::left <<
"#grad";
324 os << std::setw(8) << std::left <<
"#cval";
325 os << std::setw(8) << std::left <<
"subIter";
330template<
typename Real>
332 std::ios_base::fmtflags osFlags(os.flags());
333 os << std::endl <<
"Stabilized LCL Solver (Type E, Equality Constraints)";
335 os <<
"Subproblem Solver: " <<
subStep_ << std::endl;
339template<
typename Real>
341 std::ios_base::fmtflags osFlags(os.flags());
342 os << std::scientific << std::setprecision(6);
345 if (
state_->iter == 0 ) {
347 os << std::setw(6) << std::left <<
state_->iter;
348 os << std::setw(15) << std::left <<
state_->value;
349 os << std::setw(15) << std::left <<
state_->cnorm;
350 os << std::setw(15) << std::left <<
state_->gnorm;
351 os << std::setw(15) << std::left <<
"---";
352 os << std::scientific << std::setprecision(2);
353 os << std::setw(10) << std::left <<
state_->searchSize;
354 os << std::setw(10) << std::left <<
sigma_;
357 os << std::scientific << std::setprecision(6);
358 os << std::setw(8) << std::left <<
state_->nfval;
359 os << std::setw(8) << std::left <<
state_->ngrad;
360 os << std::setw(8) << std::left <<
state_->ncval;
361 os << std::setw(8) << std::left <<
"---";
366 os << std::setw(6) << std::left <<
state_->iter;
367 os << std::setw(15) << std::left <<
state_->value;
368 os << std::setw(15) << std::left <<
state_->cnorm;
369 os << std::setw(15) << std::left <<
state_->gnorm;
370 os << std::setw(15) << std::left <<
state_->snorm;
371 os << std::scientific << std::setprecision(2);
372 os << std::setw(10) << std::left <<
state_->searchSize;
373 os << std::setw(10) << std::left <<
sigma_;
376 os << std::scientific << std::setprecision(6);
377 os << std::setw(8) << std::left <<
state_->nfval;
378 os << std::setw(8) << std::left <<
state_->ngrad;
379 os << std::setw(8) << std::left <<
state_->ncval;
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.
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 the elastic augmented Lagrangian.
void reset(const Vector< Real > &multiplier, Real penaltyParameter, Real sigma)
const Ptr< const Vector< Real > > getConstraintVec(const Vector< Real > &x, Real &tol)
const Ptr< const Vector< Real > > getObjectiveGradient(const Vector< Real > &x, Real &tol)
const Ptr< AugmentedLagrangianObjective< Real > > getAugmentedLagrangian(void) const
int getNumberConstraintEvaluations(void) const
Real getObjectiveValue(const Vector< Real > &x, Real &tol)
void setScaling(const Real fscale=1.0, const Real cscale=1.0)
int getNumberFunctionEvaluations(void) const
int getNumberGradientEvaluations(void) const
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.
const Ptr< Vector< Real > > & getMultiplierVector()
Get the dual constraint space vector.
const Ptr< Constraint< Real > > & getConstraint()
Get the equality constraint.
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...
void check(bool printToStream=false, std::ostream &outStream=std::cout) const
Run vector, linearity and derivative checks for user-supplied vectors, objective function and constra...
const Ptr< Objective< Real > > & getObjective()
Get the objective function.
const Ptr< Vector< Real > > & getResidualVector()
Get the primal constraint space vector.
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...
virtual void edit()
Resume editting optimization problem after finalize has been called.
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
Real optToleranceInitial_
void initialize(Vector< Real > &x, const Vector< Real > &g, const Vector< Real > &l, const Vector< Real > &c, ElasticObjective< Real > &alobj, Constraint< Real > &con, std::ostream &outStream=std::cout)
Real feasToleranceInitial_
virtual void writeOutput(std::ostream &os, const bool print_header=false) const override
Print iterate status.
virtual void writeHeader(std::ostream &os) const override
Print iterate header.
const Ptr< Secant< Real > > secant_
Real optDecreaseExponent_
Real feasDecreaseExponent_
virtual void run(Problem< Real > &problem, std::ostream &outStream=std::cout) override
Run algorithm on equality constrained problems (Type-E). This is the primary Type-E interface.
Real feasIncreaseExponent_
virtual void writeName(std::ostream &os) const override
Print step name.
Real optIncreaseExponent_
StabilizedLCLAlgorithm(ParameterList &list, const Ptr< Secant< Real > > &secant=nullPtr)
Defines the linear algebra or vector space interface.
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.