ROL
Loading...
Searching...
No Matches
ROL_PolyhedralProjection_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_POLYHEDRALPROJECTION_DEF_H
11#define ROL_POLYHEDRALPROJECTION_DEF_H
12
13namespace ROL {
14
15template<typename Real>
17 : bnd_(bnd), con_(nullPtr) {}
18
19template<typename Real>
21 const Vector<Real> &xdual,
22 const Ptr<BoundConstraint<Real>> &bnd,
23 const Ptr<Constraint<Real>> &con,
24 const Vector<Real> &mul,
25 const Vector<Real> &res)
26 : bnd_(bnd), con_(con) {
27 xprim_ = xprim.clone();
28 xdual_ = xdual.clone();
29 mul_ = mul.clone();
30 res_ = res.clone();
31 if (con_ != nullPtr) {
32 rcon_ = makePtr<ReducedLinearConstraint<Real>>(con,bnd,xprim_);
33 ns_ = makePtr<NullSpaceOperator<Real>>(rcon_,*xprim_,*res_);
34 }
35}
36
37template<typename Real>
38void PolyhedralProjection<Real>::project(Vector<Real> &x, std::ostream &stream) {
39 if (con_ == nullPtr) {
40 bnd_->project(x);
41 }
42 else {
43 throw Exception::NotImplemented(">>> ROL::PolyhedralProjection::project : No projection implemented!");
44 }
45}
46
47template<typename Real>
49 if (con_ == nullPtr) {
50 bnd_->pruneActive(v,x);
51 }
52 else {
53 rcon_->setX(makePtrFromRef(x));
54 ns_->update(x);
55 Real tol = 0;
56 ns_->apply(v,*xprim_,tol);
57 }
58}
59
60template<typename Real>
61const Ptr<Constraint<Real>> PolyhedralProjection<Real>::getLinearConstraint(void) const {
62 return con_;
63}
64
65template<typename Real>
66const Ptr<BoundConstraint<Real>> PolyhedralProjection<Real>::getBoundConstraint(void) const {
67 return bnd_;
68}
69
70template<typename Real>
71const Ptr<Vector<Real>> PolyhedralProjection<Real>::getMultiplier(void) const {
72 return mul_;
73}
74
75template<typename Real>
76const Ptr<Vector<Real>> PolyhedralProjection<Real>::getResidual(void) const {
77 return res_;
78}
79
80} // namespace ROL
81
82#endif
Provides the interface to apply upper and lower bound constraints.
Defines the general constraint operator interface.
Ptr< ReducedLinearConstraint< Real > > rcon_
const Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
const Ptr< Constraint< Real > > con_
virtual void project(Vector< Real > &x, std::ostream &stream=std::cout)
const Ptr< Vector< Real > > getResidual(void) const
const Ptr< Vector< Real > > getMultiplier(void) const
virtual void applyJacobian(Vector< Real > &v, const Vector< Real > &x)
Ptr< NullSpaceOperator< Real > > ns_
PolyhedralProjection(const Ptr< BoundConstraint< Real > > &bnd)
const Ptr< Constraint< Real > > getLinearConstraint(void) const
Defines the linear algebra or vector space interface.
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.