10 #ifndef ROL_TYPEE_STABILIZEDLCLALGORITHM_DEF_H
11 #define ROL_TYPEE_STABILIZEDLCLALGORITHM_DEF_H
19 template<
typename Real>
21 : TypeE::
Algorithm<Real>::
Algorithm(), secant_(secant), list_(list), subproblemIter_(0) {
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);
66 template<
typename Real>
73 std::ostream &outStream ) {
74 const Real one(1), TOL(1.e-2);
75 Real tol = std::sqrt(ROL_EPSILON<Real>());
90 state_->cnorm = state_->constraintVec->norm();
98 if (useDefaultScaling_) {
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) {
117 state_->gnorm = state_->gradientVec->norm()/std::min(fscale_,cscale_);
120 if (useDefaultInitPen_) {
121 const Real oem8(1e-8), oem2(1e-2), two(2), ten(10);
122 state_->searchSize = std::max(oem8,
123 std::min(ten*std::max(one,std::abs(fscale_*state_->value))
124 / std::max(one,std::pow(cscale_*state_->cnorm,two)),oem2*maxPenaltyParam_));
127 optTolerance_ = std::max<Real>(TOL*outerOptTolerance_,
128 optToleranceInitial_);
130 feasTolerance_ = std::max<Real>(TOL*outerFeasTolerance_,
131 feasToleranceInitial_);
134 alobj.
reset(l,state_->searchSize,sigma_);
136 if (verbosity_ > 1) {
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;
146 template<
typename Real>
148 std::ostream &outStream ) {
151 problem.
finalize(
true,verbosity_>3,outStream);
166 template<
typename Real>
173 std::ostream &outStream ) {
174 const Real one(1), oem2(1e-2);
175 Real tol(std::sqrt(ROL_EPSILON<Real>())), cnorm(0), lnorm;;
178 state_->searchSize,sigma_,g,eres,emul,
179 scaleLagrangian_,HessianApprox_);
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");
207 elc.
finalize(
false,verbosity_>2,outStream);
208 Ptr<Vector<Real>> b2 = eres.
clone(), xpwa = xp->clone(), mul = emul.
clone();
212 Ptr<TypeB::Algorithm<Real>> algo;
215 if (verbosity_ > 0) writeOutput(outStream,
true);
217 while (status_->check(*state_)) {
218 lcon->setAnchor(state_->iterateVec);
219 if (verbosity_ > 3) elc.
check(
true,outStream);
222 list_.sublist(
"Status Test").set(
"Gradient Tolerance",optTolerance_);
223 list_.sublist(
"Status Test").set(
"Step Tolerance",1.e-6*optTolerance_);
224 algo = TypeB::AlgorithmFactory<Real>(list_,secant_);
225 algo->run(elc,outStream);
229 subproblemIter_ = algo->getState()->iter;
235 state_->stepVec->set(x);
236 state_->stepVec->axpy(-one,*state_->iterateVec);
237 state_->snorm = state_->stepVec->norm();
242 cnorm = cvec->norm();
243 if ( cscale_*cnorm < feasTolerance_ ) {
245 state_->iterateVec->set(x);
247 state_->constraintVec->set(*cvec);
248 state_->cnorm = cnorm;
252 emul.
axpy(state_->searchSize*cscale_,state_->constraintVec->dual());
255 if (scaleLagrangian_) state_->gradientVec->scale(state_->searchSize);
257 state_->gradientVec->axpy(-cscale_,*gs);
258 state_->gnorm = state_->gradientVec->norm();
262 sigma_ = std::min(one+lnorm,sigmaMax_)/(one+state_->searchSize);
264 optTolerance_ = std::max(oem2*outerOptTolerance_,
265 optTolerance_/(one + std::pow(state_->searchSize,optIncreaseExponent_)));
267 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
268 feasTolerance_/(one + std::pow(state_->searchSize,feasIncreaseExponent_)));
271 state_->snorm += lnorm + state_->searchSize*cscale_*state_->cnorm;
272 state_->lagmultVec->set(emul);
276 state_->searchSize = std::min(penaltyUpdate_*state_->searchSize,maxPenaltyParam_);
277 sigma_ /= sigmaUpdate_;
278 optTolerance_ = std::max(oem2*outerOptTolerance_,
279 optToleranceInitial_/(one + std::pow(state_->searchSize,optDecreaseExponent_)));
280 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
281 feasToleranceInitial_/(one + std::pow(state_->searchSize,feasDecreaseExponent_)));
283 alobj.
reset(emul,state_->searchSize,sigma_);
286 if (verbosity_ > 0) writeOutput(outStream,printHeader_);
291 template<
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";
330 template<
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;
339 template<
typename Real>
341 std::ios_base::fmtflags osFlags(os.flags());
342 os << std::scientific << std::setprecision(6);
343 if ( state_->iter == 0 ) writeName(os);
344 if ( print_header ) writeHeader(os);
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_;
355 os << std::setw(10) << std::left << std::max(feasTolerance_,outerFeasTolerance_);
356 os << std::setw(10) << std::left << std::max(optTolerance_,outerOptTolerance_);
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_;
374 os << std::setw(10) << std::left << feasTolerance_;
375 os << std::setw(10) << std::left << optTolerance_;
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;
380 os << std::setw(8) << std::left << subproblemIter_;
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...
Provides the interface to evaluate objective functions.
const Ptr< Constraint< Real > > & getConstraint()
Get the equality constraint.
const Ptr< Vector< Real > > & getPrimalOptimizationVector()
Get the primal optimization space vector.
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual int dimension() const
Return dimension of the vector space.
void addBoundConstraint(const Ptr< BoundConstraint< Real >> &bnd)
Add a bound constraint.
const Ptr< const Vector< Real > > getConstraintVec(const Vector< Real > &x, Real &tol)
virtual ROL::Ptr< Vector > basis(const int i) const
Return i-th basis vector.
Real optIncreaseExponent_
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
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.
int getNumberFunctionEvaluations(void) const
const Ptr< AugmentedLagrangianObjective< Real > > getAugmentedLagrangian(void) const
Defines the linear algebra or vector space interface.
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...
Real getObjectiveValue(const Vector< Real > &x, Real &tol)
Provides an interface to check status of optimization algorithms for problems with equality constrain...
void setScaling(const Real fscale=1.0, const Real cscale=1.0)
Provides the interface to evaluate the elastic augmented Lagrangian.
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)
const Ptr< Objective< Real > > & getObjective()
Get the objective function.
const Ptr< const Vector< Real > > getObjectiveGradient(const Vector< Real > &x, Real &tol)
const Ptr< AlgorithmState< Real > > state_
int getNumberConstraintEvaluations(void) const
Provides interface for and implements limited-memory secant operators.
const Ptr< Vector< Real > > & getResidualVector()
Get the primal constraint space vector.
const Ptr< Vector< Real > > & getMultiplierVector()
Get the dual constraint space vector.
Real feasDecreaseExponent_
void finalizeIteration()
Transform the optimization variables to the native parameterization after an optimization algorithm h...
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...
const Ptr< CombinedStatusTest< Real > > status_
Real feasToleranceInitial_
int getNumberGradientEvaluations(void) const
const Ptr< PolyhedralProjection< Real > > & getPolyhedralProjection()
Get the polyhedral projection object. This is a null pointer if no linear constraints and/or bounds a...
EProblem getProblemType()
Get the optimization problem type (U, B, E, or G).
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 .
Real optDecreaseExponent_
virtual void writeExitStatus(std::ostream &os) const
void initialize(const Vector< Real > &x, const Vector< Real > &g, const Vector< Real > &mul, const Vector< Real > &c)
Real feasIncreaseExponent_
virtual void set(const Vector &x)
Set where .
StabilizedLCLAlgorithm(ParameterList &list, const Ptr< Secant< Real >> &secant=nullPtr)
void reset(const Vector< Real > &multiplier, Real penaltyParameter, Real sigma)
virtual void edit()
Resume editting optimization problem after finalize has been called.
const Ptr< Vector< Real > > & getDualOptimizationVector()
Get the dual optimization space vector.
virtual void writeName(std::ostream &os) const override
Print step name.
Real optToleranceInitial_
Defines the general constraint operator interface.
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.