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);
83 Real tol = std::sqrt(ROL_EPSILON<Real>());
98 state_->cnorm = state_->constraintVec->norm();
106 if (useDefaultScaling_) {
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) {
125 x.
axpy(-one,state_->gradientVec->dual());
126 proj_->project(x,outStream);
127 x.
axpy(-one/std::min(fscale_,cscale_),*state_->iterateVec);
128 state_->gnorm = x.
norm();
129 x.
set(*state_->iterateVec);
132 if (useDefaultInitPen_) {
133 const Real oem8(1e-8), oem2(1e-2), two(2), ten(10);
134 state_->searchSize = std::max(oem8,
135 std::min(ten*std::max(one,std::abs(fscale_*state_->value))
136 / std::max(one,std::pow(cscale_*state_->cnorm,two)),oem2*maxPenaltyParam_));
139 optTolerance_ = std::max<Real>(TOL*outerOptTolerance_,
140 optToleranceInitial_);
142 feasTolerance_ = std::max<Real>(TOL*outerFeasTolerance_,
143 feasToleranceInitial_);
146 alobj.
reset(l,state_->searchSize,sigma_);
148 if (verbosity_ > 1) {
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;
187 std::ostream &outStream ) {
188 const Real one(1), oem2(1e-2);
189 Real tol(std::sqrt(ROL_EPSILON<Real>())), cnorm(0), lnorm;;
192 state_->searchSize,sigma_,g,eres,emul,
193 scaleLagrangian_,HessianApprox_);
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");
222 elc.
finalize(
false,verbosity_>2,outStream);
225 Ptr<TypeB::Algorithm<Real>> algo;
228 if (verbosity_ > 0) writeOutput(outStream,
true);
230 while (status_->check(*state_)) {
231 lcon->setAnchor(state_->iterateVec);
232 if (verbosity_ > 3) elc.
check(
true,outStream);
235 list_.sublist(
"Status Test").set(
"Gradient Tolerance",optTolerance_);
236 list_.sublist(
"Status Test").set(
"Step Tolerance",1.e-6*optTolerance_);
237 algo = TypeB::AlgorithmFactory<Real>(list_,secant_);
238 algo->run(elc,outStream);
242 subproblemIter_ = algo->getState()->iter;
248 state_->stepVec->set(x);
249 state_->stepVec->axpy(-one,*state_->iterateVec);
250 state_->snorm = state_->stepVec->norm();
255 cnorm = cvec->norm();
256 if ( cscale_*cnorm < feasTolerance_ ) {
258 state_->iterateVec->set(x);
260 state_->constraintVec->set(*cvec);
261 state_->cnorm = cnorm;
265 emul.
axpy(state_->searchSize*cscale_,state_->constraintVec->dual());
268 if (scaleLagrangian_) state_->gradientVec->scale(state_->searchSize);
270 state_->gradientVec->axpy(-cscale_,*gs);
271 x.
axpy(-one/std::min(fscale_,cscale_),state_->gradientVec->dual());
272 proj_->project(x,outStream);
273 x.
axpy(-one,*state_->iterateVec);
274 state_->gnorm = x.
norm();
275 x.
set(*state_->iterateVec);
279 sigma_ = std::min(one+lnorm,sigmaMax_)/(one+state_->searchSize);
281 optTolerance_ = std::max(oem2*outerOptTolerance_,
282 optTolerance_/(one + std::pow(state_->searchSize,optIncreaseExponent_)));
284 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
285 feasTolerance_/(one + std::pow(state_->searchSize,feasIncreaseExponent_)));
288 state_->snorm += lnorm + state_->searchSize*cscale_*state_->cnorm;
289 state_->lagmultVec->set(emul);
293 state_->searchSize = std::min(penaltyUpdate_*state_->searchSize,maxPenaltyParam_);
294 sigma_ /= sigmaUpdate_;
295 optTolerance_ = std::max(oem2*outerOptTolerance_,
296 optToleranceInitial_/(one + std::pow(state_->searchSize,optDecreaseExponent_)));
297 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
298 feasToleranceInitial_/(one + std::pow(state_->searchSize,feasDecreaseExponent_)));
300 alobj.
reset(emul,state_->searchSize,sigma_);
303 if (verbosity_ > 0) writeOutput(outStream,printHeader_);
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";
358 std::ios_base::fmtflags osFlags(os.flags());
359 os << std::scientific << std::setprecision(6);
360 if ( state_->iter == 0 ) writeName(os);
361 if ( print_header ) writeHeader(os);
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_;
372 os << std::setw(10) << std::left << std::max(feasTolerance_,outerFeasTolerance_);
373 os << std::setw(10) << std::left << std::max(optTolerance_,outerOptTolerance_);
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_;
391 os << std::setw(10) << std::left << feasTolerance_;
392 os << std::setw(10) << std::left << optTolerance_;
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;
397 os << std::setw(8) << std::left << subproblemIter_;