10#ifndef ROL_TYPEG_STABILIZEDLCLALGORITHM_DEF_H
11#define ROL_TYPEG_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>
74 std::ostream &outStream ) {
76 if (
proj_ == nullPtr) {
77 proj_ = makePtr<PolyhedralProjection<Real>>(makePtrFromRef(bnd));
80 proj_->project(x,outStream);
82 const Real one(1), TOL(1.e-2);
109 Ptr<Vector<Real>> ji = x.
clone();
110 Real maxji(0), normji(0);
111 for (
int i = 0; i < c.
dimension(); ++i) {
114 maxji = std::max(normji,maxji);
116 cscale_ = one/std::max(one,maxji);
118 catch (std::exception &e) {
126 proj_->project(x,outStream);
133 const Real oem8(1e-8), oem2(1e-2), two(2), ten(10);
134 state_->searchSize = std::max(oem8,
149 outStream << std::endl;
150 outStream <<
"Stabilized LCL Initialize" << std::endl;
151 outStream <<
"Objective Scaling: " <<
fscale_ << std::endl;
152 outStream <<
"Constraint Scaling: " <<
cscale_ << std::endl;
153 outStream <<
"Penalty Parameter: " <<
state_->searchSize << std::endl;
154 outStream << std::endl;
158template<
typename Real>
160 std::ostream &outStream ) {
179template<
typename Real>
187 std::ostream &outStream ) {
188 const Real one(1), oem2(1e-2);
194 initialize(x,g,emul,eres,alobj,bnd,econ,outStream);
196 Ptr<Vector<Real>> u = eres.
clone(), v = eres.
clone(), c = eres.
clone();
197 Ptr<Vector<Real>> gu = emul.
clone(), gv = emul.
clone(), l = emul.
clone();
199 Ptr<ElasticLinearConstraint<Real>> lcon
200 = makePtr<ElasticLinearConstraint<Real>>(makePtrFromRef(x),
201 makePtrFromRef(econ),
202 makePtrFromRef(eres));
203 std::vector<Ptr<Vector<Real>>> vecList = {s,u,v};
204 Ptr<PartitionedVector<Real>> xp = makePtr<PartitionedVector<Real>>(vecList);
205 Ptr<PartitionedVector<Real>> gxp = makePtr<PartitionedVector<Real>>({gs,gu,gv});
206 Ptr<Vector<Real>> lb = u->clone(); lb->zero();
207 std::vector<Ptr<BoundConstraint<Real>>> bndList(3);
208 bndList[0] = makePtrFromRef(bnd);
209 bndList[1] = makePtr<Bounds<Real>>(*lb,
true);
210 bndList[2] = makePtr<Bounds<Real>>(*lb,
true);
211 Ptr<BoundConstraint<Real>> xbnd
212 = makePtr<BoundConstraint_Partitioned<Real>>(bndList,vecList);
213 ParameterList ppa_list;
214 if (c->dimension() == 1)
215 ppa_list.sublist(
"General").sublist(
"Polyhedral Projection").set(
"Type",
"Dai-Fletcher");
217 ppa_list.sublist(
"General").sublist(
"Polyhedral Projection").set(
"Type",
"Semismooth Newton");
225 Ptr<TypeB::Algorithm<Real>> algo;
231 lcon->setAnchor(
state_->iterateVec);
238 algo->run(elc,outStream);
255 cnorm = cvec->norm();
258 state_->iterateVec->set(x);
260 state_->constraintVec->set(*cvec);
272 proj_->project(x,outStream);
289 state_->lagmultVec->set(emul);
308template<
typename Real>
310 std::ios_base::fmtflags osFlags(os.flags());
312 os << std::string(114,
'-') << std::endl;
313 os <<
"Stabilized LCL status output definitions" << std::endl << std::endl;
314 os <<
" iter - Number of iterates (steps taken)" << std::endl;
315 os <<
" fval - Objective function value" << std::endl;
316 os <<
" cnorm - Norm of the constraint violation" << std::endl;
317 os <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
318 os <<
" snorm - Norm of the step" << std::endl;
319 os <<
" penalty - Penalty parameter" << std::endl;
320 os <<
" sigma - Elastic Penalty parameter" << std::endl;
321 os <<
" feasTol - Feasibility tolerance" << std::endl;
322 os <<
" optTol - Optimality tolerance" << std::endl;
323 os <<
" #fval - Number of times the objective was computed" << std::endl;
324 os <<
" #grad - Number of times the gradient was computed" << std::endl;
325 os <<
" #cval - Number of times the constraint was computed" << std::endl;
326 os <<
" subIter - Number of iterations to solve subproblem" << std::endl;
327 os << std::string(114,
'-') << std::endl;
330 os << std::setw(6) << std::left <<
"iter";
331 os << std::setw(15) << std::left <<
"fval";
332 os << std::setw(15) << std::left <<
"cnorm";
333 os << std::setw(15) << std::left <<
"gLnorm";
334 os << std::setw(15) << std::left <<
"snorm";
335 os << std::setw(10) << std::left <<
"penalty";
336 os << std::setw(10) << std::left <<
"sigma";
337 os << std::setw(10) << std::left <<
"feasTol";
338 os << std::setw(10) << std::left <<
"optTol";
339 os << std::setw(8) << std::left <<
"#fval";
340 os << std::setw(8) << std::left <<
"#grad";
341 os << std::setw(8) << std::left <<
"#cval";
342 os << std::setw(8) << std::left <<
"subIter";
347template<
typename Real>
349 std::ios_base::fmtflags osFlags(os.flags());
350 os << std::endl <<
"Stabilized LCL Solver (Type G, General Constraints)";
352 os <<
"Subproblem Solver: " <<
subStep_ << std::endl;
356template<
typename Real>
358 std::ios_base::fmtflags osFlags(os.flags());
359 os << std::scientific << std::setprecision(6);
362 if (
state_->iter == 0 ) {
364 os << std::setw(6) << std::left <<
state_->iter;
365 os << std::setw(15) << std::left <<
state_->value;
366 os << std::setw(15) << std::left <<
state_->cnorm;
367 os << std::setw(15) << std::left <<
state_->gnorm;
368 os << std::setw(15) << std::left <<
"---";
369 os << std::scientific << std::setprecision(2);
370 os << std::setw(10) << std::left <<
state_->searchSize;
371 os << std::setw(10) << std::left <<
sigma_;
374 os << std::scientific << std::setprecision(6);
375 os << std::setw(8) << std::left <<
state_->nfval;
376 os << std::setw(8) << std::left <<
state_->ngrad;
377 os << std::setw(8) << std::left <<
state_->ncval;
378 os << std::setw(8) << std::left <<
"---";
383 os << std::setw(6) << std::left <<
state_->iter;
384 os << std::setw(15) << std::left <<
state_->value;
385 os << std::setw(15) << std::left <<
state_->cnorm;
386 os << std::setw(15) << std::left <<
state_->gnorm;
387 os << std::setw(15) << std::left <<
state_->snorm;
388 os << std::scientific << std::setprecision(2);
389 os << std::setw(10) << std::left <<
state_->searchSize;
390 os << std::setw(10) << std::left <<
sigma_;
393 os << std::scientific << std::setprecision(6);
394 os << std::setw(8) << std::left <<
state_->nfval;
395 os << std::setw(8) << std::left <<
state_->ngrad;
396 os << std::setw(8) << std::left <<
state_->ncval;
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.
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 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 setProjectionAlgorithm(ParameterList &parlist)
Set polyhedral projection algorithm.
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< BoundConstraint< Real > > & getBoundConstraint()
Get the bound constraint.
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.
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 optDecreaseExponent_
virtual void run(Problem< Real > &problem, std::ostream &outStream=std::cout) override
Run algorithm on general constrained problems (Type-G). This is the primary Type-G interface.
void initialize(Vector< Real > &x, const Vector< Real > &g, const Vector< Real > &l, const Vector< Real > &c, ElasticObjective< Real > &alobj, BoundConstraint< Real > &bnd, Constraint< Real > &con, std::ostream &outStream=std::cout)
Real optIncreaseExponent_
Real feasIncreaseExponent_
virtual void writeName(std::ostream &os) const override
Print step name.
Real feasDecreaseExponent_
Real optToleranceInitial_
StabilizedLCLAlgorithm(ParameterList &list, const Ptr< Secant< Real > > &secant=nullPtr)
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.
Real feasToleranceInitial_
const Ptr< Secant< Real > > secant_
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.