SHOGUN  3.2.1
 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/config.h>
18 
19 #include <shogun/lib/common.h>
22 
23 #define LIBBMRM_PLUS_INF (-log(0.0))
24 #define LIBBMRM_CALLOC(x, y) SG_CALLOC(y, x)
25 #define LIBBMRM_REALLOC(x, y) SG_REALLOC(x, y)
26 #define LIBBMRM_FREE(x) SG_FREE(x)
27 #define LIBBMRM_MEMCPY(x, y, z) memcpy(x, y, z)
28 #define LIBBMRM_MEMMOVE(x, y, z) memmove(x, y, z)
29 #define LIBBMRM_INDEX(ROW, COL, NUM_ROWS) ((COL)*(NUM_ROWS)+(ROW))
30 #define LIBBMRM_ABS(A) ((A) < 0 ? -(A) : (A))
31 
32 namespace shogun
33 {
35 extern uint32_t BufSize;
36 
46  uint32_t idx;
47 };
48 
51 {
53  uint32_t maxCPs;
54 
56  uint32_t* ICPcounter;
57 
60 
62  uint32_t* ACPs;
63 
66 };
67 
78  bmrm_ll** tail,
79  bool* map,
80  float64_t* A,
81  uint32_t free_idx,
82  float64_t* cp_data,
83  uint32_t dim);
84 
93  bmrm_ll** head,
94  bmrm_ll** tail,
95  bool* map,
96  float64_t* icp);
97 
101 void clean_icp(ICP_stats* icp_stats,
102  BmrmStatistics& bmrm,
103  bmrm_ll** head,
104  bmrm_ll** tail,
105  float64_t*& H,
106  float64_t*& diag_H,
107  float64_t*& beta,
108  bool*& map,
109  uint32_t cleanAfter,
110  float64_t*& b,
111  uint32_t*& I,
112  uint32_t cp_models = 0
113  );
114 
120 inline float64_t * get_cutting_plane(bmrm_ll *ptr) { return ptr->address; }
121 
128 inline uint32_t find_free_idx(bool *map, uint32_t size)
129 {
130  for (uint32_t i=0; i<size; ++i) if (map[i]) return i;
131  SG_SERROR("No free index available in CP buffer of size %d.\n", size);
132  return size-1;
133 }
134 
150 BmrmStatistics svm_bmrm_solver(
151  CDualLibQPBMSOSVM *machine,
152  float64_t *W,
153  float64_t TolRel,
154  float64_t TolAbs,
155  float64_t _lambda,
156  uint32_t _BufSize,
157  bool cleanICP,
158  uint32_t cleanAfter,
159  float64_t K,
160  uint32_t Tmax,
161  bool store_train_info
162  );
163 
164 }
165 
166 #endif /* libbmrm_h */

SHOGUN Machine Learning Toolbox - Documentation