44 #ifndef ROL_AUGMENTEDLAGRANGIANSTEP_H 45 #define ROL_AUGMENTEDLAGRANGIANSTEP_H 58 #include "Teuchos_ParameterList.hpp" 71 Teuchos::RCP<AugmentedLagrangian<Real> >
augLag_;
72 Teuchos::RCP<Algorithm<Real> >
algo_;
73 Teuchos::RCP<Vector<Real> >
x_;
104 augLag_->gradient(g,x,tol);
105 if ( scaleLagrangian_ ) {
111 x_->axpy(-1.,g.
dual());
126 :
Step<Real>(), augLag_(Teuchos::null), algo_(Teuchos::null),
127 x_(Teuchos::null), parlist_(parlist), subproblemIter_(0) {
128 Teuchos::ParameterList& sublist = parlist.sublist(
"Step").sublist(
"Augmented Lagrangian");
131 scaleLagrangian_ = sublist.get(
"Use Scaled Augmented Lagrangian",
false);
132 minPenaltyLowerBound_ = sublist.get(
"Penalty Parameter Reciprocal Lower Bound", 0.1);
133 minPenaltyReciprocal_ = 0.1;
134 penaltyUpdate_ = sublist.get(
"Penalty Parameter Growth Factor", 1.e1);
135 maxPenaltyParam_ = sublist.get(
"Maximum Penalty Parameter", 1.e8);
137 optIncreaseExponent_ = sublist.get(
"Optimality Tolerance Update Exponent", 1.0);
138 optDecreaseExponent_ = sublist.get(
"Optimality Tolerance Decrease Exponent", 1.0);
139 optToleranceInitial_ = sublist.get(
"Initial Optimality Tolerance", 1.0);
141 feasIncreaseExponent_ = sublist.get(
"Feasibility Tolerance Update Exponent", 0.1);
142 feasDecreaseExponent_ = sublist.get(
"Feasibility Tolerance Decrease Exponent", 0.9);
143 feasToleranceInitial_ = sublist.get(
"Initial Feasibility Tolerance", 1.0);
145 print_ = sublist.get(
"Print Intermediate Optimization History",
false);
146 maxit_ = sublist.get(
"Subproblem Iteration Limit", 1000);
147 subStep_ = sublist.get(
"Subproblem Step Type",
"Trust Region");
148 parlist_.sublist(
"Status Test").set(
"Iteration Limit",maxit_);
150 outerFeasTolerance_ = parlist.sublist(
"Status Test").get(
"Constraint Tolerance", 1.e-8);
151 outerOptTolerance_ = parlist.sublist(
"Status Test").get(
"Gradient Tolerance", 1.e-8);
152 outerStepTolerance_ = parlist.sublist(
"Status Test").get(
"Step Tolerance", 1.e-8);
162 state->descentVec = x.
clone();
163 state->gradientVec = g.
clone();
164 state->constraintVec = c.
clone();
168 algo_state.
nfval = 0;
169 algo_state.
ncval = 0;
170 algo_state.
ngrad = 0;
179 augLag_->update(x,
true,algo_state.
iter);
180 algo_state.
value = augLag_->getObjectiveValue(x);
182 augLag_->getConstraintVec(*(state->constraintVec),x);
183 algo_state.
cnorm = (state->constraintVec)->norm();
185 algo_state.
ncval += augLag_->getNumberConstraintEvaluations();
186 algo_state.
nfval += augLag_->getNumberFunctionEvaluations();
187 algo_state.
ngrad += augLag_->getNumberGradientEvaluations();
189 minPenaltyReciprocal_ = std::min(1./state->searchSize,minPenaltyLowerBound_);
190 optTolerance_ = std::max(1.e-2*outerOptTolerance_,
191 optToleranceInitial_*std::pow(minPenaltyReciprocal_,optDecreaseExponent_));
192 optTolerance_ = std::min(optTolerance_,1.e-2*algo_state.
gnorm);
193 feasTolerance_ = std::max(1.e-2*outerFeasTolerance_,
194 feasToleranceInitial_*std::pow(minPenaltyReciprocal_,feasDecreaseExponent_));
202 parlist_.sublist(
"Status Test").set(
"Gradient Tolerance",optTolerance_);
203 parlist_.sublist(
"Status Test").set(
"Step Tolerance",1.e-6*optTolerance_);
207 algo_->run(*x_,*augLag_,bnd,print_);
210 algo_->run(*x_,*augLag_,print_);
213 subproblemIter_ = (algo_->getState())->iter;
226 state->descentVec->set(s);
230 algo_state.
value = augLag_->getObjectiveValue(x);
232 augLag_->getConstraintVec(*(state->constraintVec),x);
233 algo_state.
cnorm = (state->constraintVec)->norm();
237 algo_state.
nfval += augLag_->getNumberFunctionEvaluations();
238 algo_state.
ngrad += augLag_->getNumberGradientEvaluations();
239 algo_state.
ncval += augLag_->getNumberConstraintEvaluations();
241 augLag_->update(x,
true,algo_state.
iter);
244 minPenaltyReciprocal_ = std::min(1./state->searchSize,minPenaltyLowerBound_);
245 if ( algo_state.
cnorm < feasTolerance_ ) {
246 l.
axpy(state->searchSize,(state->constraintVec)->dual());
247 optTolerance_ = std::max(1.e-2*outerOptTolerance_,
248 optTolerance_*std::pow(minPenaltyReciprocal_,optIncreaseExponent_));
249 feasTolerance_ = std::max(1.e-2*outerFeasTolerance_,
250 feasTolerance_*std::pow(minPenaltyReciprocal_,feasIncreaseExponent_));
252 algo_state.
snorm += state->searchSize*algo_state.
cnorm;
256 state->searchSize = std::min(penaltyUpdate_*state->searchSize,maxPenaltyParam_);
257 optTolerance_ = std::max(1.e-2*outerOptTolerance_,
258 optToleranceInitial_*std::pow(minPenaltyReciprocal_,optDecreaseExponent_));
259 feasTolerance_ = std::max(1.e-2*outerFeasTolerance_,
260 feasToleranceInitial_*std::pow(minPenaltyReciprocal_,feasDecreaseExponent_));
262 augLag_->reset(l,state->searchSize);
268 std::stringstream hist;
270 hist << std::setw(6) << std::left <<
"iter";
271 hist << std::setw(15) << std::left <<
"fval";
272 hist << std::setw(15) << std::left <<
"cnorm";
273 hist << std::setw(15) << std::left <<
"gLnorm";
274 hist << std::setw(15) << std::left <<
"snorm";
275 hist << std::setw(10) << std::left <<
"penalty";
276 hist << std::setw(10) << std::left <<
"feasTol";
277 hist << std::setw(10) << std::left <<
"optTol";
278 hist << std::setw(8) << std::left <<
"#fval";
279 hist << std::setw(8) << std::left <<
"#grad";
280 hist << std::setw(8) << std::left <<
"#cval";
281 hist << std::setw(8) << std::left <<
"subIter";
289 std::stringstream hist;
290 hist <<
"\n" <<
" Augmented Lagrangian solver";
298 std::stringstream hist;
299 hist << std::scientific << std::setprecision(6);
300 if ( algo_state.
iter == 0 ) {
306 if ( algo_state.
iter == 0 ) {
308 hist << std::setw(6) << std::left << algo_state.
iter;
309 hist << std::setw(15) << std::left << algo_state.
value;
310 hist << std::setw(15) << std::left << algo_state.
cnorm;
311 hist << std::setw(15) << std::left << algo_state.
gnorm;
312 hist << std::setw(15) << std::left <<
" ";
313 hist << std::scientific << std::setprecision(2);
314 hist << std::setw(10) << std::left << Step<Real>::getStepState()->searchSize;
315 hist << std::setw(10) << std::left << std::max(feasTolerance_,outerFeasTolerance_);
316 hist << std::setw(10) << std::left << std::max(optTolerance_,outerOptTolerance_);
321 hist << std::setw(6) << std::left << algo_state.
iter;
322 hist << std::setw(15) << std::left << algo_state.
value;
323 hist << std::setw(15) << std::left << algo_state.
cnorm;
324 hist << std::setw(15) << std::left << algo_state.
gnorm;
325 hist << std::setw(15) << std::left << algo_state.
snorm;
326 hist << std::scientific << std::setprecision(2);
327 hist << std::setw(10) << std::left << Step<Real>::getStepState()->searchSize;
330 hist << std::scientific << std::setprecision(6);
331 hist << std::setw(8) << std::left << algo_state.
nfval;
332 hist << std::setw(8) << std::left << algo_state.
ngrad;
333 hist << std::setw(8) << std::left << algo_state.
ncval;
Real feasDecreaseExponent_
void initialize(Vector< Real > &x, const Vector< Real > &g, Vector< Real > &l, const Vector< Real > &c, Objective< Real > &obj, EqualityConstraint< Real > &con, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Initialize step with equality constraint.
Provides the interface to evaluate objective functions.
Provides the interface to evaluate the augmented Lagrangian.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
virtual void scale(const Real alpha)=0
Compute where .
std::string printHeader(void) const
Print iterate header.
virtual void plus(const Vector &x)=0
Compute , where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Provides the interface to compute optimization steps.
Real feasIncreaseExponent_
Real feasToleranceInitial_
Teuchos::RCP< StepState< Real > > getState(void)
Contains definitions of custom data types in ROL.
Teuchos::RCP< Algorithm< Real > > algo_
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update bounds.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Defines the linear algebra or vector space interface.
~AugmentedLagrangianStep()
Provides the interface to compute augmented Lagrangian steps.
std::string printName(void) const
Print step name.
Real optIncreaseExponent_
State for algorithm class. Will be used for restarts.
Teuchos::RCP< Vector< Real > > x_
bool isActivated(void)
Check if bounds are on.
Defines the equality constraint operator interface.
Real minPenaltyLowerBound_
Provides an interface to run optimization algorithms.
AugmentedLagrangianStep(Teuchos::ParameterList &parlist)
Real optDecreaseExponent_
Real minPenaltyReciprocal_
Teuchos::RCP< AugmentedLagrangian< Real > > augLag_
void compute(Vector< Real > &s, const Vector< Real > &x, const Vector< Real > &l, Objective< Real > &obj, EqualityConstraint< Real > &con, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step (equality and bound constraints).
Real optToleranceInitial_
Provides the interface to apply upper and lower bound constraints.
std::string print(AlgorithmState< Real > &algo_state, bool pHeader=false) const
Print iterate status.
Teuchos::RCP< Vector< Real > > lagmultVec
Teuchos::RCP< Vector< Real > > iterateVec
virtual void set(const Vector &x)
Set where .
virtual Real norm() const =0
Returns where .
void update(Vector< Real > &x, Vector< Real > &l, const Vector< Real > &s, Objective< Real > &obj, EqualityConstraint< Real > &con, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update step, if successful (equality and bound constraints).
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Update step, for bound constraints; here only to satisfy the interface requirements, does nothing, needs refactoring.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
Teuchos::ParameterList parlist_
Real computeGradient(Vector< Real > &g, const Vector< Real > &x, const Real mu, BoundConstraint< Real > &bnd)
static const double ROL_EPSILON
Platform-dependent machine epsilon.
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Compute step for bound constraints; here only to satisfy the interface requirements, does nothing, needs refactoring.