ROL
ROL_MeritFunction.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 
45 #ifndef ROL_MERITFUNCTION_H
46 #define ROL_MERITFUNCTION_H
47 
48 #include "ROL_Objective.hpp"
49 #include "ROL_InequalityConstraint.hpp"
51 
52 /* Nonsmooth merit function as depicted in Eq. 19.36 of Nocedal and Wright Second Edition
53 
54  \f[
55  \phi_\nu(x,s) = f(x) - \mu\sum\limits_{i=1}^m \ln(s_i)
56  + \nu \| c_E(x)\| + \nu + \| c_I(x)-s\|
57  \f]
58 
59  using the Euclidean norm without squares
60  */
61 
62 
63 namespace ROL {
64 namespace InteriorPoint {
65 
66 template<class Real>
67 class MeritFunction : public Objective<Real> {
68 
69  typedef Vector<Real> V;
73  typedef InequalityConstraint<Real> INCON;
74 
75  typedef ROL::ParameterList PLIST;
76 
77 
78  typedef typename PV::size_type uint;
79 
80  const static uint OPT = 0;
81  const static uint SLACK = 1;
82 
83 
84 private:
85 
86  ROL::Ptr<OBJ> obj_; // Raw objective function
87  ROL::Ptr<EQCON> eqcon_; // constraint
88  ROL::Ptr<INCON> incon_; // Inequality constraint
89  ROL::Ptr<BND> bnd_; // Bound constraint
90 
91  Real mu_; // Penalty parameter for log barrier on slack
92  Real nu_; // Penalty parameter for constraint norms
93 
94  ROL::Ptr<OBJ> obj_;
95  ROL::Ptr<EQCON> eqcon_;
96  ROL::Ptr<INCON> incon_;
97 
98  ROL::Ptr<V> xopt_;
99  ROL::Ptr<V> slack_;
100 
101  ROL::Ptr<V> gopt_; // Gradient of the objective function
102 
103  ROL::Ptr<V> sfun_; // store elementwise function of slack variable
104 
105 
106  ROL::Ptr<V> eqmult_; // constraint Lagrange multiplier
107  ROL::Ptr<V> inmult_; // Inequality constraint Lagrange multiplier
108 
109  ROL::Ptr<V> ce_; // constraint vector
110  ROL::Ptr<V> ci_; // Inequation constraint vector
111 
112  ROL::Ptr<V> jced_; // Jacobian applied to d
113  ROL::Ptr<V> jcid_; // Inequality Jacobian applied to d
114 
115  Real cenorm_;
116  Real cinorm_;
117 
118 
119  static const Elementwise::Logarithm<Real> LOG_;
120  static const Elementwise::Reciprocal<Real> RECIP_;
121  static const Elementwise::ReductionSum<Real> SUM_;
122 
123 
124 public:
125 
126  MeritFunction( ROL::Ptr<OBJ> &obj,
127  ROL::Ptr<EQCON> &eqcon,
128  ROL::Ptr<INCON> &incon,
129  const V& x,
130  const V& eqmult,
131  const V& inmult,
132  PLIST &parlist ) :
133  obj_(obj), eqcon_(eqcon), incon_(incon) {
134 
135  const PV &xpv = dynamic_cast<const PV&>(x);
136  xopt_ = xpv.get(OPT);
137  slack_ = xpv.get(SLACK);
138  sfun_ = slack_->clone();
139 
140  gopt_ = xopt_->dual().clone();
141 
142  PLIST &iplist = parlist.sublist("Step").sublist("Primal-Dual Interior Point");
143  mu_ = iplist.get("Initial Slack Penalty");
144  nu_ = iplist.get("Initial Constraint Norm Penalty");
145 
146  }
147 
148 
149  Real value( const V &x, Real &tol ) {
150 
151  const PV &xpv = dynamic_cast<const PV&>(x);
152  xopt_ = xpv.get(OPT);
153  slack_ = xpv.get(SLACK);
154 
155  sfun_->set(*slack_);
156 
157  sfun_->applyUnary(LOG_);
158 
159  Real val = obj_->value(*xopt_,tol);
160 
161  val += mu_*logs_->reduce(SUM_);
162 
163  eqcon_->value(*ce_,*xopt_,tol);
164  incon_->value(*ci_,*xopt_,tol);
165 
166  cenorm_ = ce_->norm();
167  cinorm_ = ci_->norm();
168 
169  val += nu_*(cenorm_ + cinorm_);
170 
171  return val;
172  }
173 
174 
175  Real dirDeriv( const V &x, const V &d, Real tol ) {
176 
177  const PV &xpv = dynamic_cast<const PV&>(x);
178  xopt_ = xpv.get(OPT);
179  slack_ = xpv.get(SLACK);
180 
181  const PV &dpv = dynamic_cast<const PV&>(d);
182  ROL::Ptr<V> dopt = dpv.get(OPT);
183  ROL::Ptr<V> dslack = dpv.get(SLACK);
184 
185  sfun_->set(*slack);
186  sfun_->applyUnary(RECIP_);
187 
188  ce_->applyJacobian(*jced_,*dopt,*xopt,tol);
189  ci_->applyJacobian(*jcid_,*dopt,*xopt,tol);
190 
191  obj_->gradient(*gopt_,*xopt,tol);
192 
193 
194  // Contributions to directional derivatives
195  Real ddopt = gopt_->dot(*dopt);
196 
197  Real ddslack = sfun_->dot(*dslack);
198 
199  Real ddce = ce_->dot(*jced_)/cenorm_;
200 
201  Real ddci = ci_->dot(*jcid_)/cinorm_;
202 
203  Real ddsn = slack_->dot(*dslack)/slack->norm();
204 
205  return ddopt - mu_*ddslack + nu_*(ddce + ddci + ddsn);
206 
207  }
208 
209 
210  void updateBarrier( Real mu ) {
211  mu_ = mu;
212  }
213 
214 
215 
216 }; // class MeritFunction
217 
218 } // namespace InteriorPoint
219 } // namespace ROL
220 
221 
222 #endif // ROL_MERITFUNCTION_H
223 
224 
225 
226 
227 
228 
229 
230 
231 
232 
233 
Provides the interface to evaluate objective functions.
ROL::Ptr< const Vector< Real > > get(size_type i) const
Defines the linear algebra of vector space on a generic partitioned vector.
static const Elementwise::Reciprocal< Real > RECIP_
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
static const Elementwise::Logarithm< Real > LOG_
static const Elementwise::ReductionSum< Real > SUM_
std::vector< PV >::size_type size_type
Real dirDeriv(const V &x, const V &d, Real tol)
MeritFunction(ROL::Ptr< OBJ > &obj, ROL::Ptr< EQCON > &eqcon, ROL::Ptr< INCON > &incon, const V &x, const V &eqmult, const V &inmult, PLIST &parlist)
Real value(const V &x, Real &tol)
Compute value.
Defines the general constraint operator interface.
InequalityConstraint< Real > INCON