ROL
ROL_SlacklessObjective.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_SLACKLESSOBJECTIVE_HPP
11 #define ROL_SLACKLESSOBJECTIVE_HPP
12 
13 #include "ROL_Objective.hpp"
15 
22 namespace ROL {
23 
24 template<typename Real>
25 class SlacklessObjective : public Objective<Real> {
26 private:
27  const Ptr<Objective<Real>> obj_;
28 
29 public:
31  SlacklessObjective( const Ptr<Objective<Real>> &obj );
32 
33  Ptr<Objective<Real>> getObjective(void) const;
34 
35  void update( const Vector<Real> &x, UpdateType type, int iter = -1 ) override;
36  void update( const Vector<Real> &x, bool flag = true, int iter = -1 ) override;
37  Real value( const Vector<Real> &x, Real &tol ) override;
38  Real dirDeriv( const Vector<Real> &x, const Vector<Real> &d, Real &tol ) override;
39  void gradient( Vector<Real> &g, const Vector<Real> &x, Real &tol ) override;
40  void hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) override;
41  void invHessVec( Vector<Real> &ihv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) override;
42  void precond( Vector<Real> &Pv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) override;
43 
44 // Definitions for parametrized (stochastic) objective functions
45 public:
46  void setParameter(const std::vector<Real> &param) override;
47 
48 private:
49  Ptr<Vector<Real>> getOpt( Vector<Real> &xs ) const;
50  Ptr<const Vector<Real>> getOpt( const Vector<Real> &xs ) const;
51  void zeroSlack( Vector<Real> &x ) const;
52 }; // class SlacklessObjective
53 
54 } // namespace ROL
55 
57 
58 #endif // ROL_SLACKLESSOBJECTIVE_HPP
59 
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
Real dirDeriv(const Vector< Real > &x, const Vector< Real > &d, Real &tol) override
Compute directional derivative.
Provides the interface to evaluate objective functions.
void setParameter(const std::vector< Real > &param) override
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update objective function.
void zeroSlack(Vector< Real > &x) const
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.
void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply preconditioner to vector.
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
Ptr< Vector< Real > > getOpt(Vector< Real > &xs) const
This class strips out the slack variables from objective evaluations to create the new objective ...
SlacklessObjective(const Ptr< Objective< Real >> &obj)
Ptr< Objective< Real > > getObjective(void) const
const Ptr< Objective< Real > > obj_
void invHessVec(Vector< Real > &ihv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply inverse Hessian approximation to vector.