74 std::ostream &outStream ) {
75 const Real one(1), TOL(1.e-2);
76 Real tol = std::sqrt(ROL_EPSILON<Real>());
87 alobj.
gradient(*state_->gradientVec,x,tol);
91 state_->cnorm = state_->constraintVec->norm();
99 if (useDefaultScaling_) {
102 Ptr<Vector<Real>> ji = x.
clone();
103 Real maxji(0), normji(0);
104 for (
int i = 0; i < c.
dimension(); ++i) {
107 maxji = std::max(normji,maxji);
109 cscale_ = one/std::max(one,maxji);
111 catch (std::exception &e) {
118 state_->gnorm = state_->gradientVec->norm()/std::min(fscale_,cscale_);
121 if (useRelTol_) outerOptTolerance_ *= state_->gnorm;
122 if (useDefaultInitPen_) {
123 const Real oem8(1e-8), oem2(1e-2), two(2), ten(10);
124 state_->searchSize = std::max(oem8,
125 std::min(ten*std::max(one,std::abs(fscale_*state_->value))
126 / std::max(one,std::pow(cscale_*state_->cnorm,two)),oem2*maxPenaltyParam_));
129 minPenaltyReciprocal_ = std::min(one/state_->searchSize,minPenaltyLowerBound_);
130 optTolerance_ = std::max<Real>(TOL*outerOptTolerance_,
131 optToleranceInitial_*std::pow(minPenaltyReciprocal_,optDecreaseExponent_));
132 optTolerance_ = std::min<Real>(optTolerance_,TOL*state_->gnorm);
133 feasTolerance_ = std::max<Real>(TOL*outerFeasTolerance_,
134 feasToleranceInitial_*std::pow(minPenaltyReciprocal_,feasDecreaseExponent_));
137 alobj.
reset(l,state_->searchSize);
139 if (verbosity_ > 1) {
140 outStream << std::endl;
141 outStream <<
"Augmented Lagrangian Initialize" << std::endl;
142 outStream <<
"Objective Scaling: " << fscale_ << std::endl;
143 outStream <<
"Constraint Scaling: " << cscale_ << std::endl;
144 outStream << std::endl;
155 std::ostream &outStream ) {
156 const Real one(1), oem2(1e-2);
157 Real tol(std::sqrt(ROL_EPSILON<Real>()));
160 state_->searchSize,g,eres,emul,
161 scaleLagrangian_,HessianApprox_);
162 initialize(x,g,emul,eres,alobj,econ,outStream);
163 Ptr<TypeU::Algorithm<Real>> algo;
166 if (verbosity_ > 0) writeOutput(outStream,
true);
168 while (status_->check(*state_)) {
170 list_.sublist(
"Status Test").set(
"Gradient Tolerance",optTolerance_);
171 list_.sublist(
"Status Test").set(
"Step Tolerance",1.e-6*optTolerance_);
172 algo = TypeU::AlgorithmFactory<Real>(list_,secant_);
173 algo->run(x,g,alobj,outStream);
174 subproblemIter_ = algo->getState()->iter;
177 state_->stepVec->set(x);
178 state_->stepVec->axpy(-one,*state_->iterateVec);
179 state_->snorm = state_->stepVec->norm();
183 state_->iterateVec->set(x);
186 state_->cnorm = state_->constraintVec->norm();
187 alobj.
gradient(*state_->gradientVec,x,tol);
188 if (scaleLagrangian_) {
189 state_->gradientVec->scale(state_->searchSize);
191 state_->gnorm = state_->gradientVec->norm()/std::min(fscale_,cscale_);
200 minPenaltyReciprocal_ = std::min(one/state_->searchSize,minPenaltyLowerBound_);
201 if ( cscale_*state_->cnorm < feasTolerance_ ) {
202 emul.
axpy(state_->searchSize*cscale_,state_->constraintVec->dual());
204 optTolerance_ = std::max(oem2*outerOptTolerance_,
205 optTolerance_*std::pow(minPenaltyReciprocal_,optIncreaseExponent_));
207 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
208 feasTolerance_*std::pow(minPenaltyReciprocal_,feasIncreaseExponent_));
210 state_->snorm += state_->searchSize*cscale_*state_->cnorm;
211 state_->lagmultVec->set(emul);
214 state_->searchSize = std::min(penaltyUpdate_*state_->searchSize,maxPenaltyParam_);
215 optTolerance_ = std::max(oem2*outerOptTolerance_,
216 optToleranceInitial_*std::pow(minPenaltyReciprocal_,optDecreaseExponent_));
217 feasTolerance_ = std::max(oem2*outerFeasTolerance_,
218 feasToleranceInitial_*std::pow(minPenaltyReciprocal_,feasDecreaseExponent_));
220 alobj.
reset(emul,state_->searchSize);
223 if (verbosity_ > 0) writeOutput(outStream,printHeader_);
231 std::ios_base::fmtflags osFlags(os.flags());
233 os << std::string(114,
'-') << std::endl;
234 os <<
"Augmented Lagrangian status output definitions" << std::endl << std::endl;
235 os <<
" iter - Number of iterates (steps taken)" << std::endl;
236 os <<
" fval - Objective function value" << std::endl;
237 os <<
" cnorm - Norm of the constraint violation" << std::endl;
238 os <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
239 os <<
" snorm - Norm of the step" << std::endl;
240 os <<
" penalty - Penalty parameter" << std::endl;
241 os <<
" feasTol - Feasibility tolerance" << std::endl;
242 os <<
" optTol - Optimality tolerance" << std::endl;
243 os <<
" #fval - Number of times the objective was computed" << std::endl;
244 os <<
" #grad - Number of times the gradient was computed" << std::endl;
245 os <<
" #cval - Number of times the constraint was computed" << std::endl;
246 os <<
" subIter - Number of iterations to solve subproblem" << std::endl;
247 os << std::string(114,
'-') << std::endl;
250 os << std::setw(6) << std::left <<
"iter";
251 os << std::setw(15) << std::left <<
"fval";
252 os << std::setw(15) << std::left <<
"cnorm";
253 os << std::setw(15) << std::left <<
"gLnorm";
254 os << std::setw(15) << std::left <<
"snorm";
255 os << std::setw(10) << std::left <<
"penalty";
256 os << std::setw(10) << std::left <<
"feasTol";
257 os << std::setw(10) << std::left <<
"optTol";
258 os << std::setw(8) << std::left <<
"#fval";
259 os << std::setw(8) << std::left <<
"#grad";
260 os << std::setw(8) << std::left <<
"#cval";
261 os << std::setw(8) << std::left <<
"subIter";
277 std::ios_base::fmtflags osFlags(os.flags());
278 os << std::scientific << std::setprecision(6);
279 if ( state_->iter == 0 ) writeName(os);
280 if ( print_header ) writeHeader(os);
281 if ( state_->iter == 0 ) {
283 os << std::setw(6) << std::left << state_->iter;
284 os << std::setw(15) << std::left << state_->value;
285 os << std::setw(15) << std::left << state_->cnorm;
286 os << std::setw(15) << std::left << state_->gnorm;
287 os << std::setw(15) << std::left <<
"---";
288 os << std::scientific << std::setprecision(2);
289 os << std::setw(10) << std::left << state_->searchSize;
290 os << std::setw(10) << std::left << std::max(feasTolerance_,outerFeasTolerance_);
291 os << std::setw(10) << std::left << std::max(optTolerance_,outerOptTolerance_);
292 os << std::scientific << std::setprecision(6);
293 os << std::setw(8) << std::left << state_->nfval;
294 os << std::setw(8) << std::left << state_->ngrad;
295 os << std::setw(8) << std::left << state_->ncval;
296 os << std::setw(8) << std::left <<
"---";
301 os << std::setw(6) << std::left << state_->iter;
302 os << std::setw(15) << std::left << state_->value;
303 os << std::setw(15) << std::left << state_->cnorm;
304 os << std::setw(15) << std::left << state_->gnorm;
305 os << std::setw(15) << std::left << state_->snorm;
306 os << std::scientific << std::setprecision(2);
307 os << std::setw(10) << std::left << state_->searchSize;
308 os << std::setw(10) << std::left << feasTolerance_;
309 os << std::setw(10) << std::left << optTolerance_;
310 os << std::scientific << std::setprecision(6);
311 os << std::setw(8) << std::left << state_->nfval;
312 os << std::setw(8) << std::left << state_->ngrad;
313 os << std::setw(8) << std::left << state_->ncval;
314 os << std::setw(8) << std::left << subproblemIter_;
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 .
virtual void run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, Constraint< Real > &econ, Vector< Real > &emul, const Vector< Real > &eres, std::ostream &outStream=std::cout) override
Run algorithm on equality constrained problems (Type-E). This general interface supports the use of d...