48 #ifndef __PRECOMPUTED_BATCH_H__ 49 #define __PRECOMPUTED_BATCH_H__ 51 #include "algorithms/algorithm.h" 52 #include "services/daal_defines.h" 53 #include "objective_function_batch.h" 54 #include "sum_of_functions_batch.h" 55 #include "precomputed_types.h" 61 namespace optimization_solver
82 template<
typename algorithmFPType, Method method>
83 class DAAL_EXPORT BatchContainer :
public daal::algorithms::AnalysisContainerIface<batch>
91 BatchContainer(daal::services::Environment::env *daalEnv) {}
92 virtual ~BatchContainer() {}
98 virtual services::Status compute()
101 return services::Status();
119 template<
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
120 class DAAL_EXPORT Batch :
public sum_of_functions::Batch
123 typedef sum_of_functions::Batch super;
125 typedef typename super::InputType InputType;
126 typedef typename super::ParameterType ParameterType;
127 typedef typename super::ResultType ResultType;
131 ParameterType parameter;
136 Batch() : parameter(1), super(1, &input, ¶meter)
149 Batch(
const Batch<algorithmFPType, method> &other) :
150 parameter(other.parameter), super(other.parameter.numberOfTerms, &input, ¶meter), input(other.input)
153 const ResultType *otherResult =
const_cast<Batch<algorithmFPType, method> &
>(other).getResult().get();
156 bool isResultInitialized =
false;
157 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::gradientIdx));
158 _result->set(objective_function::gradientIdx, otherResult->get(objective_function::gradientIdx));
159 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::valueIdx));
160 _result->set(objective_function::valueIdx, otherResult->get(objective_function::valueIdx));
161 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::hessianIdx));
162 _result->set(objective_function::hessianIdx, otherResult->get(objective_function::hessianIdx));
163 if (isResultInitialized)
165 _res = _result.get();
174 virtual int getMethod() const DAAL_C11_OVERRIDE {
return (
int)method; }
181 services::SharedPtr<Batch<algorithmFPType, method> > clone()
const 183 return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
191 services::Status allocate()
193 return allocateResult();
197 virtual Batch<algorithmFPType, method> *cloneImpl()
const DAAL_C11_OVERRIDE
199 return new Batch<algorithmFPType, method>(*this);
202 virtual services::Status allocateResult() DAAL_C11_OVERRIDE
204 services::Status s = _result->allocate<algorithmFPType>(&input, ¶meter, (int) method);
205 _res = _result.get();
211 Analysis<batch>::_ac =
new BatchContainer<algorithmFPType, method>(&_env);
214 _result = objective_function::ResultPtr(
new ResultType());
219 using interface1::BatchContainer;
220 using interface1::Batch;
daal::algorithms::optimization_solver::precomputed::interface1::Batch::Batch
Batch()
Definition: precomputed_batch.h:136
daal::services::interface1::Environment::_envStruct
The environment structure.
Definition: env_detect.h:95
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
daal
Definition: algorithm_base_common.h:57
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:79
daal::algorithms::optimization_solver::objective_function::interface1::Result
Provides methods to access final results obtained with the compute() method of the Objective function...
Definition: objective_function_types.h:186
daal::algorithms::optimization_solver::precomputed::interface1::BatchContainer
Provides methods to run implementations of the objective function with precomputed characteristics...
Definition: precomputed_batch.h:83
daal::algorithms::optimization_solver::precomputed::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
Definition: precomputed_batch.h:91
daal::algorithms::optimization_solver::precomputed::interface1::Batch::input
InputType input
Definition: precomputed_batch.h:129
daal::algorithms::optimization_solver::objective_function::gradientIdx
Definition: objective_function_types.h:104
daal::algorithms::optimization_solver::sum_of_functions::interface1::Batch
Interface for computing the Sum of functions in the batch processing mode.
Definition: sum_of_functions_batch.h:87
daal::algorithms::optimization_solver::objective_function::hessianIdx
Definition: objective_function_types.h:106
daal::services::interface1::SharedPtr
Shared pointer that retains shared ownership of an object through a pointer. Several SharedPtr object...
Definition: daal_shared_ptr.h:187
daal::algorithms::optimization_solver::sum_of_functions::interface1::Parameter
Parameter for the Sum of functions
Definition: sum_of_functions_types.h:95
daal::algorithms::optimization_solver::objective_function::valueIdx
Definition: objective_function_types.h:105
daal::algorithms::optimization_solver::precomputed::interface1::Batch
Computes the objective function with precomputed characteristics in the batch processing mode...
Definition: precomputed_batch.h:120
daal::algorithms::optimization_solver::precomputed::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: precomputed_batch.h:149
daal::algorithms::optimization_solver::precomputed::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: precomputed_batch.h:181
daal::algorithms::optimization_solver::precomputed::interface1::Batch::~Batch
virtual ~Batch()
Definition: precomputed_batch.h:141
daal::algorithms::optimization_solver::precomputed::interface1::Batch::parameter
ParameterType parameter
Definition: precomputed_batch.h:131
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:94
daal::algorithms::optimization_solver::precomputed::interface1::BatchContainer::compute
virtual services::Status compute()
Definition: precomputed_batch.h:98
daal::algorithms::optimization_solver::precomputed::interface1::Batch::allocate
services::Status allocate()
Definition: precomputed_batch.h:191
daal::algorithms::optimization_solver::precomputed::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: precomputed_batch.h:174
daal::algorithms::optimization_solver::objective_function::interface1::Parameter
Parameter for the Objective function
Definition: objective_function_types.h:122
daal::algorithms::optimization_solver::objective_function::interface1::Result::get
data_management::NumericTablePtr get(ResultId id) const