44 #ifndef ROL_ALMOST_SURE_CONSTRAINT_H 45 #define ROL_ALMOST_SURE_CONSTRAINT_H 57 const ROL::Ptr<SampleGenerator<Real> >
sampler_;
58 const ROL::Ptr<Constraint<Real> >
con_;
69 : sampler_(sampler), con_(con), isInitialized_(false) {}
79 std::vector<Real> param;
80 for (
int i = 0; i < sampler_->numMySamples(); ++i) {
81 param = sampler_->getMyPoint(i);
82 con_->setParameter(param);
84 con_->value(*(pc.
get(i)), x, tol);
95 std::vector<Real> param;
96 for (
int i = 0; i < sampler_->numMySamples(); ++i) {
97 param = sampler_->getMyPoint(i);
98 con_->setParameter(param);
100 con_->applyJacobian(*(pjv.
get(i)), v, x, tol);
109 if (!isInitialized_) {
110 scratch1_ = ajv.
clone();
111 scratch2_ = ajv.
clone();
112 isInitialized_ =
true;
116 std::vector<Real> param;
117 scratch1_->
zero(); scratch2_->zero();
118 for (
int i = 0; i < sampler_->numMySamples(); ++i) {
119 param = sampler_->getMyPoint(i);
120 con_->setParameter(param);
122 con_->applyAdjointJacobian(*scratch1_, *(pv.
get(i)), x, tol);
123 scratch2_->
plus(*scratch1_);
125 sampler_->sumAll(*scratch2_, ajv);
134 if (!isInitialized_) {
135 scratch1_ = ahuv.
clone();
136 scratch2_ = ahuv.
clone();
137 isInitialized_ =
true;
141 std::vector<Real> param;
142 scratch1_->
zero(); scratch2_->zero();
143 for (
int i = 0; i < sampler_->numMySamples(); ++i) {
144 param = sampler_->getMyPoint(i);
145 con_->setParameter(param);
147 con_->applyAdjointHessian(*scratch1_, *(pu.
get(i)), v, x, tol);
148 scratch2_->
plus(*scratch1_);
150 sampler_->sumAll(*scratch2_, ahuv);
162 std::vector<Real> param;
163 scratch1_->
zero(); scratch2_->zero();
164 for (
int i = 0; i < sampler_->numMySamples(); ++i) {
165 param = sampler_->getMyPoint(i);
166 con_->setParameter(param);
168 con_->applyPreconditioner(*(ppv.
get(i)), *(pv.
get(i)), x, g, tol);
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 .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
const ROL::Ptr< SampleGenerator< Real > > sampler_
ROL::Ptr< Vector< Real > > scratch1_
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 ...
ROL::Ptr< Vector< Real > > scratch2_
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Defines the linear algebra of a vector space on a generic partitioned vector where the individual vec...
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol)
Evaluate the constraint operator at .
AlmostSureConstraint(const ROL::Ptr< SampleGenerator< Real > > &sampler, const ROL::Ptr< Constraint< Real > > &con)
void zero()
Set to zero vector.
void plus(const V &x)
Compute , where .
virtual ~AlmostSureConstraint()
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the constraint Jacobian at , , to vector .
const ROL::Ptr< Constraint< Real > > con_
void applyPreconditioner(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g, Real &tol)
Apply a constraint preconditioner at , , to vector . Ideally, this preconditioner satisfies the follo...
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 ...
ROL::Ptr< const Vector< Real > > get(size_type i) const
Defines the general constraint operator interface.