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 {
34 extern uint32_t BufSize;
35 
45  uint32_t idx;
46 };
47 
50 {
52  uint32_t maxCPs;
53 
55  uint32_t* ICPcounter;
56 
59 
61  uint32_t* ACPs;
62 
65 };
66 
77  bmrm_ll** tail,
78  bool* map,
79  float64_t* A,
80  uint32_t free_idx,
81  float64_t* cp_data,
82  uint32_t dim);
83 
92  bmrm_ll** head,
93  bmrm_ll** tail,
94  bool* map,
95  float64_t* icp);
96 
100 void clean_icp(ICP_stats* icp_stats,
101  BmrmStatistics& bmrm,
102  bmrm_ll** head,
103  bmrm_ll** tail,
104  float64_t*& H,
105  float64_t*& diag_H,
106  float64_t*& beta,
107  bool*& map,
108  uint32_t cleanAfter,
109  float64_t*& b,
110  uint32_t*& I,
111  uint32_t cp_models = 0
112  );
113 
119 inline float64_t * get_cutting_plane(bmrm_ll *ptr) { return ptr->address; }
120 
127 inline uint32_t find_free_idx(bool *map, uint32_t size)
128 {
129  for (uint32_t i=0; i<size; ++i) if (map[i]) return i;
130  SG_SERROR("No free index available in CP buffer of size %d.\n", size);
131  return size-1;
132 }
133 
149 BmrmStatistics svm_bmrm_solver(
150  CDualLibQPBMSOSVM *machine,
151  float64_t *W,
152  float64_t TolRel,
153  float64_t TolAbs,
154  float64_t _lambda,
155  uint32_t _BufSize,
156  bool cleanICP,
157  uint32_t cleanAfter,
158  float64_t K,
159  uint32_t Tmax,
160  bool store_train_info
161  );
162 
163 }
164 
165 #endif /* libbmrm_h */

SHOGUN Machine Learning Toolbox - Documentation