41 #ifndef ROL_INTERIORPOINT_H 42 #define ROL_INTERIORPOINT_H 50 namespace InteriorPoint {
64 const static size_type
OPT = 0;
65 const static size_type
SLACK = 1;
67 Teuchos::RCP<Objective<Real> >
obj_;
89 obj_(obj), slack_barrier_(slack_barrier), bc_barrier_(Teuchos::null),
90 x_(Teuchos::null), g_(Teuchos::null), scratch_(Teuchos::null),
91 mu_(mu), nfval_(0), ngval_(0), fval_(0.0), gnorm_(0.0),
92 hasBoundConstraint_(false) {
94 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
96 x_ = Teuchos::rcp_static_cast<PV>(xpv.
clone());
97 g_ = Teuchos::rcp_static_cast<PV>(xpv.
dual().
clone());
107 obj_(obj), slack_barrier_(slack_barrier), bc_barrier_(bc_barrier),
108 x_(Teuchos::null), g_(Teuchos::null), scratch_(Teuchos::null),
109 mu_(mu), nfval_(0), ngval_(0), fval_(0.0), gnorm_(0.0),
110 hasBoundConstraint_(true) {
112 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
114 x_ = Teuchos::rcp_static_cast<PV>(xpv.
clone());
115 g_ = Teuchos::rcp_static_cast<PV>(xpv.
dual().
clone());
117 scratch_ = g_->get(OPT)->clone();
136 nfval_ = 0.; nfval_ = 0.;
149 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
151 Teuchos::RCP<const V> xo = xpv.
get(OPT);
152 Teuchos::RCP<const V> xs = xpv.
get(SLACK);
154 obj_->update(*xo,flag,iter);
155 slack_barrier_->update(*xs,flag,iter);
157 if(hasBoundConstraint_) {
158 bc_barrier_->update(*xo,flag,iter);
171 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
173 Teuchos::RCP<const V> xo = xpv.
get(OPT);
174 Teuchos::RCP<const V> xs = xpv.
get(SLACK);
179 fval_ = obj_->value(*xo,tol);
180 Real pval = slack_barrier_->value(*xs,tol);
182 val = fval_ + mu_*pval;
184 if( hasBoundConstraint_ ) {
185 Real bval = bc_barrier_->value(*xo,tol);
209 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
210 PV &gpv = Teuchos::dyn_cast<PV>(g);
212 Teuchos::RCP<const V> xo = xpv.
get(OPT);
213 Teuchos::RCP<const V> xs = xpv.
get(SLACK);
215 Teuchos::RCP<V> go = gpv.get(OPT);
216 Teuchos::RCP<V> gs = gpv.get(SLACK);
218 obj_->gradient(*go,*xo,tol);
220 if( hasBoundConstraint_ ) {
221 bc_barrier_->gradient(*scratch_,*xo,tol);
222 scratch_->scale(mu_);
226 slack_barrier_->gradient(*gs,*xs,tol);
258 using Teuchos::RCP;
using Teuchos::dyn_cast;
260 const PV &xpv = dyn_cast<
const PV>(x);
261 const PV &vpv = dyn_cast<
const PV>(v);
262 PV &hvpv = dyn_cast<PV>(hv);
264 RCP<const V> xo = xpv.
get(OPT);
265 RCP<const V> xs = xpv.
get(SLACK);
267 RCP<const V> vo = vpv.get(OPT);
268 RCP<const V> vs = vpv.get(SLACK);
270 RCP<V> hvo = hvpv.get(OPT);
271 RCP<V> hvs = hvpv.get(SLACK);
273 obj_->hessVec(*hvo, *vo, *xo, tol);
275 if( hasBoundConstraint_ ) {
276 bc_barrier_->hessVec(*scratch_,*vo,*xo,tol);
277 scratch_->scale(mu_);
278 hvo->plus(*scratch_);
282 slack_barrier_->hessVec(*hvs, *vs, *xs, tol);
305 const static size_type
OPT = 0;
308 const static size_type INEQ = 0;
309 const static size_type EQUAL = 1;
311 Teuchos::RCP<InequalityConstraint<Real> >
incon_;
312 Teuchos::RCP<EqualityConstraint<Real> >
eqcon_;
323 incon_(incon), eqcon_(eqcon),
324 hasEquality_(true), ncval_(0) { }
328 incon_(incon), eqcon_(Teuchos::null),
329 hasEquality_(false), ncval_(0) { }
338 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
340 Teuchos::RCP<const V> xo = xpv.
get(OPT);
341 Teuchos::RCP<const V> xs = xpv.
get(SLACK);
343 incon_->update(*xo,flag,iter);
346 eqcon_->update(*xo,flag,iter);
353 PV &cpv = Teuchos::dyn_cast<PV>(c);
354 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
356 Teuchos::RCP<const V> xo = xpv.get(OPT);
357 Teuchos::RCP<const V> xs = xpv.get(SLACK);
359 Teuchos::RCP<V> ci = cpv.
get(INEQ);
362 incon_->value(*ci, *xo, tol);
367 eqcon_->value(*ce, *xo, tol);
379 using Teuchos::RCP;
using Teuchos::dyn_cast;
382 const PV &xpv = dyn_cast<
const PV>(x);
383 const PV &vpv = dyn_cast<
const PV>(v);
385 RCP<const V> xo = xpv.
get(OPT);
386 RCP<const V> xs = xpv.
get(SLACK);
388 RCP<const V> vo = vpv.get(OPT);
389 RCP<const V> vs = vpv.get(SLACK);
391 PV &jvpv = dyn_cast<PV>(jv);
393 RCP<V> jvi = jvpv.
get(INEQ);
394 incon_->applyJacobian(*jvi, *vo, *xo, tol);
398 RCP<V> jve = jvpv.
get(EQUAL);
399 eqcon_->applyJacobian(*jve, *vo, *xo, tol);
409 using Teuchos::RCP;
using Teuchos::dyn_cast;
412 const PV &xpv = dyn_cast<
const PV>(x);
413 PV &ajvpv = dyn_cast<PV>(ajv);
415 RCP<const V> xo = xpv.
get(OPT);
416 RCP<const V> xs = xpv.
get(SLACK);
418 RCP<V> ajvo = ajvpv.get(OPT);
419 RCP<V> ajvs = ajvpv.get(SLACK);
421 const PV &vpv = dyn_cast<
const PV>(v);
423 RCP<const V> vi = vpv.
get(INEQ);
425 incon_->applyAdjointJacobian(*ajvo,*vi,*xo,tol);
432 RCP<const V> ve = vpv.
get(EQUAL);
433 RCP<V> temp = ajvo->clone();
434 eqcon_->applyAdjointJacobian(*temp,*ve,*xo,tol);
447 using Teuchos::RCP;
using Teuchos::dyn_cast;
449 const PV &xpv = dyn_cast<
const PV>(x);
450 const PV &vpv = dyn_cast<
const PV>(v);
451 PV &ahuvpv = dyn_cast<PV>(ahuv);
453 RCP<const V> xo = xpv.
get(OPT);
454 RCP<const V> xs = xpv.
get(SLACK);
456 RCP<const V> vo = vpv.get(OPT);
458 RCP<V> ahuvo = ahuvpv.get(OPT);
459 RCP<V> ahuvs = ahuvpv.get(SLACK);
461 RCP<V> temp = ahuvo->clone();
463 const PV &upv = dyn_cast<
const PV>(u);
465 RCP<const V> ui = upv.
get(INEQ);
467 incon_->applyAdjointHessian(*ahuvo,*ui,*vo,*xo,tol);
471 RCP<const V> ue = upv.
get(EQUAL);
472 eqcon_->applyAdjointHessian(*temp,*ue,*vo,*xo,tol);
Provides the interface to evaluate objective functions.
int getNumberFunctionEvaluations(void)
static const size_type SLACK
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the derivative of the adjoint of the constraint Jacobian at to vector in direction ...
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
PartitionedVector< Real > PV
CompositeConstraint(const Teuchos::RCP< InequalityConstraint< Real > > &incon, const Teuchos::RCP< EqualityConstraint< Real > > &eqcon)
void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the adjoint of the the constraint Jacobian at , , to vector .
void getObjectiveGradient(Vector< Real > &g)
Defines the linear algebra of vector space on a generic partitioned vector.
Has both inequality and equality constraints. Treat inequality constraint as equality with slack vari...
const V & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
PartitionedVector< Real > PV
Teuchos::RCP< V > scratch_
int getNumberConstraintEvaluations(void)
int getNumberGradientEvaluations(void)
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
static const size_type OPT
Defines the linear algebra or vector space interface.
PenalizedObjective(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Objective< Real > > &slack_barrier, const Vector< Real > &x, Real mu)
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Defines the equality constraint operator interface.
Teuchos::RCP< const Vector< Real > > get(size_type i) const
PenalizedObjective(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Objective< Real > > &slack_barrier, const Teuchos::RCP< Objective< Real > > &bc_barrier, const Vector< Real > &x, Real mu)
CompositeConstraint(const Teuchos::RCP< InequalityConstraint< Real > > &incon)
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update barrier penalized objective function.
Teuchos::RCP< InequalityConstraint< Real > > incon_
Teuchos::RCP< Objective< Real > > slack_barrier_
void updatePenalty(Real mu)
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the constraint Jacobian at , , to vector .
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
RCPV clone() const
Clone to make a new (uninitialized) vector.
std::vector< PV >::size_type size_type
Teuchos::RCP< Objective< Real > > obj_
Provides a unique argument for inequality constraints, which otherwise behave exactly as equality con...
virtual Real norm() const =0
Returns where .
Teuchos::RCP< Objective< Real > > bc_barrier_
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update constraint functions. x is the optimization variable, flag = true if optimization variable is ...
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol)
Evaluate the constraint operator at .
Teuchos::RCP< EqualityConstraint< Real > > eqcon_