SHOGUN  v3.2.0
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 {
42  uint32_t idx;
43 };
44 
47 {
49  uint32_t maxCPs;
50 
52  uint32_t* ICPcounter;
53 
56 
58  uint32_t* ACPs;
59 
62 };
63 
74  bmrm_ll** tail,
75  bool* map,
76  float64_t* A,
77  uint32_t free_idx,
78  float64_t* cp_data,
79  uint32_t dim);
80 
89  bmrm_ll** head,
90  bmrm_ll** tail,
91  bool* map,
92  float64_t* icp);
93 
97 void clean_icp(ICP_stats* icp_stats,
98  BmrmStatistics& bmrm,
99  bmrm_ll** head,
100  bmrm_ll** tail,
101  float64_t*& H,
102  float64_t*& diag_H,
103  float64_t*& beta,
104  bool*& map,
105  uint32_t cleanAfter,
106  float64_t*& b,
107  uint32_t*& I,
108  uint32_t cp_models = 0
109  );
110 
116 inline float64_t * get_cutting_plane(bmrm_ll *ptr) { return ptr->address; }
117 
124 inline uint32_t find_free_idx(bool *map, uint32_t size)
125 {
126  for (uint32_t i=0; i<size; ++i) if (map[i]) return i;
127  SG_SERROR("No free index available in CP buffer of size %d.\n", size);
128  return size-1;
129 }
130 
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 verbose
161  );
162 
163 }
164 
165 #endif /* libbmrm_h */
static float64_t * H
Definition: libbmrm.cpp:27
float64_t * H_buff
Definition: libbmrm.h:61
Class DualLibQPBMSOSVM that uses Bundle Methods for Regularized Risk Minimization algorithms for stru...
float64_t * get_cutting_plane(bmrm_ll *ptr)
Definition: libbmrm.h:116
uint32_t idx
Definition: libbmrm.h:42
bmrm_ll * next
Definition: libbmrm.h:38
void remove_cutting_plane(bmrm_ll **head, bmrm_ll **tail, bool *map, float64_t *icp)
Definition: libbmrm.cpp:60
uint32_t * ACPs
Definition: libbmrm.h:58
uint32_t find_free_idx(bool *map, uint32_t size)
Definition: libbmrm.h:124
bmrm_ll * prev
Definition: libbmrm.h:36
double float64_t
Definition: common.h:48
BmrmStatistics svm_bmrm_solver(CDualLibQPBMSOSVM *machine, float64_t *W, float64_t TolRel, float64_t TolAbs, float64_t _lambda, uint32_t _BufSize, bool cleanICP, uint32_t cleanAfter, float64_t K, uint32_t Tmax, bool verbose)
Definition: libbmrm.cpp:185
float64_t ** ICPs
Definition: libbmrm.h:55
uint32_t maxCPs
Definition: libbmrm.h:49
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:16
#define IGNORE_IN_CLASSLIST
Definition: CPLEXSVM.h:21
void add_cutting_plane(bmrm_ll **tail, bool *map, float64_t *A, uint32_t free_idx, float64_t *cp_data, uint32_t dim)
Definition: libbmrm.cpp:30
uint32_t * ICPcounter
Definition: libbmrm.h:52
#define SG_SERROR(...)
Definition: SGIO.h:181
float64_t * address
Definition: libbmrm.h:40
void clean_icp(ICP_stats *icp_stats, BmrmStatistics &bmrm, bmrm_ll **head, bmrm_ll **tail, float64_t *&Hmat, float64_t *&diag_H, float64_t *&beta, bool *&map, uint32_t cleanAfter, float64_t *&b, uint32_t *&I, uint32_t cp_models)
Definition: libbmrm.cpp:93

SHOGUN Machine Learning Toolbox - Documentation