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 
00032 class QPproblem : public CSGObject
00033 {
00034 // ----------------- Public Data ---------------
00035 public:
00037   int     chunk_size;
00039   int     ell;
00041   int    *y;
00043   double DELTAsv;
00045   int     q;
00047   int     maxmw;
00049   double  c_const;
00051   double  bee;
00053   double  delta;
00055   bool linadd;
00056 
00058   sKernel* KER;
00060   int     ker_type;
00062   int     projection_solver;
00064   int     projection_projector;
00066   int     PreprocessMode;
00068   int     preprocess_size;
00070   int     verbosity;
00072   double  tau_proximal;
00074   double objective_value;
00075 
00076 // ----------------- Public Methods ---------------
00078   QPproblem ();
00079   ~QPproblem();
00080 
00086   int  ReadSVMFile    (char *fInput);
00087 
00093   int  ReadGPDTBinary(char *fName);
00094 
00099   int  Check2Class    (void);
00100 
00107   void Subproblem     (QPproblem &ker, int len, int *perm);
00108 
00110   void PrepMP         (void);
00111 
00117   double  gpdtsolve      (double *solution);
00118 
00124   double  pgpdtsolve     (double *solution);
00125 
00130   inline bool get_linadd_enabled()
00131   {
00132     return linadd;
00133   }
00134 
00135 // ----------------- Private Data  ---------------
00136 private:
00137   int    dim;
00138   int    *index_in, *index_out;
00139   int    *ing, *inaux, *inold, *incom;
00140   int    *cec;
00141   int    nb;
00142   int    *bmem, *bmemrid, *pbmr;
00143   int    my_chunk_size;    // chunk_size for the current processor
00144   int    my_spD_offset;    // offset of the current processor into sp_D matrix
00145   int    recvl[32], displ[32];
00146   double kktold;
00147   double DELTAvpm, InitialDELTAvpm, DELTAkin;
00148   double *alpha;
00149   double *grad, *st;
00150 
00151 // ----------------- Private Methods ---------------
00152 private:
00153   int  Preprocess0 (int *aux, int *sv);
00154   int  Preprocess1 (sKernel* KER, int *aux, int *sv);
00155   int  optimal     (void);
00156 
00157   bool is_zero(int  i) { return (alpha[i] < DELTAsv); }
00158   bool is_free(int  i) 
00159        { return (alpha[i] > DELTAsv && alpha[i] < (c_const - DELTAsv)); }
00160   bool is_bound(int i) { return (alpha[i] > (c_const - DELTAsv)); }
00161 
00162 };

SHOGUN Machine Learning Toolbox - Documentation