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/common.h>
20 #include <shogun/io/SGIO.h>
21 
22 #define LIBBMRM_PLUS_INF (-log(0.0))
23 #define LIBBMRM_CALLOC(x, y) SG_CALLOC(y, x)
24 #define LIBBMRM_REALLOC(x, y) SG_REALLOC(x, y)
25 #define LIBBMRM_FREE(x) SG_FREE(x)
26 #define LIBBMRM_MEMCPY(x, y, z) memcpy(x, y, z)
27 #define LIBBMRM_MEMMOVE(x, y, z) memmove(x, y, z)
28 #define LIBBMRM_INDEX(ROW, COL, NUM_ROWS) ((COL)*(NUM_ROWS)+(ROW))
29 #define LIBBMRM_ABS(A) ((A) < 0 ? -(A) : (A))
30 
31 namespace shogun
32 {
33 extern uint32_t BufSize;
34 
44  uint32_t idx;
45 };
46 
49 {
51  uint32_t maxCPs;
52 
54  uint32_t* ICPcounter;
55 
58 
60  uint32_t* ACPs;
61 
64 };
65 
76  bmrm_ll** tail,
77  bool* map,
78  float64_t* A,
79  uint32_t free_idx,
80  float64_t* cp_data,
81  uint32_t dim);
82 
91  bmrm_ll** head,
92  bmrm_ll** tail,
93  bool* map,
94  float64_t* icp);
95 
99 void clean_icp(ICP_stats* icp_stats,
100  BmrmStatistics& bmrm,
101  bmrm_ll** head,
102  bmrm_ll** tail,
103  float64_t*& H,
104  float64_t*& diag_H,
105  float64_t*& beta,
106  bool*& map,
107  uint32_t cleanAfter,
108  float64_t*& b,
109  uint32_t*& I,
110  uint32_t cp_models = 0
111  );
112 
118 inline float64_t * get_cutting_plane(bmrm_ll *ptr) { return ptr->address; }
119 
126 inline uint32_t find_free_idx(bool *map, uint32_t size)
127 {
128  for (uint32_t i=0; i<size; ++i) if (map[i]) return i;
129  SG_SERROR("No free index available in CP buffer of size %d.\n", size);
130  return size-1;
131 }
132 
151 BmrmStatistics svm_bmrm_solver(
152  CDualLibQPBMSOSVM *machine,
153  float64_t *W,
154  float64_t TolRel,
155  float64_t TolAbs,
156  float64_t _lambda,
157  uint32_t _BufSize,
158  bool cleanICP,
159  uint32_t cleanAfter,
160  float64_t K,
161  uint32_t Tmax,
162  bool verbose
163  );
164 
165 }
166 
167 #endif /* libbmrm_h */

SHOGUN Machine Learning Toolbox - Documentation