SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 #ifdef USE_GPL_SHOGUN
19 
20 #include <shogun/lib/common.h>
23 
24 #define LIBBMRM_PLUS_INF (-log(0.0))
25 #define LIBBMRM_CALLOC(x, y) SG_CALLOC(y, x)
26 #define LIBBMRM_REALLOC(x, y) SG_REALLOC(x, y)
27 #define LIBBMRM_FREE(x) SG_FREE(x)
28 #define LIBBMRM_MEMCPY(x, y, z) memcpy(x, y, z)
29 #define LIBBMRM_MEMMOVE(x, y, z) memmove(x, y, z)
30 #define LIBBMRM_INDEX(ROW, COL, NUM_ROWS) ((COL)*(NUM_ROWS)+(ROW))
31 #define LIBBMRM_ABS(A) ((A) < 0 ? -(A) : (A))
32 
33 namespace shogun
34 {
36 extern uint32_t BufSize;
37 
39 IGNORE_IN_CLASSLIST struct bmrm_ll {
41  bmrm_ll *prev;
43  bmrm_ll *next;
45  float64_t *address;
47  uint32_t idx;
48 };
49 
51 IGNORE_IN_CLASSLIST struct ICP_stats
52 {
54  uint32_t maxCPs;
55 
57  uint32_t* ICPcounter;
58 
60  float64_t** ICPs;
61 
63  uint32_t* ACPs;
64 
66  float64_t* H_buff;
67 };
68 
78 void add_cutting_plane(
79  bmrm_ll** tail,
80  bool* map,
81  float64_t* A,
82  uint32_t free_idx,
83  float64_t* cp_data,
84  uint32_t dim);
85 
93 void remove_cutting_plane(
94  bmrm_ll** head,
95  bmrm_ll** tail,
96  bool* map,
97  float64_t* icp);
98 
102 void clean_icp(ICP_stats* icp_stats,
103  BmrmStatistics& bmrm,
104  bmrm_ll** head,
105  bmrm_ll** tail,
106  float64_t*& H,
107  float64_t*& diag_H,
108  float64_t*& beta,
109  bool*& map,
110  uint32_t cleanAfter,
111  float64_t*& b,
112  uint32_t*& I,
113  uint32_t cp_models = 0
114  );
115 
121 inline float64_t * get_cutting_plane(bmrm_ll *ptr) { return ptr->address; }
122 
129 inline uint32_t find_free_idx(bool *map, uint32_t size)
130 {
131  for (uint32_t i=0; i<size; ++i) if (map[i]) return i;
132  SG_SERROR("No free index available in CP buffer of size %d.\n", size);
133  return size-1;
134 }
135 
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 store_train_info
163  );
164 
165 }
166 #endif //USE_GPL_SHOGUN
167 #endif /* libbmrm_h */
double float64_t
Definition: common.h:50
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
#define IGNORE_IN_CLASSLIST
Definition: CPLEXSVM.h:24
#define SG_SERROR(...)
Definition: SGIO.h:179

SHOGUN Machine Learning Toolbox - Documentation