44 #ifndef ROL_VECTOR_SIMOPT_HPP
45 #define ROL_VECTOR_SIMOPT_HPP
79 void scale(
const Real alpha ) {
98 Real norm1 =
vec1_->norm();
99 Real norm2 =
vec2_->norm();
100 return sqrt( norm1*norm1 + norm2*norm2 );
103 ROL::Ptr<Vector<Real> >
clone()
const {
104 return ROL::makePtr<Vector_SimOpt>(
vec1_->clone(),
vec2_->clone());
114 ROL::Ptr<Vector<Real> >
basis(
const int i )
const {
117 ROL::Ptr<Vector<Real> > e1 = (
vec1_)->
basis(i);
118 ROL::Ptr<Vector<Real> > e2 = (
vec2_)->
clone(); e2->zero();
119 ROL::Ptr<Vector<Real> > e = ROL::makePtr<Vector_SimOpt<Real>>(e1,e2);
123 ROL::Ptr<Vector<Real> > e1 = (
vec1_)->
clone(); e1->zero();
124 ROL::Ptr<Vector<Real> > e2 = (
vec2_)->
basis(i-n1);
125 ROL::Ptr<Vector<Real> > e = ROL::makePtr<Vector_SimOpt<Real>>(e1,e2);
130 void applyUnary(
const Elementwise::UnaryFunction<Real> &f ) {
132 vec1_->applyUnary(f);
133 vec2_->applyUnary(f);
145 Real
reduce(
const Elementwise::ReductionOp<Real> &r )
const {
147 Real result = r.initialValue();
148 r.reduce(
vec1_->reduce(r),result);
149 r.reduce(
vec2_->reduce(r),result);
159 vec1_->randomize(l,u);
160 vec2_->randomize(l,u);
168 ROL::Ptr<const Vector<Real> >
get_1()
const {
172 ROL::Ptr<const Vector<Real> >
get_2()
const {
192 void print( std::ostream &outStream )
const {
193 outStream <<
"Sim: ";
194 vec1_->print(outStream);
195 outStream <<
"Opt: ";
196 vec2_->print(outStream);
200 template<
template<
typename>
class V,
typename Real,
typename P = Ptr<Vector<Real>>>
201 inline typename std::enable_if<std::is_base_of<Vector<Real>,
V<Real>>
::value,P>::type
203 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)
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