SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gpdtsolve.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  *** Authors: ***
8  *** Thomas Serafini, Luca Zanni ***
9  *** Dept. of Mathematics, University of Modena and Reggio Emilia - ITALY ***
10  *** serafini.thomas@unimo.it, zanni.luca@unimo.it ***
11  *** Gaetano Zanghirati ***
12  *** Dept. of Mathematics, University of Ferrara - ITALY ***
13  *** g.zanghirati@unife.it ***
14  *** ***
15  *** Software homepage: http://dm.unife.it/gpdt ***
16  *** ***
17  *** This work is supported by the Italian FIRB Projects ***
18  *** 'Statistical Learning: Theory, Algorithms and Applications' ***
19  *** (grant RBAU01877P), http://slipguru.disi.unige.it/ASTA ***
20  *** and ***
21  *** 'Parallel Algorithms and Numerical Nonlinear Optimization' ***
22  *** (grant RBAU01JYPN), http://dm.unife.it/pn2o ***
23  *** ***
24  *** Copyright (C) 2004 by T. Serafini, G. Zanghirati, L. Zanni. ***
25  *** ***
26  *** SHOGUN adaptions Written (W) 2006-2008 Soeren Sonnenburg ***
27  */
28 
29 #include <shogun/base/SGObject.h>
30 
31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
32 namespace shogun
33 {
35 class QPproblem : public CSGObject
36 {
37 // ----------------- Public Data ---------------
38 public:
40  int32_t chunk_size;
42  int32_t ell;
44  int32_t *y;
46  float64_t DELTAsv;
48  int32_t q;
50  int32_t maxmw;
52  float64_t c_const;
54  float64_t bee;
58  bool linadd;
59 
61  sKernel* KER;
63  int32_t ker_type;
65  int32_t projection_solver;
67  int32_t projection_projector;
69  int32_t PreprocessMode;
71  int32_t preprocess_size;
73  int32_t verbosity;
75  float64_t tau_proximal;
77  float64_t objective_value;
78 
79 // ----------------- Public Methods ---------------
81  QPproblem ();
82  ~QPproblem();
83 
89  int32_t ReadSVMFile (char *fInput);
90 
96  int32_t ReadGPDTBinary(char *fName);
97 
102  int32_t Check2Class ();
103 
110  void Subproblem (QPproblem &ker, int32_t len, int32_t *perm);
111 
113  void PrepMP ();
114 
120  float64_t gpdtsolve (float64_t *solution);
121 
127  float64_t pgpdtsolve (float64_t *solution);
128 
133  inline bool get_linadd_enabled()
134  {
135  return linadd;
136  }
137 
139  inline virtual const char* get_name() const { return "QPproblem"; }
140 
141 // ----------------- Private Data ---------------
142 private:
143  int32_t dim;
144  int32_t *index_in, *index_out;
145  int32_t *ing, *inaux, *inold, *incom;
146  int32_t *cec;
147  int32_t nb;
148  int32_t *bmem, *bmemrid, *pbmr;
149  int32_t my_chunk_size; // chunk_size for the current processor
150  int32_t my_spD_offset; // offset of the current processor into sp_D matrix
151  int32_t recvl[32], displ[32];
152  float64_t kktold;
153  float64_t DELTAvpm, InitialDELTAvpm, DELTAkin;
154  float64_t *alpha;
155  float64_t *grad, *st;
156 
157 // ----------------- Private Methods ---------------
158 private:
159  int32_t Preprocess0 (int32_t *aux, int32_t *sv);
160  int32_t Preprocess1 (sKernel* KER, int32_t *aux, int32_t *sv);
161  int32_t optimal ();
162 
163  bool is_zero(int32_t i) { return (alpha[i] < DELTAsv); }
164  bool is_free(int32_t i)
165  { return (alpha[i] > DELTAsv && alpha[i] < (c_const - DELTAsv)); }
166  bool is_bound(int32_t i) { return (alpha[i] > (c_const - DELTAsv)); }
167 
168 };
169 }
170 #endif // DOXYGEN_SHOULD_SKIP_THIS

SHOGUN Machine Learning Toolbox - Documentation