ROL
ROL_InteriorPoint.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Rapid Optimization Library (ROL) Package
4//
5// Copyright 2014 NTESS and the ROL contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef ROL_INTERIORPOINT_H
11#define ROL_INTERIORPOINT_H
12
13#include "ROL_Objective.hpp"
16
17namespace ROL {
18
19namespace InteriorPoint {
20
25template <class Real>
26class PenalizedObjective : public ROL::Objective<Real> {
27private:
29
30 ROL::Ptr<Objective<Real> > obj_;
31 ROL::Ptr<Objective<Real> > barrier_;
32 ROL::Ptr<Vector<Real> > x_;
33 ROL::Ptr<Vector<Real> > g_;
34 ROL::Ptr<Vector<Real> > scratch_;
35
36 Real mu_;
37 Real fval_;
38 Real gnorm_;
39 int nfval_;
40 int ngval_;
41
42public:
43
44 PenalizedObjective( const ROL::Ptr<Objective<Real> > &obj,
45 const ROL::Ptr<BoundConstraint<Real> > &bnd,
46 const Vector<Real> &x,
47 ROL::ParameterList &parlist)
48 : obj_(obj), x_(ROL::nullPtr), g_(ROL::nullPtr), scratch_(ROL::nullPtr),
49 fval_(0), gnorm_(0), nfval_(0), ngval_(0) {
50 ROL::ParameterList& IPlist = parlist.sublist("Step").sublist("Interior Point");
51 barrier_ = ROL::makePtr<ObjectiveFromBoundConstraint<Real>>(*bnd,IPlist);
52 x_ = x.clone();
53 g_ = x.dual().clone();
54 scratch_ = x.dual().clone();
55 mu_ = IPlist.get("Initial Barrier Parameter",1.0);
56 }
57
58 void updatePenalty( Real mu ) {
59 mu_ = mu;
60 }
61
63 return nfval_;
64 }
65
67 return ngval_;
68 }
69
70 void reset(void) {
71 nfval_ = 0; nfval_ = 0;
72 }
73
74 void update( const Vector<Real> &x, bool flag = true, int iter = -1 ) {
75 // Update original objective and bound penalty
76 obj_->update(x,flag,iter);
77 barrier_->update(x,flag,iter);
78 }
79
80 Real value( const Vector<Real> &x, Real &tol ) {
81 // Compute original objective value and bound penalty value
82 fval_ = obj_->value(x,tol);
83 Real val = fval_;
84 Real bval = barrier_->value(x,tol);
85 val += mu_*bval;
86
87 ++nfval_;
88 return val;
89 }
90
91 Real getObjectiveValue(void) {
92 return fval_;
93 }
94
95 void gradient( Vector<Real> &g, const Vector<Real> &x, Real &tol ) {
96 // Compute gradient of objective and bound penalty
97 obj_->gradient(g,x,tol);
98 barrier_->gradient(*scratch_,x,tol);
99 scratch_->scale(mu_);
100 g.plus(*scratch_);
101
102 g_->set(g);
103 gnorm_ = g.norm();
104 ++ngval_;
105 }
106
108 g.set(*g_);
109 }
110
112 return gnorm_;
113 }
114
115 void hessVec( Vector<Real> &hv, const Vector<Real> &v,
116 const Vector<Real> &x, Real &tol ) {
117 // Compute hessvec of objective and bound penalty
118 obj_->hessVec(hv, v, x, tol);
119 barrier_->hessVec(*scratch_,v,x,tol);
120 scratch_->scale(mu_);
121 hv.plus(*scratch_);
122 }
123
124}; // class InteriorPointObjective
125
126} // namespace InteriorPoint
127} // namespace ROL
128
129#endif
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.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
PartitionedVector< Real >::size_type size_type
Real value(const Vector< Real > &x, Real &tol)
Compute value.
PenalizedObjective(const ROL::Ptr< Objective< Real > > &obj, const ROL::Ptr< BoundConstraint< Real > > &bnd, const Vector< Real > &x, ROL::ParameterList &parlist)
ROL::Ptr< Objective< Real > > barrier_
Provides the interface to evaluate objective functions.
std::vector< PV >::size_type size_type
Defines the linear algebra or vector space interface.
virtual Real norm() const =0
Returns where .
virtual void set(const Vector &x)
Set where .
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis,...
virtual void plus(const Vector &x)=0
Compute , where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.