gpdtsolve.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  *** Authors:                                                               ***
00008  ***  Thomas Serafini, Luca Zanni                                           ***
00009  ***   Dept. of Mathematics, University of Modena and Reggio Emilia - ITALY ***
00010  ***   serafini.thomas@unimo.it, zanni.luca@unimo.it                        ***
00011  ***  Gaetano Zanghirati                                                    ***
00012  ***   Dept. of Mathematics, University of Ferrara - ITALY                  ***
00013  ***   g.zanghirati@unife.it                                                ***
00014  ***                                                                        ***
00015  *** Software homepage: http://dm.unife.it/gpdt                             ***
00016  ***                                                                        ***
00017  *** This work is supported by the Italian FIRB Projects                    ***
00018  ***      'Statistical Learning: Theory, Algorithms and Applications'       ***
00019  ***      (grant RBAU01877P), http://slipguru.disi.unige.it/ASTA            ***
00020  *** and                                                                    ***
00021  ***      'Parallel Algorithms and Numerical Nonlinear Optimization'        ***
00022  ***      (grant RBAU01JYPN), http://dm.unife.it/pn2o                       ***
00023  ***                                                                        ***
00024  *** Copyright (C) 2004 by T. Serafini, G. Zanghirati, L. Zanni.            ***
00025  ***                                                                        ***
00026  *** SHOGUN adaptions  Written (W) 2006-2008 Soeren Sonnenburg              ***
00027  */
00028 
00029 #include "base/SGObject.h"
00030 
00031 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00032 
00033 class QPproblem : public CSGObject
00034 {
00035 // ----------------- Public Data ---------------
00036 public:
00038   int32_t     chunk_size;
00040   int32_t     ell;
00042   int32_t    *y;
00044   float64_t DELTAsv;
00046   int32_t     q;
00048   int32_t     maxmw;
00050   float64_t  c_const;
00052   float64_t  bee;
00054   float64_t  delta;
00056   bool linadd;
00057 
00059   sKernel* KER;
00061   int32_t     ker_type;
00063   int32_t     projection_solver;
00065   int32_t     projection_projector;
00067   int32_t     PreprocessMode;
00069   int32_t     preprocess_size;
00071   int32_t     verbosity;
00073   float64_t  tau_proximal;
00075   float64_t objective_value;
00076 
00077 // ----------------- Public Methods ---------------
00079   QPproblem ();
00080   ~QPproblem();
00081 
00087   int32_t  ReadSVMFile    (char *fInput);
00088 
00094   int32_t  ReadGPDTBinary(char *fName);
00095 
00100   int32_t  Check2Class    (void);
00101 
00108   void Subproblem     (QPproblem &ker, int32_t len, int32_t *perm);
00109 
00111   void PrepMP         (void);
00112 
00118   float64_t  gpdtsolve      (float64_t *solution);
00119 
00125   float64_t  pgpdtsolve     (float64_t *solution);
00126 
00131   inline bool get_linadd_enabled()
00132   {
00133     return linadd;
00134   }
00135 
00137   inline virtual const char* get_name() const { return "QProblem"; }
00138 
00139 // ----------------- Private Data  ---------------
00140 private:
00141   int32_t    dim;
00142   int32_t    *index_in, *index_out;
00143   int32_t    *ing, *inaux, *inold, *incom;
00144   int32_t    *cec;
00145   int32_t    nb;
00146   int32_t    *bmem, *bmemrid, *pbmr;
00147   int32_t    my_chunk_size;  // chunk_size for the current processor
00148   int32_t    my_spD_offset;  // offset of the current processor into sp_D matrix
00149   int32_t    recvl[32], displ[32];
00150   float64_t kktold;
00151   float64_t DELTAvpm, InitialDELTAvpm, DELTAkin;
00152   float64_t *alpha;
00153   float64_t *grad, *st;
00154 
00155 // ----------------- Private Methods ---------------
00156 private:
00157   int32_t  Preprocess0 (int32_t *aux, int32_t *sv);
00158   int32_t  Preprocess1 (sKernel* KER, int32_t *aux, int32_t *sv);
00159   int32_t  optimal     (void);
00160 
00161   bool is_zero(int32_t  i) { return (alpha[i] < DELTAsv); }
00162   bool is_free(int32_t  i)
00163        { return (alpha[i] > DELTAsv && alpha[i] < (c_const - DELTAsv)); }
00164   bool is_bound(int32_t i) { return (alpha[i] > (c_const - DELTAsv)); }
00165 
00166 };
00167 #endif // DOXYGEN_SHOULD_SKIP_THIS

SHOGUN Machine Learning Toolbox - Documentation