ROL
ROL_NonlinearLeastSquaresObjective_Dynamic.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 #ifndef ROL_NONLINEARLEASTSQUARESOBJECTIVE_DYNAMIC_H
45 #define ROL_NONLINEARLEASTSQUARESOBJECTIVE_DYNAMIC_H
46 
47 #include "ROL_Objective.hpp"
49 #include "ROL_Types.hpp"
50 
70 namespace ROL {
71 
72 template <class Real>
73 class DynamicConstraint;
74 
75 template <class Real>
77 private:
78  const Ptr<DynamicConstraint<Real>> con_;
79  const Ptr<const Vector<Real>> uo_;
80  const Ptr<const Vector<Real>> z_;
81  const Ptr<const TimeStamp<Real>> ts_;
82  const bool GaussNewtonHessian_;
83 
84  Ptr<Vector<Real> > c1_, c2_, cdual_, udual_;
85 
86 public:
95  const Vector<Real> &c,
96  const Ptr<const Vector<Real>> &uo,
97  const Ptr<const Vector<Real>> &z,
98  const Ptr<const TimeStamp<Real>> &ts,
99  const bool GNH = false)
100  : con_(con), uo_(uo), z_(z), ts_(ts), GaussNewtonHessian_(GNH) {
101  c1_ = c.clone();
102  c2_ = c.clone();
103  cdual_ = c.dual().clone();
104  udual_ = uo->dual().clone();
105  }
106 
107  void update( const Vector<Real> &u, bool flag = true, int iter = -1 ) {
108  //con_->update_un(u,*ts_);
109  con_->update(*uo_,u,*z_,*ts_);
110  con_->value(*c1_,*uo_,u,*z_,*ts_);
111  cdual_->set(c1_->dual());
112  }
113 
114  Real value( const Vector<Real> &x, Real &tol ) {
115  Real half(0.5);
116  return half*(c1_->dot(*cdual_));
117  }
118 
119  void gradient( Vector<Real> &g, const Vector<Real> &u, Real &tol ) {
120  con_->applyAdjointJacobian_un(g,*cdual_,*uo_,u,*z_,*ts_);
121  }
122 
123  void hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &u, Real &tol ) {
124  con_->applyJacobian_un(*c2_,v,*uo_,u,*z_,*ts_);
125  con_->applyAdjointJacobian_un(hv,c2_->dual(),*uo_,u,*z_,*ts_);
126  if ( !GaussNewtonHessian_ ) {
127  con_->applyAdjointHessian_un_un(*udual_,*cdual_,v,*uo_,u,*z_,*ts_);
128  hv.plus(*udual_);
129  }
130  }
131 
132  void precond( Vector<Real> &pv, const Vector<Real> &v, const Vector<Real> &u, Real &tol ) {
133  con_->applyInverseAdjointJacobian_un(*cdual_,v,*uo_,u,*z_,*ts_);
134  con_->applyInverseJacobian_un(pv,cdual_->dual(),*uo_,u,*z_,*ts_);
135  }
136 
137 // Definitions for parametrized (stochastic) equality constraints
138 //public:
139 // void setParameter(const std::vector<Real> &param) {
140 // Objective<Real>::setParameter(param);
141 // con_->setParameter(param);
142 // }
143 };
144 
145 } // namespace ROL
146 
147 #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.
virtual void plus(const Vector &x)=0
Compute , where .
Defines the time-dependent constraint operator interface for simulation-based optimization.
Contains definitions of custom data types in ROL.
NonlinearLeastSquaresObjective_Dynamic(const Ptr< DynamicConstraint< Real >> &con, const Vector< Real > &c, const Ptr< const Vector< Real >> &uo, const Ptr< const Vector< Real >> &z, const Ptr< const TimeStamp< Real >> &ts, const bool GNH=false)
Constructor.
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Contains local time step information.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
void precond(Vector< Real > &pv, const Vector< Real > &v, const Vector< Real > &u, Real &tol)
Apply preconditioner to vector.
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, Real &tol)
Apply Hessian approximation to vector.
void update(const Vector< Real > &u, bool flag=true, int iter=-1)
Update objective function.
void gradient(Vector< Real > &g, const Vector< Real > &u, Real &tol)
Compute gradient.
Provides the interface to evaluate nonlinear least squares objective functions.