ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
nlls
ROL_NonlinearLeastSquaresObjective_Def.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_NONLINEARLEASTSQUARESOBJECTIVE_DEF_H
11
#define ROL_NONLINEARLEASTSQUARESOBJECTIVE_DEF_H
12
13
namespace
ROL
{
14
15
template
<
typename
Real>
16
NonlinearLeastSquaresObjective<Real>::NonlinearLeastSquaresObjective
(
const
Ptr<
Constraint<Real>
> &con,
17
const
Vector<Real>
&optvec,
18
const
Vector<Real>
&convec,
19
const
bool
GNH)
20
:
con_
(con),
GaussNewtonHessian_
(GNH) {
21
c1_
= convec.
clone
();
c1dual_
=
c1_
->dual().clone();
22
c2_
= convec.
clone
();
23
x_
= optvec.
dual
().clone();
24
}
25
26
template
<
typename
Real>
27
void
NonlinearLeastSquaresObjective<Real>::update
(
const
Vector<Real>
&x,
UpdateType
type,
int
iter ) {
28
Real tol = std::sqrt(
ROL_EPSILON<Real>
());
29
con_
->update(x,type,iter);
30
con_
->value(*
c1_
,x,tol);
31
c1dual_
->set(
c1_
->dual());
32
}
33
34
template
<
typename
Real>
35
void
NonlinearLeastSquaresObjective<Real>::update
(
const
Vector<Real>
&x,
bool
flag,
int
iter ) {
36
Real tol = std::sqrt(
ROL_EPSILON<Real>
());
37
con_
->update(x,flag,iter);
38
con_
->value(*
c1_
,x,tol);
39
c1dual_
->set(
c1_
->dual());
40
}
41
42
template
<
typename
Real>
43
Real
NonlinearLeastSquaresObjective<Real>::value
(
const
Vector<Real>
&x, Real &tol ) {
44
Real half(0.5);
45
return
half*(
c1_
->dot(*
c1_
));
46
}
47
48
template
<
typename
Real>
49
void
NonlinearLeastSquaresObjective<Real>::gradient
(
Vector<Real>
&g,
const
Vector<Real>
&x, Real &tol ) {
50
con_
->applyAdjointJacobian(g,*
c1dual_
,x,tol);
51
}
52
53
template
<
typename
Real>
54
void
NonlinearLeastSquaresObjective<Real>::hessVec
(
Vector<Real>
&hv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol ) {
55
con_
->applyJacobian(*
c2_
,v,x,tol);
56
con_
->applyAdjointJacobian(hv,
c2_
->dual(),x,tol);
57
if
( !
GaussNewtonHessian_
) {
58
con_
->applyAdjointHessian(*
x_
,*
c1dual_
,v,x,tol);
59
hv.
plus
(*
x_
);
60
}
61
}
62
63
template
<
typename
Real>
64
void
NonlinearLeastSquaresObjective<Real>::precond
(
Vector<Real>
&Pv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol ) {
65
con_
->applyPreconditioner(Pv,v,x,x.
dual
(),tol);
66
}
67
68
template
<
typename
Real>
69
void
NonlinearLeastSquaresObjective<Real>::setParameter
(
const
std::vector<Real> ¶m) {
70
Objective<Real>::setParameter
(param);
71
con_
->setParameter(param);
72
}
73
74
}
// namespace ROL
75
76
#endif
ROL::NonlinearLeastSquaresObjective::NonlinearLeastSquaresObjective
NonlinearLeastSquaresObjective(const Ptr< Constraint< Real > > &con, const Vector< Real > &optvec, const Vector< Real > &convec, const bool GNH=false)
Constructor.
ROL::NonlinearLeastSquaresObjective::update
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
ROL::NonlinearLeastSquaresObjective::gradient
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
ROL::NonlinearLeastSquaresObjective::setParameter
void setParameter(const std::vector< Real > ¶m) override
ROL::NonlinearLeastSquaresObjective::hessVec
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
ROL::NonlinearLeastSquaresObjective::precond
void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
ROL::NonlinearLeastSquaresObjective::value
Real value(const Vector< Real > &x, Real &tol) override
ROL::Objective::setParameter
virtual void setParameter(const std::vector< Real > ¶m)
Definition
ROL_Objective.hpp:509
ROL::ROL::Constraint
Definition
ROL_Constraint_SerialSimOpt.hpp:52
ROL::ROL::NonlinearLeastSquaresObjective::c1dual_
Ptr< Vector< Real > > c1dual_
Definition
ROL_Constraint_SerialSimOpt.hpp:44
ROL::ROL::NonlinearLeastSquaresObjective::c1_
Ptr< Vector< Real > > c1_
Definition
ROL_Constraint_SerialSimOpt.hpp:44
ROL::ROL::NonlinearLeastSquaresObjective::x_
Ptr< Vector< Real > > x_
Definition
ROL_Constraint_SerialSimOpt.hpp:44
ROL::ROL::NonlinearLeastSquaresObjective::GaussNewtonHessian_
const bool GaussNewtonHessian_
Definition
ROL_Constraint_SerialSimOpt.hpp:42
ROL::ROL::NonlinearLeastSquaresObjective::con_
const Ptr< Constraint< Real > > con_
Definition
ROL_Constraint_SerialSimOpt.hpp:41
ROL::ROL::NonlinearLeastSquaresObjective::c2_
Ptr< Vector< Real > > c2_
Definition
ROL_Constraint_SerialSimOpt.hpp:44
ROL::ROL::Vector
Definition
ROL_Constraint_SerialSimOpt.hpp:51
ROL::ROL::Vector::clone
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
ROL::ROL::Vector::plus
virtual void plus(const Vector &x)=0
Compute , where .
ROL::ROL::Vector::dual
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis,...
Definition
ROL_Constraint_SerialSimOpt.hpp:193
ROL::ROL::UpdateType
UpdateType
Definition
ROL_Constraint_SerialSimOpt.hpp:19
ROL::ROL::ROL_EPSILON
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
Definition
ROL_Constraint_SerialSimOpt.hpp:57
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0