SHOGUN  v2.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 #include <shogun/lib/common.h>
16 
17 #ifndef libbmrm_h
18 #define libbmrm_h
19 
20 #define LIBBMRM_PLUS_INF (-log(0.0))
21 #define LIBBMRM_CALLOC(x, y) calloc(x, y)
22 #define LIBBMRM_REALLOC(x, y) realloc(x, y)
23 #define LIBBMRM_FREE(x) SG_FREE(x)
24 #define LIBBMRM_MEMCPY(x, y, z) memcpy(x, y, z)
25 #define LIBBMRM_MEMMOVE(x, y, z) memmove(x, y, z)
26 #define LIBBMRM_INDEX(ROW, COL, NUM_ROWS) ((COL)*(NUM_ROWS)+(ROW))
27 #define LIBBMRM_ABS(A) ((A) < 0 ? -(A) : (A))
28 
29 namespace shogun
30 {
33 {
36  {
37  nIter = 0;
38  nCP = 0;
39  nzA = 0;
40  Fp = 0;
41  Fd = 0;
42  qp_exitflag = 0;
43  exitflag = 0;
44  };
45 
48 
50  bool load_serializable(CSerializableFile* file, const char* prefix="") { return false; }
51 
53  bool save_serializable(CSerializableFile* file, const char* prefix="") { return false; }
54 
56  uint32_t nIter;
57 
59  uint32_t nCP;
60 
62  uint32_t nzA;
63 
66 
69 
71  int8_t qp_exitflag;
72 
78  int8_t exitflag;
79 
82 
85 
88 };
89 
99  uint32_t idx;
100 };
101 
111 void add_cutting_plane(
112  bmrm_ll** tail,
113  bool* map,
114  float64_t* A,
115  uint32_t free_idx,
116  float64_t* cp_data,
117  uint32_t dim);
118 
127  bmrm_ll** head,
128  bmrm_ll** tail,
129  bool* map,
130  float64_t* icp);
131 
137 inline float64_t * get_cutting_plane(bmrm_ll *ptr) { return ptr->address; }
138 
145 inline uint32_t find_free_idx(bool *map, uint32_t size)
146 { for(uint32_t i=0; i<size; ++i) if (map[i]) return i; return size+1; }
147 
166 bmrm_return_value_T svm_bmrm_solver(
167  CStructuredModel *model,
168  float64_t *W,
169  float64_t TolRel,
170  float64_t TolAbs,
171  float64_t _lambda,
172  uint32_t _BufSize,
173  bool cleanICP,
174  uint32_t cleanAfter,
175  float64_t K,
176  uint32_t Tmax,
177  bool verbose
178  );
179 
180 }
181 
182 #endif /* libbmrm_h */

SHOGUN Machine Learning Toolbox - Documentation