ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
sol
function
randvarfunctional
ROL_StochasticConstraint.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_STOCHASTIC_CONSTRAINT_H
11
#define ROL_STOCHASTIC_CONSTRAINT_H
12
13
#include "
ROL_StochasticObjective.hpp
"
14
#include "
ROL_ConstraintFromObjective.hpp
"
15
#include "
ROL_Types.hpp
"
16
17
namespace
ROL
{
18
19
template
<
class
Real>
20
class
StochasticConstraint
:
public
Constraint
<Real> {
21
private
:
22
Ptr<StochasticObjective<Real>>
robj_
;
23
Ptr<Constraint<Real>>
con_
;
24
Ptr<SampleGenerator<Real>>
sampler_
;
25
26
public
:
27
StochasticConstraint
(
const
Ptr<
Objective<Real>
> &obj,
28
const
Ptr<
SampleGenerator<Real>
> &sampler,
29
ParameterList &parlist,
30
const
int
index = 0)
31
:
sampler_
(sampler) {
32
robj_
= makePtr<StochasticObjective<Real>>(obj,parlist,sampler,1,index);
33
con_
= makePtr<ConstraintFromObjective<Real>>(
robj_
);
34
}
35
36
StochasticConstraint
(
const
Ptr<
Constraint<Real>
> &con,
37
const
Ptr<
SampleGenerator<Real>
> &sampler,
38
ParameterList &parlist,
39
const
int
index = 0)
40
:
sampler_
(sampler) {
41
try
{
42
Ptr<ConstraintFromObjective<Real>> cfo
43
= dynamicPtrCast<ConstraintFromObjective<Real>>(con);
44
robj_
= makePtr<StochasticObjective<Real>>(cfo->getObjective(),
45
parlist,sampler,1,index);
46
con_
= makePtr<ConstraintFromObjective<Real>>(
robj_
);
47
}
48
catch
(std::exception &e) {
49
throw
Exception::NotImplemented
(
">>> ROL::StochasticConstraint: Input constraint must be a ConstraintFromObjective!"
);
50
}
51
}
52
53
Real
computeStatistic
(
const
Vector<Real>
&x)
const
{
54
return
robj_
->computeStatistic(x);
55
}
56
57
void
setIndex
(
int
ind) {
58
robj_
->setIndex(ind);
59
}
60
61
void
update
(
const
Vector<Real>
&x,
UpdateType
type,
int
iter = -1) {
62
con_
->update(x,type,iter);
63
}
64
65
void
update
(
const
Vector<Real>
&x,
bool
flag =
true
,
int
iter = -1) {
66
con_
->update(x,flag,iter);
67
}
68
69
void
value
(
Vector<Real>
&c,
const
Vector<Real>
&x, Real &tol) {
70
con_
->value(c,x,tol);
71
}
72
73
void
applyJacobian
(
Vector<Real>
&jv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol) {
74
con_
->applyJacobian(jv,v,x,tol);
75
}
76
77
void
applyAdjointJacobian
(
Vector<Real>
&ajv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol) {
78
con_
->applyAdjointJacobian(ajv,v,x,tol);
79
}
80
81
void
applyAdjointHessian
(
Vector<Real>
&ahuv,
const
Vector<Real>
&u,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol) {
82
con_
->applyAdjointHessian(ahuv,u,v,x,tol);
83
}
84
85
};
// class StochasticConstraint
86
87
}
// namespace ROL
88
89
#endif
ROL_ConstraintFromObjective.hpp
ROL_StochasticObjective.hpp
ROL_Types.hpp
Contains definitions of custom data types in ROL.
ROL::Exception::NotImplemented
Definition
ROL_Types.hpp:884
ROL::Objective
Provides the interface to evaluate objective functions.
Definition
ROL_Objective.hpp:44
ROL::ROL::Constraint::Constraint
Constraint(void)
Definition
ROL_Constraint_SerialSimOpt.hpp:59
ROL::SampleGenerator
Definition
ROL_SampleGenerator.hpp:20
ROL::StochasticConstraint::applyAdjointHessian
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Definition
ROL_StochasticConstraint.hpp:81
ROL::StochasticConstraint::value
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol)
Definition
ROL_StochasticConstraint.hpp:69
ROL::StochasticConstraint::computeStatistic
Real computeStatistic(const Vector< Real > &x) const
Definition
ROL_StochasticConstraint.hpp:53
ROL::StochasticConstraint::robj_
Ptr< StochasticObjective< Real > > robj_
Definition
ROL_StochasticConstraint.hpp:22
ROL::StochasticConstraint::update
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Definition
ROL_StochasticConstraint.hpp:65
ROL::StochasticConstraint::sampler_
Ptr< SampleGenerator< Real > > sampler_
Definition
ROL_StochasticConstraint.hpp:24
ROL::StochasticConstraint::applyJacobian
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Definition
ROL_StochasticConstraint.hpp:73
ROL::StochasticConstraint::StochasticConstraint
StochasticConstraint(const Ptr< Constraint< Real > > &con, const Ptr< SampleGenerator< Real > > &sampler, ParameterList &parlist, const int index=0)
Definition
ROL_StochasticConstraint.hpp:36
ROL::StochasticConstraint::applyAdjointJacobian
void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Definition
ROL_StochasticConstraint.hpp:77
ROL::StochasticConstraint::con_
Ptr< Constraint< Real > > con_
Definition
ROL_StochasticConstraint.hpp:23
ROL::StochasticConstraint::StochasticConstraint
StochasticConstraint(const Ptr< Objective< Real > > &obj, const Ptr< SampleGenerator< Real > > &sampler, ParameterList &parlist, const int index=0)
Definition
ROL_StochasticConstraint.hpp:27
ROL::StochasticConstraint::setIndex
void setIndex(int ind)
Definition
ROL_StochasticConstraint.hpp:57
ROL::StochasticConstraint::update
void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Definition
ROL_StochasticConstraint.hpp:61
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::UpdateType
UpdateType
Definition
ROL_UpdateType.hpp:18
Generated by
1.17.0