24 #ifndef __PRECOMPUTED_BATCH_H__
25 #define __PRECOMPUTED_BATCH_H__
27 #include "algorithms/algorithm.h"
28 #include "services/daal_defines.h"
29 #include "objective_function_batch.h"
30 #include "sum_of_functions_batch.h"
31 #include "precomputed_types.h"
37 namespace optimization_solver
58 template<
typename algorithmFPType, Method method>
59 class BatchContainer :
public daal::algorithms::AnalysisContainerIface<batch>
67 DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv) {}
68 DAAL_DEPRECATED_VIRTUAL
virtual ~BatchContainer() {}
74 DAAL_DEPRECATED_VIRTUAL
virtual services::Status compute()
77 return services::Status();
95 template<
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
96 class DAAL_EXPORT Batch :
public sum_of_functions::interface1::Batch
99 typedef sum_of_functions::interface1::Batch super;
101 typedef typename super::InputType InputType;
102 typedef typename super::ParameterType ParameterType;
103 typedef typename super::ResultType ResultType;
107 ParameterType parameter;
112 DAAL_DEPRECATED Batch() : parameter(1), super(1, &input, ¶meter)
117 DAAL_DEPRECATED_VIRTUAL
virtual ~Batch() {}
125 DAAL_DEPRECATED Batch(
const Batch<algorithmFPType, method> &other) :
126 parameter(other.parameter), super(other.parameter.numberOfTerms, &input, ¶meter), input(other.input)
129 const ResultType *otherResult =
const_cast<Batch<algorithmFPType, method> &
>(other).getResult().get();
132 bool isResultInitialized =
false;
133 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::gradientIdx));
134 _result->set(objective_function::gradientIdx, otherResult->get(objective_function::gradientIdx));
135 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::valueIdx));
136 _result->set(objective_function::valueIdx, otherResult->get(objective_function::valueIdx));
137 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::hessianIdx));
138 _result->set(objective_function::hessianIdx, otherResult->get(objective_function::hessianIdx));
139 if (isResultInitialized)
141 _res = _result.get();
150 DAAL_DEPRECATED_VIRTUAL
virtual int getMethod() const DAAL_C11_OVERRIDE {
return (
int)method; }
157 DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone()
const
159 return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
167 DAAL_DEPRECATED services::Status allocate()
169 return allocateResult();
173 virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
175 return new Batch<algorithmFPType, method>(*this);
178 virtual services::Status allocateResult() DAAL_C11_OVERRIDE
180 services::Status s = _result->allocate<algorithmFPType>(&input, ¶meter, (int) method);
181 _res = _result.get();
187 Analysis<batch>::_ac =
new BatchContainer<algorithmFPType, method>(&_env);
190 _result = objective_function::ResultPtr(
new ResultType());
214 template<
typename algorithmFPType, Method method>
215 class BatchContainer :
public daal::algorithms::AnalysisContainerIface<batch>
223 BatchContainer(daal::services::Environment::env *daalEnv) {}
224 virtual ~BatchContainer() {}
230 virtual services::Status compute()
233 return services::Status();
251 template<
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
252 class DAAL_EXPORT Batch :
public sum_of_functions::Batch
255 typedef sum_of_functions::Batch super;
257 typedef typename super::InputType InputType;
258 typedef typename super::ParameterType ParameterType;
259 typedef typename super::ResultType ResultType;
263 ParameterType parameter;
268 Batch() : parameter(1), super(1, &input, ¶meter)
281 Batch(
const Batch<algorithmFPType, method> &other) :
282 parameter(other.parameter), super(other.parameter.numberOfTerms, &input, ¶meter), input(other.input)
285 const ResultType *otherResult =
const_cast<Batch<algorithmFPType, method> &
>(other).getResult().get();
288 bool isResultInitialized =
false;
289 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::gradientIdx));
290 _result->set(objective_function::gradientIdx, otherResult->get(objective_function::gradientIdx));
291 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::valueIdx));
292 _result->set(objective_function::valueIdx, otherResult->get(objective_function::valueIdx));
293 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::hessianIdx));
294 _result->set(objective_function::hessianIdx, otherResult->get(objective_function::hessianIdx));
295 if (isResultInitialized)
297 _res = _result.get();
306 virtual int getMethod() const DAAL_C11_OVERRIDE {
return (
int)method; }
313 services::SharedPtr<Batch<algorithmFPType, method> > clone()
const
315 return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
323 services::Status allocate()
325 return allocateResult();
329 virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
331 return new Batch<algorithmFPType, method>(*this);
334 virtual services::Status allocateResult() DAAL_C11_OVERRIDE
336 services::Status s = _result->allocate<algorithmFPType>(&input, ¶meter, (int) method);
337 _res = _result.get();
343 Analysis<batch>::_ac =
new BatchContainer<algorithmFPType, method>(&_env);
346 _result = objective_function::ResultPtr(
new ResultType());
351 using interface2::BatchContainer;
352 using interface2::Batch;
daal::algorithms::optimization_solver::precomputed::interface2::Batch::parameter
ParameterType parameter
Definition: precomputed_batch.h:263
daal::algorithms::optimization_solver::precomputed::interface1::Batch::parameter
ParameterType parameter
Definition: precomputed_batch.h:107
daal::algorithms::optimization_solver::precomputed::interface2::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: precomputed_batch.h:281
daal::algorithms::optimization_solver::precomputed::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: precomputed_batch.h:125
daal::algorithms::optimization_solver::precomputed::interface1::Batch::input
InputType input
Definition: precomputed_batch.h:105
daal::algorithms::optimization_solver::sum_of_functions::interface1::Input
Input objects for the Sum of functions
Definition: sum_of_functions_types.h:113
daal::algorithms::optimization_solver::precomputed::interface2::BatchContainer
Provides methods to run implementations of the objective function with precomputed characteristics...
Definition: precomputed_batch.h:215
daal::algorithms::optimization_solver::precomputed::interface2::Batch::allocate
services::Status allocate()
Definition: precomputed_batch.h:323
daal::algorithms::optimization_solver::precomputed::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: precomputed_batch.h:306
daal::algorithms::optimization_solver::precomputed::interface2::Batch::input
InputType input
Definition: precomputed_batch.h:261
daal::algorithms::optimization_solver::precomputed::interface2::Batch::Batch
Batch()
Definition: precomputed_batch.h:268
daal::algorithms::optimization_solver::precomputed::interface1::BatchContainer
Provides methods to run implementations of the objective function with precomputed characteristics...
Definition: precomputed_batch.h:59
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:63
daal::algorithms::optimization_solver::sum_of_functions::interface1::Parameter
Parameter for the Sum of functions
Definition: sum_of_functions_types.h:71
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:55
daal::algorithms::optimization_solver::precomputed::interface2::BatchContainer::compute
virtual services::Status compute()
Definition: precomputed_batch.h:230
daal::algorithms::optimization_solver::precomputed::interface1::Batch
Computes the objective function with precomputed characteristics in the batch processing mode...
Definition: precomputed_batch.h:96
daal::algorithms::optimization_solver::precomputed::interface1::BatchContainer::compute
virtual DAAL_DEPRECATED_VIRTUAL services::Status compute()
Definition: precomputed_batch.h:74
daal::algorithms::optimization_solver::objective_function::gradientIdx
Definition: objective_function_types.h:86
daal::algorithms::optimization_solver::precomputed::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
Definition: precomputed_batch.h:223
daal::algorithms::optimization_solver::objective_function::valueIdx
Definition: objective_function_types.h:87
daal::algorithms::optimization_solver::precomputed::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: precomputed_batch.h:313
daal::algorithms::optimization_solver::precomputed::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: precomputed_batch.h:150
daal::algorithms::optimization_solver::precomputed::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: precomputed_batch.h:157
daal::algorithms::optimization_solver::precomputed::interface1::Batch::allocate
DAAL_DEPRECATED services::Status allocate()
Definition: precomputed_batch.h:167
daal::algorithms::optimization_solver::objective_function::hessianIdx
Definition: objective_function_types.h:88
daal::algorithms::optimization_solver::precomputed::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
Definition: precomputed_batch.h:67
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::optimization_solver::precomputed::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: precomputed_batch.h:112
daal::algorithms::optimization_solver::precomputed::interface2::Batch
Computes the objective function with precomputed characteristics in the batch processing mode...
Definition: precomputed_batch.h:252