10 #ifndef ROL_INTERIORPOINT_PRIMALDUAL_RESIDUAL_H
11 #define ROL_INTERIORPOINT_PRIMALDUAL_RESIDUAL_H
13 #include "ROL_Elementwise_Function.hpp"
20 namespace InteriorPoint {
38 template<
class Real>
class PrimalDualSymmetrizer;
42 class PrimalDualResidual :
public Constraint<Real> {
64 ROL::Ptr<LinearOperator<Real> >
sym_;
76 const ROL::Ptr<CON> &eqcon,
77 const ROL::Ptr<CON> &incon,
82 const PV &xpv =
dynamic_cast<const PV&
>(x);
89 sym_ = ROL::makePtr<PrimalDualSymmetrizer<Real>>(*qs_);
93 void value(
V &c,
const V &x, Real &tol ) {
98 PV &cpv =
dynamic_cast<PV&
>(c);
99 const PV &xpv =
dynamic_cast<const PV&
>(x);
101 ROL::Ptr<const V> xo = xpv.
get(
OPT);
102 ROL::Ptr<const V> xs = xpv.
get(
SLACK);
103 ROL::Ptr<const V> xe = xpv.
get(
EQUAL);
104 ROL::Ptr<const V> xi = xpv.
get(
INEQ);
108 ROL::Ptr<V> co = cpv.
get(
OPT);
111 ROL::Ptr<V> ci = cpv.
get(
INEQ);
114 obj_->gradient(*co,*xo,tol);
117 eqcon_->applyAdjointJacobian(*
qo_,*xe,*xo,tol);
120 incon_->applyAdjointJacobian(*
qo_,*xi,*xo,tol);
126 Elementwise::Multiply<Real> mult;
127 cs->applyBinary(mult,*xi);
129 Elementwise::Fill<Real> fill(-
mu_);
130 qs_->applyUnary(fill);
135 eqcon_->value(*ce, *xo, tol);
138 incon_->value(*ci, *xo, tol);
142 sym_->apply(c,c,tol);
143 sym_->applyInverse(c,c,tol);
154 PV &jvpv =
dynamic_cast<PV&
>(jv);
155 const PV &vpv =
dynamic_cast<const PV&
>(v);
156 const PV &xpv =
dynamic_cast<const PV&
>(x);
158 ROL::Ptr<V> jvo = jvpv.
get(
OPT);
161 ROL::Ptr<V> jvi = jvpv.
get(
INEQ);
163 ROL::Ptr<const V> vo = vpv.
get(
OPT);
164 ROL::Ptr<const V> vs = vpv.
get(
SLACK);
165 ROL::Ptr<const V> ve = vpv.
get(
EQUAL);
166 ROL::Ptr<const V> vi = vpv.
get(
INEQ);
168 ROL::Ptr<const V> xo = xpv.
get(
OPT);
169 ROL::Ptr<const V> xs = xpv.
get(
SLACK);
170 ROL::Ptr<const V> xe = xpv.
get(
EQUAL);
171 ROL::Ptr<const V> xi = xpv.
get(
INEQ);
174 obj_->hessVec(*jvo,*vo,*xo,tol);
176 eqcon_->applyAdjointHessian(*
qo_,*xe,*vo,*xo,tol);
178 jvo->axpy(-1.0,*
qo_);
180 incon_->applyAdjointHessian(*
qo_,*xi,*vo,*xo,tol);
182 jvo->axpy(-1.0,*
qo_);
184 eqcon_->applyAdjointJacobian(*
qo_,*ve,*xo,tol);
186 jvo->axpy(-1.0,*
qo_);
188 incon_->applyAdjointJacobian(*
qo_,*vi,*xo,tol);
190 jvo->axpy(-1.0,*
qo_);
196 Elementwise::Multiply<Real> mult;
198 jvs->applyBinary(mult,*xi);
202 qs_->applyBinary(mult,*xs);
207 eqcon_->applyJacobian(*jve,*vo,*xo,tol);
210 incon_->applyJacobian(*jvi,*vo,*xo,tol);
215 sym_->apply(jv,jv,tol);
216 sym_->applyInverse(jv,jv,tol);
255 void update(
const V& s,
bool flag =
true,
int iter = -1 ) {
259 void apply(
V &Hv,
const V &v, Real &tol )
const {
264 const PV &vpv =
dynamic_cast<const PV&
>(v);
265 PV &Hvpv =
dynamic_cast<PV&
>(Hv);
267 ROL::Ptr<const V> vo = vpv.
get(
OPT);
268 ROL::Ptr<const V> vs = vpv.
get(
SLACK);
269 ROL::Ptr<const V> ve = vpv.
get(
EQUAL);
270 ROL::Ptr<const V> vi = vpv.
get(
INEQ);
272 ROL::Ptr<V> Hvo = Hvpv.
get(
OPT);
275 ROL::Ptr<V> Hvi = Hvpv.
get(
INEQ);
280 Elementwise::Divide<Real> div;
281 Hvs->applyBinary(div,*
s_);
296 const PV &vpv =
dynamic_cast<const PV&
>(v);
297 PV &Hvpv =
dynamic_cast<PV&
>(Hv);
299 ROL::Ptr<const V> vo = vpv.
get(
OPT);
300 ROL::Ptr<const V> vs = vpv.
get(
SLACK);
301 ROL::Ptr<const V> ve = vpv.
get(
EQUAL);
302 ROL::Ptr<const V> vi = vpv.
get(
INEQ);
304 ROL::Ptr<V> Hvo = Hvpv.
get(
OPT);
307 ROL::Ptr<V> Hvi = Hvpv.
get(
INEQ);
312 Elementwise::Multiply<Real> mult;
313 Hvs->applyBinary(mult,*
s_);
334 #endif // ROL_INTERIORPOINT_PRIMALDUAL_RESIDUAL_H
Provides the interface to evaluate objective functions.
static const size_type OPT
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
void apply(V &Hv, const V &v, Real &tol) const
Apply linear operator.
ROL::Ptr< const Vector< Real > > get(size_type i) const
static const size_type SLACK
Defines the linear algebra of vector space on a generic partitioned vector.
ROL::Ptr< LinearOperator< Real > > sym_
static const size_type EQUAL
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
PrimalDualSymmetrizer(const V &s)
static const size_type INEQ
static const size_type OPT
PartitionedVector< Real > PV
void applyInverse(V &Hv, const V &v, Real &tol) const
Apply inverse of linear operator.
void value(V &c, const V &x, Real &tol)
Evaluate the constraint operator at .
void updatePenalty(Real mu)
static const size_type EQUAL
Provides the interface to apply a linear operator.
PrimalDualResidual(const ROL::Ptr< OBJ > &obj, const ROL::Ptr< CON > &eqcon, const ROL::Ptr< CON > &incon, const V &x)
std::vector< PV >::size_type size_type
PartitionedVector< Real > PV
static const size_type INEQ
void applyJacobian(V &jv, const V &v, const V &x, Real &tol)
Apply the constraint Jacobian at , , to vector .
Defines the general constraint operator interface.
void update(const V &s, bool flag=true, int iter=-1)
Update linear operator.
static const size_type SLACK