19 #ifndef ROL_POISSONCONTROL_HPP
20 #define ROL_POISSONCONTROL_HPP
63 Real h = 1.0/((Real)n+1.0);
64 for (
uint i=0; i<n; i++) {
66 (*Mzp)[i] = h/6.0*(4.0*(*zp)[i] + (*zp)[i+1]);
68 else if ( i == n-1 ) {
69 (*Mzp)[i] = h/6.0*((*zp)[i-1] + 4.0*(*zp)[i]);
72 (*Mzp)[i] = h/6.0*((*zp)[i-1] + 4.0*(*zp)[i] + (*zp)[i+1]);
85 Real h = 1.0/((Real)n+1.0);
86 SV b( ROL::makePtr<vector>(n,0.0) );
95 (*up)[0] = (*bp)[0]/d;
96 for (
uint i = 1; i < n; i++ ) {
97 m = 1.0/(d - o*c[i-1]);
99 (*up)[i] = ( (*bp)[i] - o*(*up)[i-1] )*m;
101 for (
uint i = n-1; i > 0; i-- ) {
102 (*up)[i-1] = (*up)[i-1] - c[i-1]*(*up)[i];
107 Real val = 1.0/3.0*std::pow(x,4.0) - 2.0/3.0*std::pow(x,3.0) + 1.0/3.0*x + 8.0*
alpha_;
115 ROL::Ptr<const vector> zp =
getVector(z);
117 Real h = 1.0/((Real)n+1.0);
119 SV u( ROL::makePtr<vector>(n,0.0) );
128 for (
uint i=0; i<n; i++) {
131 res *= h/6.0*(4.0*(*zp)[i] + (*zp)[i+1]);
134 res += h/6.0*(4.0*res1 + res2)*res1;
136 else if ( i == n-1 ) {
137 res *= h/6.0*((*zp)[i-1] + 4.0*(*zp)[i]);
140 res += h/6.0*(res1 + 4.0*res2)*res2;
143 res *= h/6.0*((*zp)[i-1] + 4.0*(*zp)[i] + (*zp)[i+1]);
147 res += h/6.0*(res1 + 4.0*res2 + res3)*res2;
158 ROL::Ptr<const vector> zp =
getVector(z);
162 Real h = 1.0/((Real)n+1.0);
165 SV u( ROL::makePtr<vector>(n,0.0) );
173 for (
uint i=0; i<n; i++) {
177 SV p( ROL::makePtr<vector>(n,0.0) );
184 for (
uint i=0; i<n; i++) {
186 res1 =
alpha_*(*zp)[i] - (*pp)[i];
187 res2 =
alpha_*(*zp)[i+1] - (*pp)[i+1];
188 (*gp)[i] = h/6.0*(4.0*res1 + res2);
190 else if ( i == n-1 ) {
191 res1 =
alpha_*(*zp)[i-1] - (*pp)[i-1];
192 res2 =
alpha_*(*zp)[i] - (*pp)[i];
193 (*gp)[i] = h/6.0*(res1 + 4.0*res2);
196 res1 =
alpha_*(*zp)[i-1] - (*pp)[i-1];
197 res2 =
alpha_*(*zp)[i] - (*pp)[i];
198 res3 =
alpha_*(*zp)[i+1] - (*pp)[i+1];
199 (*gp)[i] = h/6.0*(res1 + 4.0*res2 + res3);
208 ROL::Ptr<const vector> zp =
getVector(z);
209 ROL::Ptr<const vector> vp =
getVector(v);
213 Real h = 1.0/((Real)n+1.0);
216 SV u( ROL::makePtr<vector>(n,0.0) );
221 SV p( ROL::makePtr<vector>(n,0.0) );
229 for (
uint i=0; i<n; i++) {
231 res1 =
alpha_*(*vp)[i] + (*pp)[i];
232 res2 =
alpha_*(*vp)[i+1] + (*pp)[i+1];
233 (*hvp)[i] = h/6.0*(4.0*res1 + res2);
235 else if ( i == n-1 ) {
236 res1 =
alpha_*(*vp)[i-1] + (*pp)[i-1];
237 res2 =
alpha_*(*vp)[i] + (*pp)[i];
238 (*hvp)[i] = h/6.0*(res1 + 4.0*res2);
241 res1 =
alpha_*(*vp)[i-1] + (*pp)[i-1];
242 res2 =
alpha_*(*vp)[i] + (*pp)[i];
243 res3 =
alpha_*(*vp)[i+1] + (*pp)[i+1];
244 (*hvp)[i] = h/6.0*(res1 + 4.0*res2 + res3);
258 return ROL::makePtr<Objective_PoissonControl<Real>>();
265 ROL::Ptr<std::vector<Real> > x0p = ROL::makePtr<std::vector<Real>>(n,0.0);
266 for (
int i=0; i<n; i++) {
269 return ROL::makePtr<StdVector<Real>>(x0p);
276 ROL::Ptr<std::vector<Real> > xp = ROL::makePtr<std::vector<Real>>(n,0.0);
277 Real h = 1.0/((Real)n+1.0), pt = 0.0;
278 for(
int i = 0; i < n; i++ ) {
280 (*xp)[i] = 4.0*pt*(1.0-pt);
282 return ROL::makePtr<StdVector<Real>>(xp);
Provides the interface to evaluate objective functions.
typename PV< Real >::size_type size_type
Ptr< Vector< Real > > getSolution(const int i=0) const
Objective_PoissonControl(Real alpha=1.e-4)
Real value(const Vector< Real > &z, Real &tol)
Compute value.
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
Defines the linear algebra or vector space interface.
std::vector< Real > vector
Ptr< Objective< Real > > getObjective(void) const
void solve_poisson(Vector< Real > &u, const Vector< Real > &z)
void gradient(Vector< Real > &g, const Vector< Real > &z, Real &tol)
Compute gradient.
Poisson distributed control.
Contains definitions of test objective functions.
void apply_mass(Vector< Real > &Mz, const Vector< Real > &z)
ROL::Ptr< const vector > getVector(const V &x)
Ptr< Vector< Real > > getInitialGuess(void) const
Real evaluate_target(Real x)
ROL::Ptr< vector > getVector(V &x)