ROL
ROL_LinearObjective_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_LINEAR_OBJECTIVE_DEF_H
11#define ROL_LINEAR_OBJECTIVE_DEF_H
12
13namespace ROL {
14
15template<typename Real>
16LinearObjective<Real>::LinearObjective(const Ptr<const Vector<Real>> &cost) : cost_(cost) {
17 dual_cost_ = cost_->dual().clone();
18 dual_cost_->set(cost_->dual());
19}
20
21template<typename Real>
22Real LinearObjective<Real>::value( const Vector<Real> &x, Real &tol ) {
23 return x.dot(*dual_cost_);
24}
25
26template<typename Real>
28 g.set(*cost_);
29}
30
31template<typename Real>
32void LinearObjective<Real>::hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
33 hv.zero();
34}
35
36} // namespace ROL
37
38#endif
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.
LinearObjective(const Ptr< const Vector< Real > > &cost)
const Ptr< const Vector< Real > > dual_cost_
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
const Ptr< const Vector< Real > > cost_
Defines the linear algebra or vector space interface.
virtual void set(const Vector &x)
Set where .
virtual void zero()
Set to zero vector.
virtual Real dot(const Vector &x) const =0
Compute where .