44 #ifndef ROL_LINEARCOMBINATIONOBJECTIVE_SIMOPT_H 45 #define ROL_LINEARCOMBINATIONOBJECTIVE_SIMOPT_H 48 #include "Teuchos_RCP.hpp" 55 const std::vector<Teuchos::RCP<Objective_SimOpt<Real> > >
obj_;
65 udual_(Teuchos::null), zdual_(Teuchos::null),
66 uinitialized_(false), zinitialized_(false) {
68 weights_.clear(); weights_.assign(size_,static_cast<Real>(1));
74 weights_(weights), size_(weights.size()),
75 udual_(Teuchos::null), zdual_(Teuchos::null),
76 uinitialized_(false), zinitialized_(false) {}
79 for (
size_t i=0; i<
size_; ++i) {
80 obj_[i]->update(u,z,flag,iter);
86 for (
size_t i = 0; i <
size_; ++i) {
87 val += weights_[i]*obj_[i]->value(u,z,tol);
98 for (
size_t i = 0; i <
size_; ++i) {
99 obj_[i]->gradient_1(*udual_,u,z,tol);
100 g.
axpy(weights_[i],*udual_);
105 if (!zinitialized_) {
107 zinitialized_ =
true;
110 for (
size_t i = 0; i <
size_; ++i) {
111 obj_[i]->gradient_2(*zdual_,u,z,tol);
112 g.
axpy(weights_[i],*zdual_);
117 if (!uinitialized_) {
119 uinitialized_ =
true;
122 for (
size_t i = 0; i <
size_; ++i) {
123 obj_[i]->hessVec_11(*udual_,v,u,z,tol);
124 hv.
axpy(weights_[i],*udual_);
129 if (!uinitialized_) {
131 uinitialized_ =
true;
134 for (
size_t i = 0; i <
size_; ++i) {
135 obj_[i]->hessVec_12(*udual_,v,u,z,tol);
136 hv.
axpy(weights_[i],*udual_);
141 if (!zinitialized_) {
143 zinitialized_ =
true;
146 for (
size_t i = 0; i <
size_; ++i) {
147 obj_[i]->hessVec_21(*zdual_,v,u,z,tol);
148 hv.
axpy(weights_[i],*zdual_);
153 if (!zinitialized_) {
155 zinitialized_ =
true;
158 for (
size_t i = 0; i <
size_; ++i) {
159 obj_[i]->hessVec_22(*zdual_,v,u,z,tol);
160 hv.
axpy(weights_[i],*zdual_);
168 for (
size_t i = 0; i <
size_; ++i) {
169 obj_[i]->setParameter(param);
void hessVec_12(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Provides the interface to evaluate simulation-based objective functions.
void update(const Vector< Real > &u, const Vector< Real > &z, bool flag=true, int iter=-1)
Update objective function. u is an iterate, z is an iterate, flag = true if the iterate has changed...
const double weights[4][5]
Real value(const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Compute value.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
void setParameter(const std::vector< Real > ¶m)
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
void hessVec_22(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
const std::vector< Teuchos::RCP< Objective_SimOpt< Real > > > obj_
void gradient_1(Vector< Real > &g, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Compute gradient with respect to first component.
LinearCombinationObjective_SimOpt(const std::vector< Teuchos::RCP< Objective_SimOpt< Real > > > &obj)
void hessVec_21(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
LinearCombinationObjective_SimOpt(const std::vector< Real > &weights, const std::vector< Teuchos::RCP< Objective_SimOpt< Real > > > &obj)
void gradient_2(Vector< Real > &g, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Compute gradient with respect to second component.
Teuchos::RCP< Vector< Real > > udual_
virtual void setParameter(const std::vector< Real > ¶m)
void hessVec_11(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply Hessian approximation to vector.
Teuchos::RCP< Vector< Real > > zdual_
std::vector< Real > weights_