SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
libbmrm.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  * libbmrm.h: Implementation of the BMRM solver for SO training
8  *
9  * Copyright (C) 2012 Michal Uricar, uricamic@cmp.felk.cvut.cz
10  *
11  * Implementation of the BMRM solver
12  *--------------------------------------------------------------------- */
13 
14 #ifndef libbmrm_h
15 #define libbmrm_h
16 
17 #include <shogun/lib/common.h>
20 
21 #define LIBBMRM_PLUS_INF (-log(0.0))
22 #define LIBBMRM_CALLOC(x, y) SG_CALLOC(y, x)
23 #define LIBBMRM_REALLOC(x, y) SG_REALLOC(x, y)
24 #define LIBBMRM_FREE(x) SG_FREE(x)
25 #define LIBBMRM_MEMCPY(x, y, z) memcpy(x, y, z)
26 #define LIBBMRM_MEMMOVE(x, y, z) memmove(x, y, z)
27 #define LIBBMRM_INDEX(ROW, COL, NUM_ROWS) ((COL)*(NUM_ROWS)+(ROW))
28 #define LIBBMRM_ABS(A) ((A) < 0 ? -(A) : (A))
29 
30 namespace shogun
31 {
41  uint32_t idx;
42 };
43 
46 {
48  uint32_t maxCPs;
49 
51  uint32_t* ICPcounter;
52 
55 
57  uint32_t* ACPs;
58 
61 };
62 
73  bmrm_ll** tail,
74  bool* map,
75  float64_t* A,
76  uint32_t free_idx,
77  float64_t* cp_data,
78  uint32_t dim);
79 
88  bmrm_ll** head,
89  bmrm_ll** tail,
90  bool* map,
91  float64_t* icp);
92 
96 void clean_icp(ICP_stats* icp_stats,
97  BmrmStatistics& bmrm,
98  bmrm_ll** head,
99  bmrm_ll** tail,
100  float64_t*& H,
101  float64_t*& diag_H,
102  float64_t*& beta,
103  bool*& map,
104  uint32_t cleanAfter,
105  float64_t*& b,
106  uint32_t*& I,
107  uint32_t cp_models = 0
108  );
109 
115 inline float64_t * get_cutting_plane(bmrm_ll *ptr) { return ptr->address; }
116 
123 inline uint32_t find_free_idx(bool *map, uint32_t size)
124 { for(uint32_t i=0; i<size; ++i) if (map[i]) return i; return size+1; }
125 
144 BmrmStatistics svm_bmrm_solver(
145  CDualLibQPBMSOSVM *machine,
146  float64_t *W,
147  float64_t TolRel,
148  float64_t TolAbs,
149  float64_t _lambda,
150  uint32_t _BufSize,
151  bool cleanICP,
152  uint32_t cleanAfter,
153  float64_t K,
154  uint32_t Tmax,
155  bool verbose
156  );
157 
158 }
159 
160 #endif /* libbmrm_h */

SHOGUN Machine Learning Toolbox - Documentation