ROL
ROL_LinearObjective_SimOpt.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_LINEAR_OBJECTIVE_SIMOPT_H
11 #define ROL_LINEAR_OBJECTIVE_SIMOPT_H
12 
13 #include "ROL_Objective_SimOpt.hpp"
14 
29 namespace ROL {
30 
31 template <class Real>
33 private:
34  const Ptr<const Vector<Real>> simcost_, optcost_;
35 
36 public:
37  LinearObjective_SimOpt(const Ptr<const Vector<Real>> &simcost = nullPtr,
38  const Ptr<const Vector<Real>> &optcost = nullPtr)
39  : simcost_(simcost), optcost_(optcost) {}
40 
41  Real value( const Vector<Real> &u, const Vector<Real> &z, Real &tol ) {
42  Real valu(0), valz(0);
43  if (simcost_ != nullPtr) {
44  //valu = u.dot(simcost_->dual());
45  valu = u.apply(*simcost_);
46  }
47  if (optcost_ != nullPtr) {
48  //valz = z.dot(optcost_->dual());
49  valz = z.apply(*optcost_);
50  }
51  return valu + valz;
52  }
53 
54  void gradient_1( Vector<Real> &g, const Vector<Real> &u, const Vector<Real> &z, Real &tol ) {
55  if (simcost_ != nullPtr) {
56  g.set(*simcost_);
57  }
58  else {
59  g.zero();
60  }
61  }
62 
63  void gradient_2( Vector<Real> &g, const Vector<Real> &u, const Vector<Real> &z, Real &tol ) {
64  if (optcost_ != nullPtr) {
65  g.set(*optcost_);
66  }
67  else {
68  g.zero();
69  }
70  }
71 
72  void hessVec_11( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &u, const Vector<Real> &z, Real &tol ) {
73  hv.zero();
74  }
75 
76  void hessVec_12( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &u, const Vector<Real> &z, Real &tol ) {
77  hv.zero();
78  }
79 
80  void hessVec_21( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &u, const Vector<Real> &z, Real &tol ) {
81  hv.zero();
82  }
83 
84  void hessVec_22( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &u, const Vector<Real> &z, Real &tol ) {
85  hv.zero();
86  }
87 
88 }; // class LinearObjective_SimOpt
89 
90 } // namespace ROL
91 
92 #endif
Provides the interface to evaluate simulation-based objective functions.
virtual Real apply(const Vector< Real > &x) const
Apply to a dual vector. This is equivalent to the call .
Definition: ROL_Vector.hpp:204
void hessVec_11(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply Hessian approximation to vector.
virtual void zero()
Set to zero vector.
Definition: ROL_Vector.hpp:133
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
void gradient_2(Vector< Real > &g, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Compute gradient with respect to second component.
void hessVec_22(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Provides the interface to evaluate linear objective functions.
void gradient_1(Vector< Real > &g, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Compute gradient with respect to first component.
LinearObjective_SimOpt(const Ptr< const Vector< Real >> &simcost=nullPtr, const Ptr< const Vector< Real >> &optcost=nullPtr)
void hessVec_12(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
const Ptr< const Vector< Real > > simcost_
void hessVec_21(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:175
const Ptr< const Vector< Real > > optcost_
Real value(const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Compute value.