75 std::ostream &outStream ) {
77 if (proj_ == nullPtr) {
78 proj_ = makePtr<PolyhedralProjection<Real>>(makePtrFromRef(bnd));
81 proj_->project(x,outStream);
83 const Real one(1), TOL(1.e-2);
84 Real tol = std::sqrt(ROL_EPSILON<Real>());
95 alobj.
gradient(*state_->gradientVec,x,tol);
99 state_->cnorm = state_->constraintVec->norm();
107 if (useDefaultScaling_) {
110 Ptr<Vector<Real>> ji = x.
clone();
111 Real maxji(0), normji(0);
112 for (
int i = 0; i < c.
dimension(); ++i) {
115 maxji = std::max(normji,maxji);
117 cscale_ = one/std::max(one,maxji);
119 catch (std::exception &e) {
126 x.
axpy(-one,state_->gradientVec->dual());
127 proj_->project(x,outStream);
128 x.
axpy(-one/std::min(fscale_,cscale_),*state_->iterateVec);
129 state_->gnorm = x.
norm();
130 x.
set(*state_->iterateVec);
133 if (useDefaultInitPen_) {
134 const Real oem8(1e-8), oem2(1e-2), two(2), ten(10);
135 state_->searchSize = std::max(oem8,
136 std::min(ten*std::max(one,std::abs(fscale_*state_->value))
137 / std::max(one,std::pow(cscale_*state_->cnorm,two)),oem2*maxPenaltyParam_));
140 if (useRelTol_) outerOptTolerance_ *= state_->gnorm;
141 minPenaltyReciprocal_ = std::min(one/state_->searchSize,minPenaltyLowerBound_);
142 optTolerance_ = std::max<Real>(TOL*outerOptTolerance_,
143 optToleranceInitial_*std::pow(minPenaltyReciprocal_,optDecreaseExponent_));
144 optTolerance_ = std::min<Real>(optTolerance_,TOL*state_->gnorm);
145 feasTolerance_ = std::max<Real>(TOL*outerFeasTolerance_,
146 feasToleranceInitial_*std::pow(minPenaltyReciprocal_,feasDecreaseExponent_));
149 alobj.
reset(l,state_->searchSize);
151 if (verbosity_ > 1) {
152 outStream << std::endl;
153 outStream <<
"Augmented Lagrangian Initialize" << std::endl;
154 outStream <<
"Objective Scaling: " << fscale_ << std::endl;
155 outStream <<
"Constraint Scaling: " << cscale_ << std::endl;
156 outStream <<
"Penalty Parameter: " << state_->searchSize << std::endl;
157 outStream << std::endl;
169 std::ostream &outStream ) {
170 const Real one(1), oem2(1e-2);
171 Real tol(std::sqrt(ROL_EPSILON<Real>()));
174 state_->searchSize,g,eres,emul,
175 scaleLagrangian_,HessianApprox_);
176 initialize(x,g,emul,eres,alobj,bnd,econ,outStream);
177 Ptr<TypeB::Algorithm<Real>> algo;
180 if (verbosity_ > 0) writeOutput(outStream,
true);
182 while (status_->check(*state_)) {
184 list_.sublist(
"Status Test").set(
"Gradient Tolerance",optTolerance_);
185 list_.sublist(
"Status Test").set(
"Step Tolerance",1.e-6*optTolerance_);
186 algo = TypeB::AlgorithmFactory<Real>(list_,secant_);
187 if (hasPolyProj_) algo->run(x,g,alobj,bnd,*proj_->getLinearConstraint(),
188 *proj_->getMultiplier(),*proj_->getResidual(),
190 else algo->run(x,g,alobj,bnd,outStream);
191 subproblemIter_ = algo->getState()->iter;
194 state_->stepVec->set(x);
195 state_->stepVec->axpy(-one,*state_->iterateVec);
196 state_->snorm = state_->stepVec->norm();
200 state_->iterateVec->set(x);
203 state_->cnorm = state_->constraintVec->norm();
204 alobj.
gradient(*state_->gradientVec,x,tol);
205 if (scaleLagrangian_) {
206 state_->gradientVec->scale(state_->searchSize);
208 x.
axpy(-one/std::min(fscale_,cscale_),state_->gradientVec->dual());
209 proj_->project(x,outStream);
210 x.
axpy(-one,*state_->iterateVec);
211 state_->gnorm = x.
norm();
212 x.
set(*state_->iterateVec);
222 minPenaltyReciprocal_ = std::min(one/state_->searchSize,minPenaltyLowerBound_);
223 if ( cscale_*state_->cnorm < feasTolerance_ ) {
224 emul.
axpy(state_->searchSize*cscale_,state_->constraintVec->dual());
225 optTolerance_ = std::max(oem2*outerOptTolerance_,
226 optTolerance_*std::pow(minPenaltyReciprocal_,optIncreaseExponent_));
227 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
228 feasTolerance_*std::pow(minPenaltyReciprocal_,feasIncreaseExponent_));
230 state_->snorm += state_->searchSize*cscale_*state_->cnorm;
231 state_->lagmultVec->set(emul);
234 state_->searchSize = std::min(penaltyUpdate_*state_->searchSize,maxPenaltyParam_);
235 optTolerance_ = std::max(oem2*outerOptTolerance_,
236 optToleranceInitial_*std::pow(minPenaltyReciprocal_,optDecreaseExponent_));
237 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
238 feasToleranceInitial_*std::pow(minPenaltyReciprocal_,feasDecreaseExponent_));
240 alobj.
reset(emul,state_->searchSize);
244 if (verbosity_ > 0) writeOutput(outStream,printHeader_);
251 std::ios_base::fmtflags osFlags(os.flags());
253 os << std::string(114,
'-') << std::endl;
254 os <<
"Augmented Lagrangian status output definitions" << std::endl << std::endl;
255 os <<
" iter - Number of iterates (steps taken)" << std::endl;
256 os <<
" fval - Objective function value" << std::endl;
257 os <<
" cnorm - Norm of the constraint violation" << std::endl;
258 os <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
259 os <<
" snorm - Norm of the step" << std::endl;
260 os <<
" penalty - Penalty parameter" << std::endl;
261 os <<
" feasTol - Feasibility tolerance" << std::endl;
262 os <<
" optTol - Optimality tolerance" << std::endl;
263 os <<
" #fval - Number of times the objective was computed" << std::endl;
264 os <<
" #grad - Number of times the gradient was computed" << std::endl;
265 os <<
" #cval - Number of times the constraint was computed" << std::endl;
266 os <<
" subIter - Number of iterations to solve subproblem" << std::endl;
267 os << std::string(114,
'-') << std::endl;
270 os << std::setw(6) << std::left <<
"iter";
271 os << std::setw(15) << std::left <<
"fval";
272 os << std::setw(15) << std::left <<
"cnorm";
273 os << std::setw(15) << std::left <<
"gLnorm";
274 os << std::setw(15) << std::left <<
"snorm";
275 os << std::setw(10) << std::left <<
"penalty";
276 os << std::setw(10) << std::left <<
"feasTol";
277 os << std::setw(10) << std::left <<
"optTol";
278 os << std::setw(8) << std::left <<
"#fval";
279 os << std::setw(8) << std::left <<
"#grad";
280 os << std::setw(8) << std::left <<
"#cval";
281 os << std::setw(8) << std::left <<
"subIter";
297 std::ios_base::fmtflags osFlags(os.flags());
298 os << std::scientific << std::setprecision(6);
299 if ( state_->iter == 0 ) writeName(os);
300 if ( print_header ) writeHeader(os);
301 if ( state_->iter == 0 ) {
303 os << std::setw(6) << std::left << state_->iter;
304 os << std::setw(15) << std::left << state_->value;
305 os << std::setw(15) << std::left << state_->cnorm;
306 os << std::setw(15) << std::left << state_->gnorm;
307 os << std::setw(15) << std::left <<
"---";
308 os << std::scientific << std::setprecision(2);
309 os << std::setw(10) << std::left << state_->searchSize;
310 os << std::setw(10) << std::left << std::max(feasTolerance_,outerFeasTolerance_);
311 os << std::setw(10) << std::left << std::max(optTolerance_,outerOptTolerance_);
312 os << std::scientific << std::setprecision(6);
313 os << std::setw(8) << std::left << state_->nfval;
314 os << std::setw(8) << std::left << state_->ngrad;
315 os << std::setw(8) << std::left << state_->ncval;
316 os << std::setw(8) << std::left <<
"---";
321 os << std::setw(6) << std::left << state_->iter;
322 os << std::setw(15) << std::left << state_->value;
323 os << std::setw(15) << std::left << state_->cnorm;
324 os << std::setw(15) << std::left << state_->gnorm;
325 os << std::setw(15) << std::left << state_->snorm;
326 os << std::scientific << std::setprecision(2);
327 os << std::setw(10) << std::left << state_->searchSize;
328 os << std::setw(10) << std::left << feasTolerance_;
329 os << std::setw(10) << std::left << optTolerance_;
330 os << std::scientific << std::setprecision(6);
331 os << std::setw(8) << std::left << state_->nfval;
332 os << std::setw(8) << std::left << state_->ngrad;
333 os << std::setw(8) << std::left << state_->ncval;
334 os << std::setw(8) << std::left << subproblemIter_;
void run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, Constraint< Real > &econ, Vector< Real > &emul, const Vector< Real > &eres, std::ostream &outStream=std::cout) override
Run algorithm on general constrained problems (Type-G). This is the primary Type-G interface.