ROL
ROL_InteriorPoint.hpp
Go to the documentation of this file.
1 // Rapid Optimization Library (ROL) Package
2 // Copyright (2014) Sandia Corporation
3 //
4 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
5 // license for use of this work by or on behalf of the U.S. Government.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are
9 // met:
10 //
11 // 1. Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //
14 // 2. Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 //
18 // 3. Neither the name of the Corporation nor the names of the
19 // contributors may be used to endorse or promote products derived from
20 // this software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
23 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
26 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
34 // Questions? Contact lead developers:
35 // Drew Kouri (dpkouri@sandia.gov) and
36 // Denis Ridzal (dridzal@sandia.gov)
37 //
38 // ************************************************************************
39 // @HEADER
40 
41 #ifndef ROL_INTERIORPOINT_H
42 #define ROL_INTERIORPOINT_H
43 
44 #include "ROL_Objective.hpp"
45 #include "ROL_BoundConstraint.hpp"
47 
48 namespace ROL {
49 
50 namespace InteriorPoint {
51 
56 template <class Real>
57 class PenalizedObjective : public ROL::Objective<Real> {
58 private:
60 
61  ROL::Ptr<Objective<Real> > obj_;
62  ROL::Ptr<Objective<Real> > barrier_;
63  ROL::Ptr<Vector<Real> > x_;
64  ROL::Ptr<Vector<Real> > g_;
65  ROL::Ptr<Vector<Real> > scratch_;
66 
67  Real mu_;
68  Real fval_;
69  Real gnorm_;
70  int nfval_;
71  int ngval_;
72 
73 public:
74 
75  PenalizedObjective( const ROL::Ptr<Objective<Real> > &obj,
76  const ROL::Ptr<BoundConstraint<Real> > &bnd,
77  const Vector<Real> &x,
78  ROL::ParameterList &parlist)
79  : obj_(obj), x_(ROL::nullPtr), g_(ROL::nullPtr), scratch_(ROL::nullPtr),
80  fval_(0), gnorm_(0), nfval_(0), ngval_(0) {
81  ROL::ParameterList& IPlist = parlist.sublist("Step").sublist("Interior Point");
82  barrier_ = ROL::makePtr<ObjectiveFromBoundConstraint<Real>>(*bnd,IPlist);
83  x_ = x.clone();
84  g_ = x.dual().clone();
85  scratch_ = x.dual().clone();
86  mu_ = IPlist.get("Initial Barrier Parameter",1.0);
87  }
88 
89  void updatePenalty( Real mu ) {
90  mu_ = mu;
91  }
92 
94  return nfval_;
95  }
96 
98  return ngval_;
99  }
100 
101  void reset(void) {
102  nfval_ = 0; nfval_ = 0;
103  }
104 
105  void update( const Vector<Real> &x, bool flag = true, int iter = -1 ) {
106  // Update original objective and bound penalty
107  obj_->update(x,flag,iter);
108  barrier_->update(x,flag,iter);
109  }
110 
111  Real value( const Vector<Real> &x, Real &tol ) {
112  // Compute original objective value and bound penalty value
113  fval_ = obj_->value(x,tol);
114  Real val = fval_;
115  Real bval = barrier_->value(x,tol);
116  val += mu_*bval;
117 
118  ++nfval_;
119  return val;
120  }
121 
122  Real getObjectiveValue(void) {
123  return fval_;
124  }
125 
126  void gradient( Vector<Real> &g, const Vector<Real> &x, Real &tol ) {
127  // Compute gradient of objective and bound penalty
128  obj_->gradient(g,x,tol);
129  barrier_->gradient(*scratch_,x,tol);
130  scratch_->scale(mu_);
131  g.plus(*scratch_);
132 
133  g_->set(g);
134  gnorm_ = g.norm();
135  ++ngval_;
136  }
137 
139  g.set(*g_);
140  }
141 
143  return gnorm_;
144  }
145 
146  void hessVec( Vector<Real> &hv, const Vector<Real> &v,
147  const Vector<Real> &x, Real &tol ) {
148  // Compute hessvec of objective and bound penalty
149  obj_->hessVec(hv, v, x, tol);
150  barrier_->hessVec(*scratch_,v,x,tol);
151  scratch_->scale(mu_);
152  hv.plus(*scratch_);
153  }
154 
155 }; // class InteriorPointObjective
156 
157 } // namespace InteriorPoint
158 } // namespace ROL
159 
160 #endif
Provides the interface to evaluate objective functions.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Definition: ROL_Vector.hpp:226
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
virtual void plus(const Vector &x)=0
Compute , where .
PartitionedVector< Real >::size_type size_type
PenalizedObjective(const ROL::Ptr< Objective< Real > > &obj, const ROL::Ptr< BoundConstraint< Real > > &bnd, const Vector< Real > &x, ROL::ParameterList &parlist)
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
ROL::Ptr< Objective< Real > > barrier_
Real value(const Vector< Real > &x, Real &tol)
Compute value.
ROL::Ptr< Objective< Real > > obj_
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
Provides the interface to apply upper and lower bound constraints.
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
std::vector< PV >::size_type size_type
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:209
virtual Real norm() const =0
Returns where .