22 #ifndef __PRECOMPUTED_BATCH_H__
23 #define __PRECOMPUTED_BATCH_H__
25 #include "algorithms/algorithm.h"
26 #include "services/daal_defines.h"
27 #include "objective_function_batch.h"
28 #include "sum_of_functions_batch.h"
29 #include "precomputed_types.h"
35 namespace optimization_solver
56 template<
typename algorithmFPType, Method method>
57 class DAAL_EXPORT BatchContainer :
public daal::algorithms::AnalysisContainerIface<batch>
65 BatchContainer(daal::services::Environment::env *daalEnv) {}
66 virtual ~BatchContainer() {}
72 virtual services::Status compute()
75 return services::Status();
93 template<
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
94 class DAAL_EXPORT Batch :
public sum_of_functions::Batch
97 typedef sum_of_functions::Batch super;
99 typedef typename super::InputType InputType;
100 typedef typename super::ParameterType ParameterType;
101 typedef typename super::ResultType ResultType;
105 ParameterType parameter;
110 Batch() : parameter(1), super(1, &input, ¶meter)
123 Batch(
const Batch<algorithmFPType, method> &other) :
124 parameter(other.parameter), super(other.parameter.numberOfTerms, &input, ¶meter), input(other.input)
127 const ResultType *otherResult =
const_cast<Batch<algorithmFPType, method> &
>(other).getResult().get();
130 bool isResultInitialized =
false;
131 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::gradientIdx));
132 _result->set(objective_function::gradientIdx, otherResult->get(objective_function::gradientIdx));
133 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::valueIdx));
134 _result->set(objective_function::valueIdx, otherResult->get(objective_function::valueIdx));
135 isResultInitialized = (isResultInitialized || otherResult->get(objective_function::hessianIdx));
136 _result->set(objective_function::hessianIdx, otherResult->get(objective_function::hessianIdx));
137 if (isResultInitialized)
139 _res = _result.get();
148 virtual int getMethod() const DAAL_C11_OVERRIDE {
return (
int)method; }
155 services::SharedPtr<Batch<algorithmFPType, method> > clone()
const
157 return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
165 services::Status allocate()
167 return allocateResult();
171 virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
173 return new Batch<algorithmFPType, method>(*this);
176 virtual services::Status allocateResult() DAAL_C11_OVERRIDE
178 services::Status s = _result->allocate<algorithmFPType>(&input, ¶meter, (int) method);
179 _res = _result.get();
185 Analysis<batch>::_ac =
new BatchContainer<algorithmFPType, method>(&_env);
188 _result = objective_function::ResultPtr(
new ResultType());
193 using interface1::BatchContainer;
194 using interface1::Batch;
daal::algorithms::optimization_solver::precomputed::interface1::Batch::Batch
Batch()
Definition: precomputed_batch.h:110
daal
Definition: algorithm_base_common.h:31
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::optimization_solver::precomputed::interface1::BatchContainer
Provides methods to run implementations of the objective function with precomputed characteristics...
Definition: precomputed_batch.h:57
daal::algorithms::optimization_solver::precomputed::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
Definition: precomputed_batch.h:65
daal::algorithms::optimization_solver::precomputed::interface1::Batch::input
InputType input
Definition: precomputed_batch.h:103
daal::algorithms::optimization_solver::objective_function::gradientIdx
Definition: objective_function_types.h:81
daal::algorithms::optimization_solver::objective_function::hessianIdx
Definition: objective_function_types.h:83
daal::algorithms::optimization_solver::objective_function::valueIdx
Definition: objective_function_types.h:82
daal::algorithms::optimization_solver::precomputed::interface1::Batch
Computes the objective function with precomputed characteristics in the batch processing mode...
Definition: precomputed_batch.h:94
daal::algorithms::optimization_solver::precomputed::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: precomputed_batch.h:155
daal::algorithms::optimization_solver::precomputed::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: precomputed_batch.h:123
daal::algorithms::optimization_solver::precomputed::interface1::Batch::parameter
ParameterType parameter
Definition: precomputed_batch.h:105
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::optimization_solver::precomputed::interface1::BatchContainer::compute
virtual services::Status compute()
Definition: precomputed_batch.h:72
daal::algorithms::optimization_solver::precomputed::interface1::Batch::allocate
services::Status allocate()
Definition: precomputed_batch.h:165
daal::algorithms::optimization_solver::precomputed::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: precomputed_batch.h:148