44#ifndef ROL_TYPEG_INTERIORPOINTALGORITHM_DEF_H
45#define ROL_TYPEG_INTERIORPOINTALGORITHM_DEF_H
52template<
typename Real>
55 list_(list), subproblemIter_(0), print_(false) {
61 ParameterList& steplist = list.sublist(
"Step").sublist(
"Interior Point");
62 state_->searchSize = steplist.get(
"Initial Barrier Parameter", 1.0);
63 mumin_ = steplist.get(
"Minimum Barrier Parameter", 1e-4);
64 mumax_ = steplist.get(
"Maximum Barrier Parameter", 1e8);
65 rho_ = steplist.get(
"Barrier Penalty Reduction Factor", 0.5);
67 kappaD_ = steplist.get(
"Linear Damping Coefficient", 1.e-4);
68 print_ = steplist.sublist(
"Subproblem").get(
"Print History",
false);
70 gtol_ = steplist.sublist(
"Subproblem").get(
"Initial Optimality Tolerance", 1e-2);
71 ctol_ = steplist.sublist(
"Subproblem").get(
"Initial Feasibility Tolerance", 1e-2);
73 int maxit = steplist.sublist(
"Subproblem").get(
"Iteration Limit", 1000);
74 list_.sublist(
"Status Test").set(
"Iteration Limit", maxit);
76 gtolrate_ = steplist.sublist(
"Subproblem").get(
"Optimality Tolerance Reduction Factor", 0.1);
77 ctolrate_ = steplist.sublist(
"Subproblem").get(
"Feasibility Tolerance Reduction Factor", 0.1);
78 mingtol_ =
static_cast<Real
>(1e-2)*list.sublist(
"Status Test").get(
"Gradient Tolerance", 1e-8);
79 minctol_ =
static_cast<Real
>(1e-2)*list.sublist(
"Status Test").get(
"Constraint Tolerance", 1e-8);
81 stepname_ = steplist.sublist(
"Subproblem").get(
"Step Type",
"Augmented Lagrangian");
84 verbosity_ = list.sublist(
"General").get(
"Output Level", 0);
90template<
typename Real>
100 std::ostream &outStream) {
102 if (proj_ == nullPtr) {
103 proj_ = makePtr<PolyhedralProjection<Real>>(makePtrFromRef(bnd));
104 hasPolyProj_ =
false;
106 proj_->project(x,outStream);
114 updateState(x,l,ipobj,bnd,con,pwa,dwa,outStream);
118template<
typename Real>
126 std::ostream &outStream) {
128 Real zerotol = std::sqrt(ROL_EPSILON<Real>());
130 if (state_->iter == 0) {
141 ipobj.
gradient(*state_->gradientVec, x, zerotol);
143 state_->gradientVec->plus(dwa);
146 pwa.
axpy(-one,state_->gradientVec->dual());
147 proj_->project(pwa,outStream);
149 state_->gnorm = pwa.
norm();
151 con.
value(*state_->constraintVec, x, zerotol);
152 state_->cnorm = state_->constraintVec->norm();
159template<
typename Real>
167 std::ostream &outStream ) {
169 Ptr<Vector<Real>> pwa = x.
clone(), dwa = g.
clone();
172 x,g,useLinearDamping_,kappaD_,
174 initialize(x,g,emul,eres,ipobj,bnd,econ,*pwa,*dwa,outStream);
175 Ptr<TypeE::Algorithm<Real>> algo;
178 if (verbosity_ > 0) writeOutput(outStream,
true);
180 while (status_->check(*state_)) {
182 list_.sublist(
"Status Test").set(
"Gradient Tolerance", gtol_);
183 list_.sublist(
"Status Test").set(
"Constraint Tolerance", ctol_);
184 list_.sublist(
"Status Test").set(
"Step Tolerance", stol_);
185 algo = TypeE::AlgorithmFactory<Real>(list_);
186 if (hasPolyProj_) algo->run(x,g,ipobj,econ,emul,eres,
187 *proj_->getLinearConstraint(),
188 *proj_->getMultiplier(),
189 *proj_->getResidual(),outStream);
190 else algo->run(x,g,ipobj,econ,emul,eres,outStream);
191 subproblemIter_ = algo->getState()->iter;
192 state_->nfval += algo->getState()->nfval;
193 state_->ngrad += algo->getState()->ngrad;
194 state_->ncval += algo->getState()->ncval;
197 state_->stepVec->set(x);
198 state_->stepVec->axpy(-one,*state_->iterateVec);
199 state_->lagmultVec->axpy(-one,emul);
200 state_->snorm = state_->stepVec->norm();
201 state_->snorm += state_->lagmultVec->norm();
204 state_->iterateVec->set(x);
205 state_->lagmultVec->set(emul);
212 if( (rho_< one && state_->searchSize > mumin_) || (rho_ > one && state_->searchSize < mumax_) ) {
213 state_->searchSize *= rho_;
216 gtol_ *= gtolrate_; gtol_ = std::max(gtol_,mingtol_);
217 ctol_ *= ctolrate_; ctol_ = std::max(ctol_,minctol_);
218 stol_ =
static_cast<Real
>(1e-6)*std::min(gtol_,ctol_);
222 updateState(x,emul,ipobj,bnd,econ,*pwa,*dwa);
225 if (verbosity_ > 0) writeOutput(outStream,printHeader_);
230template<
typename Real>
232 std::stringstream hist;
233 if (verbosity_ > 1) {
234 hist << std::string(109,
'-') << std::endl;
235 hist <<
"Interior Point Solver";
236 hist <<
" status output definitions" << std::endl << std::endl;
237 hist <<
" iter - Number of iterates (steps taken)" << std::endl;
238 hist <<
" fval - Objective function value" << std::endl;
239 hist <<
" cnorm - Norm of the constraint" << std::endl;
240 hist <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
241 hist <<
" snorm - Norm of the step (update to optimization vector)" << std::endl;
242 hist <<
" penalty - Penalty parameter for bound constraints" << std::endl;
243 hist <<
" #fval - Cumulative number of times the objective function was evaluated" << std::endl;
244 hist <<
" #grad - Cumulative number of times the gradient was computed" << std::endl;
245 hist <<
" #cval - Cumulative number of times the constraint was evaluated" << std::endl;
246 hist <<
" optTol - Subproblem optimality tolerance" << std::endl;
247 hist <<
" feasTol - Subproblem feasibility tolerance" << std::endl;
248 hist <<
" subiter - Number of subproblem iterations" << std::endl;
249 hist << std::string(109,
'-') << std::endl;
253 hist << std::setw(6) << std::left <<
"iter";
254 hist << std::setw(15) << std::left <<
"fval";
255 hist << std::setw(15) << std::left <<
"cnorm";
256 hist << std::setw(15) << std::left <<
"gLnorm";
257 hist << std::setw(15) << std::left <<
"snorm";
258 hist << std::setw(10) << std::left <<
"penalty";
259 hist << std::setw(8) << std::left <<
"#fval";
260 hist << std::setw(8) << std::left <<
"#grad";
261 hist << std::setw(8) << std::left <<
"#cval";
262 hist << std::setw(10) << std::left <<
"optTol";
263 hist << std::setw(10) << std::left <<
"feasTol";
264 hist << std::setw(8) << std::left <<
"subIter";
269template<
typename Real>
271 std::stringstream hist;
272 hist << std::endl <<
"Interior Point Solver (Type G, General Constraints)";
274 hist <<
"Subproblem Solver: " << stepname_ << std::endl;
278template<
typename Real>
280 std::stringstream hist;
281 hist << std::scientific << std::setprecision(6);
282 if ( state_->iter == 0 ) writeName(os);
283 if ( print_header ) writeHeader(os);
284 if ( state_->iter == 0 ) {
286 hist << std::setw(6) << std::left << state_->iter;
287 hist << std::setw(15) << std::left << state_->value;
288 hist << std::setw(15) << std::left << state_->cnorm;
289 hist << std::setw(15) << std::left << state_->gnorm;
290 hist << std::setw(15) << std::left <<
"---";
291 hist << std::scientific << std::setprecision(2);
292 hist << std::setw(10) << std::left << state_->searchSize;
293 hist << std::setw(8) << std::left << state_->nfval;
294 hist << std::setw(8) << std::left << state_->ngrad;
295 hist << std::setw(8) << std::left << state_->ncval;
296 hist << std::setw(10) << std::left <<
"---";
297 hist << std::setw(10) << std::left <<
"---";
298 hist << std::setw(8) << std::left <<
"---";
303 hist << std::setw(6) << std::left << state_->iter;
304 hist << std::setw(15) << std::left << state_->value;
305 hist << std::setw(15) << std::left << state_->cnorm;
306 hist << std::setw(15) << std::left << state_->gnorm;
307 hist << std::setw(15) << std::left << state_->snorm;
308 hist << std::scientific << std::setprecision(2);
309 hist << std::setw(10) << std::left << state_->searchSize;
310 hist << std::scientific << std::setprecision(6);
311 hist << std::setw(8) << std::left << state_->nfval;
312 hist << std::setw(8) << std::left << state_->ngrad;
313 hist << std::setw(8) << std::left << state_->ncval;
314 hist << std::scientific << std::setprecision(2);
315 hist << std::setw(10) << std::left << gtol_;
316 hist << std::setw(10) << std::left << ctol_;
317 hist << std::scientific << std::setprecision(6);
318 hist << std::setw(8) << std::left << subproblemIter_;
Provides the interface to apply upper and lower bound constraints.
virtual void projectInterior(Vector< Real > &x)
Project optimization variables into the interior of the feasible set.
Provides an interface to check status of optimization algorithms for problems with equality constrain...
Defines the general constraint operator interface.
virtual void value(Vector< Real > &c, const Vector< Real > &x, Real &tol)=0
Evaluate the constraint operator at .
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 update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update constraint function.
void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
void updatePenalty(const Real mu)
Real getObjectiveValue(const Vector< Real > &x, Real &tol)
Provides the interface to evaluate objective functions.
Provides an interface to run general constrained optimization algorithms.
void initialize(const Vector< Real > &x, const Vector< Real > &g, const Vector< Real > &mul, const Vector< Real > &c)
virtual void writeExitStatus(std::ostream &os) const
const Ptr< CombinedStatusTest< Real > > status_
const Ptr< AlgorithmState< Real > > state_
void updateState(const Vector< Real > &x, const Vector< Real > &l, InteriorPointObjective< Real > &ipobj, BoundConstraint< Real > &bnd, Constraint< Real > &con, Vector< Real > &pwa, Vector< Real > &dwa, std::ostream &outStream=std::cout)
void writeName(std::ostream &os) const override
Print step name.
void writeHeader(std::ostream &os) const override
Print iterate header.
InteriorPointAlgorithm(ParameterList &list)
void writeOutput(std::ostream &os, const bool print_header=false) const override
Print iterate status.
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.
void initialize(Vector< Real > &x, const Vector< Real > &g, const Vector< Real > &l, const Vector< Real > &c, InteriorPointObjective< Real > &ipobj, BoundConstraint< Real > &bnd, Constraint< Real > &con, Vector< Real > &pwa, Vector< Real > &dwa, std::ostream &outStream=std::cout)
Defines the linear algebra or vector space interface.
virtual Real norm() const =0
Returns where .
virtual void set(const Vector &x)
Set where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .