10 #ifndef ROL_VECTOR_SIMOPT_HPP
11 #define ROL_VECTOR_SIMOPT_HPP
45 void scale(
const Real alpha ) {
64 Real norm1 =
vec1_->norm();
65 Real norm2 =
vec2_->norm();
66 return sqrt( norm1*norm1 + norm2*norm2 );
69 ROL::Ptr<Vector<Real> >
clone()
const {
70 return ROL::makePtr<Vector_SimOpt>(
vec1_->clone(),
vec2_->clone());
86 ROL::Ptr<Vector<Real> >
basis(
const int i )
const {
89 ROL::Ptr<Vector<Real> > e1 = (
vec1_)->
basis(i);
90 ROL::Ptr<Vector<Real> > e2 = (
vec2_)->
clone(); e2->zero();
91 ROL::Ptr<Vector<Real> > e = ROL::makePtr<Vector_SimOpt<Real>>(e1,e2);
95 ROL::Ptr<Vector<Real> > e1 = (
vec1_)->
clone(); e1->zero();
96 ROL::Ptr<Vector<Real> > e2 = (
vec2_)->
basis(i-n1);
97 ROL::Ptr<Vector<Real> > e = ROL::makePtr<Vector_SimOpt<Real>>(e1,e2);
102 void applyUnary(
const Elementwise::UnaryFunction<Real> &f ) {
104 vec1_->applyUnary(f);
105 vec2_->applyUnary(f);
117 Real
reduce(
const Elementwise::ReductionOp<Real> &r )
const {
119 Real result = r.initialValue();
120 r.reduce(
vec1_->reduce(r),result);
121 r.reduce(
vec2_->reduce(r),result);
131 vec1_->randomize(l,u);
132 vec2_->randomize(l,u);
140 ROL::Ptr<const Vector<Real> >
get_1()
const {
144 ROL::Ptr<const Vector<Real> >
get_2()
const {
164 void print( std::ostream &outStream )
const {
165 outStream <<
"Sim: ";
166 vec1_->print(outStream);
167 outStream <<
"Opt: ";
168 vec2_->print(outStream);
172 template<
template<
typename>
class V,
typename Real,
typename P = Ptr<Vector<Real>>>
173 inline typename std::enable_if<std::is_base_of<Vector<Real>,
V<Real>>
::value,P>::type
175 return makePtr<Vector_SimOpt<Real>>(vsim,vopt);
ROL::Ptr< Vector< Real > > basis(const int i) const
Return i-th basis vector.
Real reduce(const Elementwise::ReductionOp< Real > &r) const
ROL::Ptr< const Vector< Real > > get_2() const
Defines the linear algebra or vector space interface for simulation-based optimization.
ROL::Ptr< Vector< Real > > vec2_
void set_1(const Vector< Real > &vec)
Real dot(const Vector< Real > &x) const
Compute where .
ROL::Objective_SimOpt value
std::enable_if< std::is_base_of< Vector< Real >, V< Real > >::value, P >::type make_Vector_SimOpt(const Ptr< V< Real >> &vsim, const Ptr< V< Real >> &vopt)
void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector< Real > &x)
Real norm() const
Returns where .
void setScalar(const Real C)
Set where .
ROL::Ptr< Vector_SimOpt< Real > > dual_vec_
Defines the linear algebra or vector space interface.
void applyUnary(const Elementwise::UnaryFunction< Real > &f)
Real apply(const Vector< Real > &x) const
Apply to a dual vector. This is equivalent to the call .
ROL::Ptr< Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
void print(std::ostream &outStream) const
void scale(const Real alpha)
Compute where .
ROL::Ptr< Vector< Real > > dual_vec2_
ROL::Ptr< Vector< Real > > vec1_
ROL::Ptr< Vector< Real > > dual_vec1_
void axpy(const Real alpha, const Vector< Real > &x)
Compute where .
ROL::Ptr< Vector< Real > > get_2()
void plus(const Vector< Real > &x)
Compute , where .
void randomize(const Real l=0.0, const Real u=1.0)
Set vector to be uniform random between [l,u].
Vector_SimOpt(const ROL::Ptr< Vector< Real > > &vec1, const ROL::Ptr< Vector< Real > > &vec2)
ROL::Ptr< Vector< Real > > get_1()
void set_2(const Vector< Real > &vec)
const Vector< Real > & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
int dimension() const
Return dimension of the vector space.
ROL::Ptr< const Vector< Real > > get_1() const