44 #ifndef ROL_TYPEE_STABILIZEDLCLALGORITHM_DEF_H
45 #define ROL_TYPEE_STABILIZEDLCLALGORITHM_DEF_H
53 template<
typename Real>
55 : TypeE::
Algorithm<Real>::
Algorithm(), secant_(secant), list_(list), subproblemIter_(0) {
60 Real one(1), p1(0.1), p9(0.9), ten(1.e1), oe8(1.e8), oem8(1.e-8);
61 ParameterList& sublist = list.sublist(
"Step").sublist(
"Stabilized LCL");
63 state_->searchSize = sublist.get(
"Initial Penalty Parameter", ten);
64 sigma_ = sublist.get(
"Initial Elastic Penalty Parameter", ten*ten);
67 penaltyUpdate_ = sublist.get(
"Penalty Parameter Growth Factor", ten);
69 sigmaMax_ = sublist.get(
"Maximum Elastic Penalty Parameter", oe8);
70 sigmaUpdate_ = sublist.get(
"Elastic Penalty Parameter Growth Rate", ten);
80 maxit_ = sublist.get(
"Subproblem Iteration Limit", 1000);
81 subStep_ = sublist.get(
"Subproblem Step Type",
"Trust Region");
84 list_.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
86 verbosity_ = list.sublist(
"General").get(
"Output Level", 0);
96 fscale_ = sublist.get(
"Objective Scaling", one);
97 cscale_ = sublist.get(
"Constraint Scaling", one);
100 template<
typename Real>
107 std::ostream &outStream ) {
108 const Real one(1), TOL(1.e-2);
109 Real tol = std::sqrt(ROL_EPSILON<Real>());
124 state_->cnorm = state_->constraintVec->norm();
132 if (useDefaultScaling_) {
135 Ptr<Vector<Real>> ji = x.
clone();
136 Real maxji(0), normji(0);
137 for (
int i = 0; i < c.
dimension(); ++i) {
140 maxji = std::max(normji,maxji);
142 cscale_ = one/std::max(one,maxji);
144 catch (std::exception &e) {
151 state_->gnorm = state_->gradientVec->norm()/std::min(fscale_,cscale_);
154 if (useDefaultInitPen_) {
155 const Real oem8(1e-8), oem2(1e-2), two(2), ten(10);
156 state_->searchSize = std::max(oem8,
157 std::min(ten*std::max(one,std::abs(fscale_*state_->value))
158 / std::max(one,std::pow(cscale_*state_->cnorm,two)),oem2*maxPenaltyParam_));
161 optTolerance_ = std::max<Real>(TOL*outerOptTolerance_,
162 optToleranceInitial_);
164 feasTolerance_ = std::max<Real>(TOL*outerFeasTolerance_,
165 feasToleranceInitial_);
168 alobj.
reset(l,state_->searchSize,sigma_);
170 if (verbosity_ > 1) {
171 outStream << std::endl;
172 outStream <<
"Stabilized LCL Initialize" << std::endl;
173 outStream <<
"Objective Scaling: " << fscale_ << std::endl;
174 outStream <<
"Constraint Scaling: " << cscale_ << std::endl;
175 outStream <<
"Penalty Parameter: " << state_->searchSize << std::endl;
176 outStream << std::endl;
180 template<
typename Real>
182 std::ostream &outStream ) {
185 problem.
finalize(
true,verbosity_>3,outStream);
200 template<
typename Real>
207 std::ostream &outStream ) {
208 const Real one(1), oem2(1e-2);
209 Real tol(std::sqrt(ROL_EPSILON<Real>())), cnorm(0), lnorm;;
212 state_->searchSize,sigma_,g,eres,emul,
213 scaleLagrangian_,HessianApprox_);
214 initialize(x,g,emul,eres,alobj,econ,outStream);
216 Ptr<Vector<Real>> u = eres.
clone(), v = eres.
clone(), c = eres.
clone();
217 Ptr<Vector<Real>> gu = emul.
clone(), gv = emul.
clone(), l = emul.
clone();
219 Ptr<ElasticLinearConstraint<Real>> lcon
220 = makePtr<ElasticLinearConstraint<Real>>(makePtrFromRef(x),
221 makePtrFromRef(econ),
222 makePtrFromRef(eres));
223 std::vector<Ptr<Vector<Real>>> vecList = {s,u,v};
224 Ptr<PartitionedVector<Real>> xp = makePtr<PartitionedVector<Real>>(vecList);
225 Ptr<PartitionedVector<Real>> gxp = makePtr<PartitionedVector<Real>>({gs,gu,gv});
226 Ptr<Vector<Real>> lb = u->clone(); lb->zero();
227 std::vector<Ptr<BoundConstraint<Real>>> bndList(3);
228 bndList[0] = makePtr<BoundConstraint<Real>>(); bndList[0]->deactivate();
229 bndList[1] = makePtr<Bounds<Real>>(*lb,
true);
230 bndList[2] = makePtr<Bounds<Real>>(*lb,
true);
231 Ptr<BoundConstraint<Real>> xbnd
232 = makePtr<BoundConstraint_Partitioned<Real>>(bndList,vecList);
233 ParameterList ppa_list;
234 if (c->dimension() == 1)
235 ppa_list.sublist(
"General").sublist(
"Polyhedral Projection").set(
"Type",
"Dai-Fletcher");
237 ppa_list.sublist(
"General").sublist(
"Polyhedral Projection").set(
"Type",
"Semismooth Newton");
241 elc.
finalize(
false,verbosity_>2,outStream);
242 Ptr<Vector<Real>> b2 = eres.
clone(), xpwa = xp->clone(), mul = emul.
clone();
246 Ptr<TypeB::Algorithm<Real>> algo;
249 if (verbosity_ > 0) writeOutput(outStream,
true);
251 while (status_->check(*state_)) {
252 lcon->setAnchor(state_->iterateVec);
253 if (verbosity_ > 3) elc.
check(
true,outStream);
256 list_.sublist(
"Status Test").set(
"Gradient Tolerance",optTolerance_);
257 list_.sublist(
"Status Test").set(
"Step Tolerance",1.e-6*optTolerance_);
258 algo = TypeB::AlgorithmFactory<Real>(list_,secant_);
259 algo->run(elc,outStream);
263 subproblemIter_ = algo->getState()->iter;
269 state_->stepVec->set(x);
270 state_->stepVec->axpy(-one,*state_->iterateVec);
271 state_->snorm = state_->stepVec->norm();
276 cnorm = cvec->norm();
277 if ( cscale_*cnorm < feasTolerance_ ) {
279 state_->iterateVec->set(x);
281 state_->constraintVec->set(*cvec);
282 state_->cnorm = cnorm;
286 emul.
axpy(state_->searchSize*cscale_,state_->constraintVec->dual());
289 if (scaleLagrangian_) state_->gradientVec->scale(state_->searchSize);
291 state_->gradientVec->axpy(-cscale_,*gs);
292 state_->gnorm = state_->gradientVec->norm();
296 sigma_ = std::min(one+lnorm,sigmaMax_)/(one+state_->searchSize);
298 optTolerance_ = std::max(oem2*outerOptTolerance_,
299 optTolerance_/(one + std::pow(state_->searchSize,optIncreaseExponent_)));
301 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
302 feasTolerance_/(one + std::pow(state_->searchSize,feasIncreaseExponent_)));
305 state_->snorm += lnorm + state_->searchSize*cscale_*state_->cnorm;
306 state_->lagmultVec->set(emul);
310 state_->searchSize = std::min(penaltyUpdate_*state_->searchSize,maxPenaltyParam_);
311 sigma_ /= sigmaUpdate_;
312 optTolerance_ = std::max(oem2*outerOptTolerance_,
313 optToleranceInitial_/(one + std::pow(state_->searchSize,optDecreaseExponent_)));
314 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
315 feasToleranceInitial_/(one + std::pow(state_->searchSize,feasDecreaseExponent_)));
317 alobj.
reset(emul,state_->searchSize,sigma_);
320 if (verbosity_ > 0) writeOutput(outStream,printHeader_);
325 template<
typename Real>
327 std::ios_base::fmtflags osFlags(os.flags());
329 os << std::string(114,
'-') << std::endl;
330 os <<
"Stabilized LCL status output definitions" << std::endl << std::endl;
331 os <<
" iter - Number of iterates (steps taken)" << std::endl;
332 os <<
" fval - Objective function value" << std::endl;
333 os <<
" cnorm - Norm of the constraint violation" << std::endl;
334 os <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
335 os <<
" snorm - Norm of the step" << std::endl;
336 os <<
" penalty - Penalty parameter" << std::endl;
337 os <<
" sigma - Elastic Penalty parameter" << std::endl;
338 os <<
" feasTol - Feasibility tolerance" << std::endl;
339 os <<
" optTol - Optimality tolerance" << std::endl;
340 os <<
" #fval - Number of times the objective was computed" << std::endl;
341 os <<
" #grad - Number of times the gradient was computed" << std::endl;
342 os <<
" #cval - Number of times the constraint was computed" << std::endl;
343 os <<
" subIter - Number of iterations to solve subproblem" << std::endl;
344 os << std::string(114,
'-') << std::endl;
347 os << std::setw(6) << std::left <<
"iter";
348 os << std::setw(15) << std::left <<
"fval";
349 os << std::setw(15) << std::left <<
"cnorm";
350 os << std::setw(15) << std::left <<
"gLnorm";
351 os << std::setw(15) << std::left <<
"snorm";
352 os << std::setw(10) << std::left <<
"penalty";
353 os << std::setw(10) << std::left <<
"sigma";
354 os << std::setw(10) << std::left <<
"feasTol";
355 os << std::setw(10) << std::left <<
"optTol";
356 os << std::setw(8) << std::left <<
"#fval";
357 os << std::setw(8) << std::left <<
"#grad";
358 os << std::setw(8) << std::left <<
"#cval";
359 os << std::setw(8) << std::left <<
"subIter";
364 template<
typename Real>
366 std::ios_base::fmtflags osFlags(os.flags());
367 os << std::endl <<
"Stabilized LCL Solver (Type E, Equality Constraints)";
369 os <<
"Subproblem Solver: " << subStep_ << std::endl;
373 template<
typename Real>
375 std::ios_base::fmtflags osFlags(os.flags());
376 os << std::scientific << std::setprecision(6);
377 if ( state_->iter == 0 ) writeName(os);
378 if ( print_header ) writeHeader(os);
379 if ( state_->iter == 0 ) {
381 os << std::setw(6) << std::left << state_->iter;
382 os << std::setw(15) << std::left << state_->value;
383 os << std::setw(15) << std::left << state_->cnorm;
384 os << std::setw(15) << std::left << state_->gnorm;
385 os << std::setw(15) << std::left <<
"---";
386 os << std::scientific << std::setprecision(2);
387 os << std::setw(10) << std::left << state_->searchSize;
388 os << std::setw(10) << std::left << sigma_;
389 os << std::setw(10) << std::left << std::max(feasTolerance_,outerFeasTolerance_);
390 os << std::setw(10) << std::left << std::max(optTolerance_,outerOptTolerance_);
391 os << std::scientific << std::setprecision(6);
392 os << std::setw(8) << std::left << state_->nfval;
393 os << std::setw(8) << std::left << state_->ngrad;
394 os << std::setw(8) << std::left << state_->ncval;
395 os << std::setw(8) << std::left <<
"---";
400 os << std::setw(6) << std::left << state_->iter;
401 os << std::setw(15) << std::left << state_->value;
402 os << std::setw(15) << std::left << state_->cnorm;
403 os << std::setw(15) << std::left << state_->gnorm;
404 os << std::setw(15) << std::left << state_->snorm;
405 os << std::scientific << std::setprecision(2);
406 os << std::setw(10) << std::left << state_->searchSize;
407 os << std::setw(10) << std::left << sigma_;
408 os << std::setw(10) << std::left << feasTolerance_;
409 os << std::setw(10) << std::left << optTolerance_;
410 os << std::scientific << std::setprecision(6);
411 os << std::setw(8) << std::left << state_->nfval;
412 os << std::setw(8) << std::left << state_->ngrad;
413 os << std::setw(8) << std::left << state_->ncval;
414 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.