C++ API Reference for Intel® Data Analytics Acceleration Library 2019

lbfgs_batch.h
1 /* file: lbfgs_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of the interface for the limited-memory Broyden-Fletcher-Goldfarb-Shanno
19 // (BFGS) algorithm in the batch processing mode
20 //--
21 */
22 
23 #ifndef __LBFGS_BATCH_H__
24 #define __LBFGS_BATCH_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/numeric_table.h"
28 #include "services/daal_defines.h"
29 #include "algorithms/optimization_solver/iterative_solver/iterative_solver_batch.h"
30 #include "lbfgs_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace optimization_solver
37 {
38 namespace lbfgs
39 {
40 namespace interface1
41 {
55 template<typename algorithmFPType, Method method, CpuType cpu>
56 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
57 {
58 public:
64  BatchContainer(daal::services::Environment::env *daalEnv);
66  ~BatchContainer();
72  virtual services::Status compute() DAAL_C11_OVERRIDE;
73 };
74 
92 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
93 class DAAL_EXPORT Batch : public iterative_solver::Batch
94 {
95 public:
96  typedef algorithms::optimization_solver::lbfgs::Input InputType;
97  typedef algorithms::optimization_solver::lbfgs::Parameter ParameterType;
98  typedef algorithms::optimization_solver::lbfgs::Result ResultType;
99 
100  InputType input;
101  ParameterType parameter;
107  Batch(const sum_of_functions::BatchPtr& objectiveFunction = sum_of_functions::BatchPtr()) :
108  input(),
109  parameter(objectiveFunction)
110  {
111  initialize();
112  }
113 
119  Batch(const Batch<algorithmFPType, method> &other) :
120  iterative_solver::Batch(other),
121  input(other.input),
122  parameter(other.parameter)
123  {
124  initialize();
125  }
126 
131  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
132 
137  virtual iterative_solver::Input * getInput() DAAL_C11_OVERRIDE { return &input; }
138 
143  virtual iterative_solver::Parameter * getParameter() DAAL_C11_OVERRIDE { return &parameter; }
144 
150  virtual services::Status createResult() DAAL_C11_OVERRIDE
151  {
152  _result = iterative_solver::ResultPtr(new ResultType());
153  _res = NULL;
154  return services::Status();
155  }
156 
162  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
163  {
164  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
165  }
166 
171  static services::SharedPtr<Batch<algorithmFPType, method> > create();
172 
173 protected:
174  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
175  {
176  return new Batch<algorithmFPType, method>(*this);
177  }
178 
179  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
180  {
181  services::Status s = static_cast<ResultType*>(_result.get())->allocate<algorithmFPType>(&input, &parameter, (int)method);
182  _res = _result.get();
183  return s;
184  }
185 
186  void initialize()
187  {
188  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
189  _par = &parameter;
190  _in = &input;
191  _result.reset(new ResultType());
192  }
193 };
195 } // namespace interface1
196 using interface1::BatchContainer;
197 using interface1::Batch;
198 
199 } // namespace lbfgs
200 } // namespace optimization_solver
201 } // namespace algorithm
202 } // namespace daal
203 
204 #endif
daal::algorithms::optimization_solver::lbfgs::interface1::Batch::getParameter
virtual iterative_solver::Parameter * getParameter() DAAL_C11_OVERRIDE
Definition: lbfgs_batch.h:143
daal::algorithms::optimization_solver::lbfgs::interface1::Batch
Computes LBFGS in the batch processing mode.
Definition: lbfgs_batch.h:93
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::lbfgs::interface1::Batch::getInput
virtual iterative_solver::Input * getInput() DAAL_C11_OVERRIDE
Definition: lbfgs_batch.h:137
daal::algorithms::optimization_solver::lbfgs::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: lbfgs_batch.h:119
daal::algorithms::optimization_solver::lbfgs::interface1::BatchContainer
Provides methods to run implementations of the LBFGS algorithm. This class is associated with daal::a...
Definition: lbfgs_batch.h:56
daal::algorithms::optimization_solver::lbfgs::interface1::Batch::parameter
ParameterType parameter
Definition: lbfgs_batch.h:101
daal_defines.h
daal::algorithms::optimization_solver::lbfgs::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: lbfgs_batch.h:162
daal::batch
Definition: daal_defines.h:106
daal::algorithms::optimization_solver::lbfgs::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: lbfgs_batch.h:131
daal::algorithms::optimization_solver::lbfgs::interface1::Batch::createResult
virtual services::Status createResult() DAAL_C11_OVERRIDE
Definition: lbfgs_batch.h:150
daal::algorithms::optimization_solver::lbfgs::interface1::Batch::Batch
Batch(const sum_of_functions::BatchPtr &objectiveFunction=sum_of_functions::BatchPtr())
Definition: lbfgs_batch.h:107
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::iterative_solver::interface1::Batch
Interface for computing the iterative solver in the batch processing mode.
Definition: iterative_solver_batch.h:52
daal::algorithms::optimization_solver::lbfgs::interface1::Batch::input
InputType input
Definition: lbfgs_batch.h:100
daal::algorithms::kmeans::objectiveFunction
Definition: kmeans_types.h:109

For more complete information about compiler optimizations, see our Optimization Notice.