44 #ifndef ROL_PARAMETRIZED_COMPOSITE_OBJECTIVE_H 45 #define ROL_PARAMETRIZED_COMPOSITE_OBJECTIVE_H 60 const std::vector<Teuchos::RCP<ParametrizedObjective<Real> > >
obj_vec_;
61 const Teuchos::RCP<ParametrizedStdObjective<Real> >
std_obj_;
70 int size = obj_vec_.size();
72 vec_grad_.clear(); vec_grad_.resize(size,Teuchos::null);
73 vec_hess_.clear(); vec_hess_.resize(size,Teuchos::null);
74 for (
int i = 0; i < size; ++i) {
75 vec_grad_[i] = x.
dual().clone();
76 vec_hess_[i] = x.
dual().clone();
78 isInitialized_ =
true;
84 if (!isValueComputed_) {
85 int size = obj_vec_.size();
86 for (
int i = 0; i < size; ++i) {
87 (*obj_value_)[i] = obj_vec_[i]->value(x,tol);
89 isValueComputed_ =
true;
95 if (!isGradientComputed_) {
96 std_obj_->gradient(*(obj_grad_vec_),*(obj_value_vec_),tol);
97 int size = obj_vec_.size();
98 for (
int i = 0; i < size; ++i) {
99 obj_vec_[i]->gradient(*(vec_grad_[i]),x,tol);
101 isGradientComputed_ =
true;
107 int size = obj_vec_.size();
108 for (
int i = 0; i < size; ++i) {
109 (*obj_gv_)[i] = vec_grad_[i]->dot(v.
dual());
110 obj_vec_[i]->hessVec(*(vec_hess_[i]),v,x,tol);
112 std_obj_->hessVec(*(obj_hess_vec_),*(obj_gv_vec_),*(obj_value_vec_),tol);
118 : obj_vec_(obj_vec), std_obj_(std_obj), isInitialized_(false),
119 isValueComputed_(false), isGradientComputed_(false) {
120 obj_value_ = Teuchos::rcp(
new std::vector<Real>(obj_vec_.size(),0));
122 obj_grad_ = Teuchos::rcp(
new std::vector<Real>(obj_vec_.size(),0));
124 obj_gv_ = Teuchos::rcp(
new std::vector<Real>(obj_vec_.size(),0));
126 obj_hess_ = Teuchos::rcp(
new std::vector<Real>(obj_vec_.size(),0));
132 const int size = obj_vec_.size();
133 for (
int i = 0; i < size; ++i) {
134 obj_vec_[i]->setParameter(param);
136 std_obj_->setParameter(param);
137 isValueComputed_ =
false;
138 isGradientComputed_ =
false;
142 int size = obj_vec_.size();
143 for (
int i = 0; i < size; ++i) {
144 obj_vec_[i]->update(x,flag,iter);
146 isValueComputed_ =
false;
152 return std_obj_->value(*obj_value_vec_,tol);
158 int size = obj_vec_.size();
159 for (
int i = 0; i < size; ++i) {
160 g.
axpy((*obj_grad_)[i],*(vec_grad_[i]));
167 int size = obj_vec_.size();
168 for (
int i = 0; i < size; ++i) {
169 hv.
axpy((*obj_grad_)[i],*(vec_hess_[i]));
170 hv.
axpy((*obj_hess_)[i],*(vec_grad_[i]));
void computeValue(const Vector< Real > &x, Real &tol)
Teuchos::RCP< std::vector< Real > > obj_hess_
Specializes the ROL::Objective interface for objective functions that operate on ROL::StdVector's.
const Teuchos::RCP< ParametrizedStdObjective< Real > > std_obj_
Teuchos::RCP< std::vector< Real > > obj_grad_
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
std::vector< Teuchos::RCP< Vector< Real > > > vec_grad_
Teuchos::RCP< std::vector< Real > > obj_value_
Teuchos::RCP< StdVector< Real > > obj_value_vec_
Teuchos::RCP< StdVector< Real > > obj_hess_vec_
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Teuchos::RCP< std::vector< Real > > obj_gv_
void initialize(const Vector< Real > &x)
Teuchos::RCP< StdVector< Real > > obj_gv_vec_
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
void computeGradient(const Vector< Real > &x, Real &tol)
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
const std::vector< Teuchos::RCP< ParametrizedObjective< Real > > > obj_vec_
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
Teuchos::RCP< StdVector< Real > > obj_grad_vec_
Real value(const Vector< Real > &x, Real &tol)
Compute value.
void computeHessVec(const Vector< Real > &v, const Vector< Real > &x, Real &tol)
ParametrizedCompositeObjective(const std::vector< Teuchos::RCP< ParametrizedObjective< Real > > > &obj_vec, const Teuchos::RCP< ParametrizedStdObjective< Real > > &std_obj)
void setParameter(const std::vector< Real > ¶m)
virtual void setParameter(const std::vector< Real > ¶m)
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Provides the interface to evaluate parametrized composite objective functions.
std::vector< Teuchos::RCP< Vector< Real > > > vec_hess_