10 #ifndef ROL_LINEARREGRESSION_H
11 #define ROL_LINEARREGRESSION_H
18 #include "ROL_Problem.hpp"
35 const Ptr<RegressionError<Real>>
error_;
36 const Ptr<SampleGenerator<Real>>
data_;
38 Ptr<RandVarFunctional<Real>>
em_;
39 Ptr<StochasticObjective<Real>>
obj_;
41 Ptr<RiskVector<Real>>
c_;
45 Ptr<BoundConstraint<Real>>
bnd_;
46 Ptr<RiskBoundConstraint<Real>>
rbnd_;
55 int dim =
data_->getMyPoint(0).size();
56 cdata_ = makePtr<std::vector<Real>>(
dim,0);
57 c_ = makePtr<RiskVector<Real>>(makePtr<StdVector<Real>>(
cdata_));
62 em_ = ErrorMeasureFactory<Real>(parlist);
69 lower_ = makePtr<std::vector<Real>>(lower);
73 upper_ = makePtr<std::vector<Real>>(upper);
86 bnd_ = makePtr<StdBoundConstraint<Real>>(*
lower_,
true);
89 bnd_ = makePtr<StdBoundConstraint<Real>>(*
upper_,
false);
94 if (
bnd_ != nullPtr) {
95 rbnd_ = makePtr<RiskBoundConstraint<Real>>(
bnd_);
96 return makePtr<OptimizationProblem<Real>>(
obj_,
c_,
rbnd_);
98 return makePtr<OptimizationProblem<Real>>(
obj_,
c_);
105 Ptr<Problem<Real>> prob
106 = makePtr<Problem<Real>>(
obj_,
c_);
108 bnd_ = makePtr<StdBoundConstraint<Real>>(*
lower_,
true);
111 bnd_ = makePtr<StdBoundConstraint<Real>>(*
upper_,
false);
116 if (
bnd_ != nullPtr) {
117 rbnd_ = makePtr<RiskBoundConstraint<Real>>(
bnd_);
118 prob->addBoundConstraint(
rbnd_);
127 void print(std::ostream &out = std::cout,
const std::string delim =
" ")
const {
130 for (
int i = 0; i <
dim; ++i) {
131 out << delim << (*cdata_)[i];
133 out << std::endl << std::endl;
Contains definitions for std::vector bound constraints.
void setUpperBound(const std::vector< Real > &upper)
Provides the interface to evaluate linear regression error.
Ptr< RiskVector< Real > > c_
Ptr< BoundConstraint< Real > > bnd_
Ptr< RiskBoundConstraint< Real > > rbnd_
void print(std::ostream &out=std::cout, const std::string delim=" ") const
Provides the interface to construct linear regression problem.
Ptr< std::vector< Real > > upper_
void setLowerBound(const std::vector< Real > &lower)
Ptr< std::vector< Real > > cdata_
void setErrorMeasure(ROL::ParameterList &parlist, bool reset=false)
Ptr< std::vector< Real > > lower_
const Ptr< OptimizationProblem< Real > > getOptimizationProblem(void)
const Ptr< RegressionError< Real > > error_
LinearRegression(const Ptr< SampleGenerator< Real >> &data)
const Ptr< SampleGenerator< Real > > data_
const Ptr< Problem< Real > > getProblem(void)
const Ptr< std::vector< Real > > getCoefficients(void) const
Ptr< StochasticObjective< Real > > obj_
Ptr< RandVarFunctional< Real > > em_