ROL
step/trustregion/ROL_SemismoothNewtonDualModel.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#pragma once
11#ifndef ROL_SEMISMOOTHNEWTONDUALMODEL_HPP
12#define ROL_SEMISMOOTHNEWTONDUALMODEL_HPP
13
18
32namespace ROL {
33
34
35template<class Real>
36class SemismoothNewtonDualModel : public TrustRegionModel<Real> {
37
38 using V = Vector<Real>;
39 using VPrim = InactiveSet_PrimalVector<Real>;
40 using VDual = InactiveSet_DualVector<Real>;
41
42 using Obj = Objective<Real>;
43 using Sec = Secant<Real>;
44 using Bnd = BoundConstraint<Real>;
45
46private:
47
48 class ProjectedObjective : public Objective<Real> {
49 private:
50 Obj& objPrimal_;
51 Bnd& bnd_;
52 Ptr<V> primalVec_;
53
54 public:
55 ProjectedObjective( Obj& objPrimal, Bnd& bnd, const Ptr<V>& primalVec ) :
56 objPrimal_(objPrimal), bnd_(bnd), primalVec_( primalVec ) {}
57
58 Real value( const V& p, Real& tol ) override {
59 primalVec_->set(p);
60 bnd_.project(*primalVec_);
61 return objPrimal_->value(*primalVec_, tol);
62 }
63
64 void gradient( V& g, const V& p, Real& tol ) override {
65 primalVec_->set(p);
66 bnd_.project(*primalVec_);
67 objPrimal_->gradient(g,*primalVec_, tol);
68 }
69
70 void hessVec( V& hv, const V& v, const V& p, Real& tol ) override {
71 primalVec_->set(p);
72 bnd_.project(*primalVec_);
73 objPrimal_->hessVec(hv,v,*primalVec_, tol);
74 }
75
76 }; // ProjectedObjective
77
78 ProjectedObjective projObj_;
79 Bnd bnd_;
80 Sec secant_;
81 Ptr<V> p_, g_, x_;
82 Ptr<V> ones_;
83 Ptr<VPrim> s_;
84 Real alpha_;
85
87
88
89public:
90
91 SemismoothNewtonDualModel( Obj& obj, Bnd& bnd, const V& p, const V& g, const Real alpha ) :
92 TrustRegionModel( obj, p, g, false ), bnd_( bnd ),
93 p_( p.clone() ), g_( p.dual().clone() ), x_( p.clone() ), ones_( p.clone() ),
94 s_( p.clone(), ones_, p_, bnd_ ), projObj_( obj, bnd, p_ ), alpha_(alpha) {
95
96 ones_->setScalar( Real(1.0) );
97 }
98
99
100 Real value( const V& s, Real& tol ) {
101
102 auto hs = workspace_.clone(*g_);
103
104 gradient(*g_,s,tol);
105 hessVec(*hs,s,s,tol);
106 hs->scale( 0.5 );
107 hs->plus(*g_);
108 s_->set(s);
109 return s_->dot(*hs);
110 }
111
112 void gradient( V& g, const V& s, Real& tol ) {
113 projObj_->gradient(g,*p_,tol);
114 g.axpy(alpha_,*p_);
115 }
116
117 void hessVec( V& hv, const V& v, const V& s, Real& tol ) {
118 auto vprune_ = workspace_.copy(v);
119 bnd_->pruneActive( *vprune_, *p_ );
120 projObj_->hessVec( hv, *vprune_, *p_, tol );
121 hv.axpy(alpha_,v);
122 }
123
124 void update( const V& p, bool flag = true, int iter = -1 ) {
125 p_->set(p);
126 auto x = this->getIterate();
127 }
128
129} // namespace ROL
130
Vector< Real > V
Objective_TimeSimOpt< Real > Obj
VectorWorkspace< Real > workspace_
Implements the dual variable model function for a semismooth Newton step.
Provides a "smart" cloning manager to be used a member variable in a class and called in the member f...
void value(ROL::Vector< Real > &c, const ROL::Vector< Real > &sol, const Real &mu)