108 std::ostream &outStream ) {
110 if (proj_ == nullPtr) {
111 proj_ = makePtr<PolyhedralProjection<Real>>(makePtrFromRef(bnd));
112 hasPolyProj_ =
false;
114 proj_->project(x,outStream);
116 const Real one(1), TOL(1.e-2);
117 Real tol = std::sqrt(ROL_EPSILON<Real>());
132 state_->cnorm = state_->constraintVec->norm();
140 if (useDefaultScaling_) {
143 Ptr<Vector<Real>> ji = x.
clone();
144 Real maxji(0), normji(0);
145 for (
int i = 0; i < c.
dimension(); ++i) {
148 maxji = std::max(normji,maxji);
150 cscale_ = one/std::max(one,maxji);
152 catch (std::exception &e) {
159 x.
axpy(-one,state_->gradientVec->dual());
160 proj_->project(x,outStream);
161 x.
axpy(-one/std::min(fscale_,cscale_),*state_->iterateVec);
162 state_->gnorm = x.
norm();
163 x.
set(*state_->iterateVec);
166 if (useDefaultInitPen_) {
167 const Real oem8(1e-8), oem2(1e-2), two(2), ten(10);
168 state_->searchSize = std::max(oem8,
169 std::min(ten*std::max(one,std::abs(fscale_*state_->value))
170 / std::max(one,std::pow(cscale_*state_->cnorm,two)),oem2*maxPenaltyParam_));
173 optTolerance_ = std::max<Real>(TOL*outerOptTolerance_,
174 optToleranceInitial_);
176 feasTolerance_ = std::max<Real>(TOL*outerFeasTolerance_,
177 feasToleranceInitial_);
180 alobj.
reset(l,state_->searchSize,sigma_);
182 if (verbosity_ > 1) {
183 outStream << std::endl;
184 outStream <<
"Stabilized LCL Initialize" << std::endl;
185 outStream <<
"Objective Scaling: " << fscale_ << std::endl;
186 outStream <<
"Constraint Scaling: " << cscale_ << std::endl;
187 outStream <<
"Penalty Parameter: " << state_->searchSize << std::endl;
188 outStream << std::endl;
221 std::ostream &outStream ) {
222 const Real one(1), oem2(1e-2);
223 Real tol(std::sqrt(ROL_EPSILON<Real>())), cnorm(0), lnorm;;
226 state_->searchSize,sigma_,g,eres,emul,
227 scaleLagrangian_,HessianApprox_);
228 initialize(x,g,emul,eres,alobj,bnd,econ,outStream);
230 Ptr<Vector<Real>> u = eres.
clone(), v = eres.
clone(), c = eres.
clone();
231 Ptr<Vector<Real>> gu = emul.
clone(), gv = emul.
clone(), l = emul.
clone();
233 Ptr<ElasticLinearConstraint<Real>> lcon
234 = makePtr<ElasticLinearConstraint<Real>>(makePtrFromRef(x),
235 makePtrFromRef(econ),
236 makePtrFromRef(eres));
237 std::vector<Ptr<Vector<Real>>> vecList = {s,u,v};
238 Ptr<PartitionedVector<Real>> xp = makePtr<PartitionedVector<Real>>(vecList);
239 Ptr<PartitionedVector<Real>> gxp = makePtr<PartitionedVector<Real>>({gs,gu,gv});
240 Ptr<Vector<Real>> lb = u->clone(); lb->zero();
241 std::vector<Ptr<BoundConstraint<Real>>> bndList(3);
242 bndList[0] = makePtrFromRef(bnd);
243 bndList[1] = makePtr<Bounds<Real>>(*lb,
true);
244 bndList[2] = makePtr<Bounds<Real>>(*lb,
true);
245 Ptr<BoundConstraint<Real>> xbnd
246 = makePtr<BoundConstraint_Partitioned<Real>>(bndList,vecList);
247 ParameterList ppa_list;
248 if (c->dimension() == 1)
249 ppa_list.sublist(
"General").sublist(
"Polyhedral Projection").set(
"Type",
"Dai-Fletcher");
251 ppa_list.sublist(
"General").sublist(
"Polyhedral Projection").set(
"Type",
"Semismooth Newton");
256 elc.
finalize(
false,verbosity_>2,outStream);
259 Ptr<TypeB::Algorithm<Real>> algo;
262 if (verbosity_ > 0) writeOutput(outStream,
true);
264 while (status_->check(*state_)) {
265 lcon->setAnchor(state_->iterateVec);
266 if (verbosity_ > 3) elc.
check(
true,outStream);
269 list_.sublist(
"Status Test").set(
"Gradient Tolerance",optTolerance_);
270 list_.sublist(
"Status Test").set(
"Step Tolerance",1.e-6*optTolerance_);
271 algo = TypeB::AlgorithmFactory<Real>(list_);
272 algo->run(elc,outStream);
276 subproblemIter_ = algo->getState()->iter;
282 state_->stepVec->set(x);
283 state_->stepVec->axpy(-one,*state_->iterateVec);
284 state_->snorm = state_->stepVec->norm();
289 cnorm = cvec->norm();
290 if ( cscale_*cnorm < feasTolerance_ ) {
292 state_->iterateVec->set(x);
294 state_->constraintVec->set(*cvec);
295 state_->cnorm = cnorm;
299 emul.
axpy(state_->searchSize*cscale_,state_->constraintVec->dual());
302 if (scaleLagrangian_) state_->gradientVec->scale(state_->searchSize);
304 state_->gradientVec->axpy(-cscale_,*gs);
305 x.
axpy(-one/std::min(fscale_,cscale_),state_->gradientVec->dual());
306 proj_->project(x,outStream);
307 x.
axpy(-one,*state_->iterateVec);
308 state_->gnorm = x.
norm();
309 x.
set(*state_->iterateVec);
313 sigma_ = std::min(one+lnorm,sigmaMax_)/(one+state_->searchSize);
315 optTolerance_ = std::max(oem2*outerOptTolerance_,
316 optTolerance_/(one + std::pow(state_->searchSize,optIncreaseExponent_)));
318 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
319 feasTolerance_/(one + std::pow(state_->searchSize,feasIncreaseExponent_)));
322 state_->snorm += lnorm + state_->searchSize*cscale_*state_->cnorm;
323 state_->lagmultVec->set(emul);
327 state_->searchSize = std::min(penaltyUpdate_*state_->searchSize,maxPenaltyParam_);
328 sigma_ /= sigmaUpdate_;
329 optTolerance_ = std::max(oem2*outerOptTolerance_,
330 optToleranceInitial_/(one + std::pow(state_->searchSize,optDecreaseExponent_)));
331 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
332 feasToleranceInitial_/(one + std::pow(state_->searchSize,feasDecreaseExponent_)));
334 alobj.
reset(emul,state_->searchSize,sigma_);
337 if (verbosity_ > 0) writeOutput(outStream,printHeader_);
344 std::stringstream hist;
346 hist << std::string(114,
'-') << std::endl;
347 hist <<
"Stabilized LCL status output definitions" << std::endl << std::endl;
348 hist <<
" iter - Number of iterates (steps taken)" << std::endl;
349 hist <<
" fval - Objective function value" << std::endl;
350 hist <<
" cnorm - Norm of the constraint violation" << std::endl;
351 hist <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
352 hist <<
" snorm - Norm of the step" << std::endl;
353 hist <<
" penalty - Penalty parameter" << std::endl;
354 hist <<
" sigma - Elastic Penalty parameter" << std::endl;
355 hist <<
" feasTol - Feasibility tolerance" << std::endl;
356 hist <<
" optTol - Optimality tolerance" << std::endl;
357 hist <<
" #fval - Number of times the objective was computed" << std::endl;
358 hist <<
" #grad - Number of times the gradient was computed" << std::endl;
359 hist <<
" #cval - Number of times the constraint was computed" << std::endl;
360 hist <<
" subIter - Number of iterations to solve subproblem" << std::endl;
361 hist << std::string(114,
'-') << std::endl;
364 hist << std::setw(6) << std::left <<
"iter";
365 hist << std::setw(15) << std::left <<
"fval";
366 hist << std::setw(15) << std::left <<
"cnorm";
367 hist << std::setw(15) << std::left <<
"gLnorm";
368 hist << std::setw(15) << std::left <<
"snorm";
369 hist << std::setw(10) << std::left <<
"penalty";
370 hist << std::setw(10) << std::left <<
"sigma";
371 hist << std::setw(10) << std::left <<
"feasTol";
372 hist << std::setw(10) << std::left <<
"optTol";
373 hist << std::setw(8) << std::left <<
"#fval";
374 hist << std::setw(8) << std::left <<
"#grad";
375 hist << std::setw(8) << std::left <<
"#cval";
376 hist << std::setw(8) << std::left <<
"subIter";
392 std::stringstream hist;
393 hist << std::scientific << std::setprecision(6);
394 if ( state_->iter == 0 ) writeName(os);
395 if ( print_header ) writeHeader(os);
396 if ( state_->iter == 0 ) {
398 hist << std::setw(6) << std::left << state_->iter;
399 hist << std::setw(15) << std::left << state_->value;
400 hist << std::setw(15) << std::left << state_->cnorm;
401 hist << std::setw(15) << std::left << state_->gnorm;
402 hist << std::setw(15) << std::left <<
"---";
403 hist << std::scientific << std::setprecision(2);
404 hist << std::setw(10) << std::left << state_->searchSize;
405 hist << std::setw(10) << std::left << sigma_;
406 hist << std::setw(10) << std::left << std::max(feasTolerance_,outerFeasTolerance_);
407 hist << std::setw(10) << std::left << std::max(optTolerance_,outerOptTolerance_);
408 hist << std::scientific << std::setprecision(6);
409 hist << std::setw(8) << std::left << state_->nfval;
410 hist << std::setw(8) << std::left << state_->ngrad;
411 hist << std::setw(8) << std::left << state_->ncval;
412 hist << std::setw(8) << std::left <<
"---";
417 hist << std::setw(6) << std::left << state_->iter;
418 hist << std::setw(15) << std::left << state_->value;
419 hist << std::setw(15) << std::left << state_->cnorm;
420 hist << std::setw(15) << std::left << state_->gnorm;
421 hist << std::setw(15) << std::left << state_->snorm;
422 hist << std::scientific << std::setprecision(2);
423 hist << std::setw(10) << std::left << state_->searchSize;
424 hist << std::setw(10) << std::left << sigma_;
425 hist << std::setw(10) << std::left << feasTolerance_;
426 hist << std::setw(10) << std::left << optTolerance_;
427 hist << std::scientific << std::setprecision(6);
428 hist << std::setw(8) << std::left << state_->nfval;
429 hist << std::setw(8) << std::left << state_->ngrad;
430 hist << std::setw(8) << std::left << state_->ncval;
431 hist << std::setw(8) << std::left << subproblemIter_;