ROL
ROL_LogBarrierObjective.hpp
Go to the documentation of this file.
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions are
3// met:
4//
5// 1. Redistributions of source code must retain the above copyright
6// notice, this list of conditions and the following disclaimer.
7//
8// 2. Redistributions in binary form must reproduce the above copyright
9// notice, this list of conditions and the following disclaimer in the
10// documentation and/or other materials provided with the distribution.
11//
12// 3. Neither the name of the Corporation nor the names of the
13// contributors may be used to endorse or promote products derived from
14// this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
17// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
20// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27//
28// Questions? Contact lead developers:
29// Drew Kouri (dpkouri@sandia.gov) and
30// Denis Ridzal (dridzal@sandia.gov)
31//
32// ************************************************************************
33// @HEADER
34
35#ifndef ROL_LOG_BARRIER_OBJECTIVE_H
36#define ROL_LOG_BARRIER_OBJECTIVE_H
37
38#include "ROL_Objective.hpp"
39
45namespace ROL {
46
47template <class Real>
48class LogBarrierObjective : public Objective<Real> {
49public:
50
51
52
53 /* \brief Objective value J(x) = \f$-\sum_i \log(x_i) \f$ */
54 Real value( const Vector<Real> &x, Real &tol ) {
55
56 ROL::Ptr<Vector<Real> > logx = x.clone();
57 logx->set(x);
58
59 Elementwise::Logarithm<Real> log;
60
61 logx->applyUnary(log);
62
63 Elementwise::ReductionSum<Real> sum;
64
65 Real result = -(logx->reduce(sum));
66
67 return result;
68 }
69
70 /* \brief gradient g_i = \f$ 1/x_i \f$ */
71 void gradient( Vector<Real> &g, const Vector<Real> &x, Real &tol ) {
72
73 g.set(x);
74
75 Elementwise::Reciprocal<Real> reciprocal;
76
77 g.applyUnary(reciprocal);
78 g.scale(-1.0);
79 }
80
81 Real dirDeriv( const Vector<Real> &x, const Vector<Real> &d, Real &tol ) {
82
83 ROL::Ptr<Vector<Real> > dbyx = d.clone();
84 dbyx->set(x);
85
86 struct Division : public Elementwise::BinaryFunction<Real> {
87 Real apply( const Real &xc, const Real &dc ) const {
88 return dc/xc;
89 }
90 } division;
91
92 dbyx->applyBinary( division, d );
93
94 Elementwise::ReductionSum<Real> sum;
95
96 return -dbyx->reduce(sum);
97 }
98
99 void hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
100 hv.set(v);
101
102 struct HessianApply : public Elementwise::BinaryFunction<Real> {
103 Real apply( const Real &vc, const Real &xc ) const {
104 return vc/(xc*xc);
105 }
106 } hessian;
107
108 hv.applyBinary(hessian,x);
109
110 }
111
112};
113
114} // namespace ROL
115
116#endif // ROL_LOG_BARRIER_OBJECTIVE_H
Log barrier objective for interior point methods.
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Real dirDeriv(const Vector< Real > &x, const Vector< Real > &d, Real &tol)
Compute directional derivative.
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.
Provides the interface to evaluate objective functions.
Defines the linear algebra or vector space interface.
virtual void set(const Vector &x)
Set where .
virtual void applyUnary(const Elementwise::UnaryFunction< Real > &f)
virtual void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector &x)
virtual void scale(const Real alpha)=0
Compute where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
ROL::BlockOperator2Diagonal BlockOperator2 apply(V &Hv, const V &v, Real &tol) const