projects
/
clueless-kmeans.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f371b63
)
Cosmetics.
author
Francois Fleuret
<francois@fleuret.org>
Thu, 28 Mar 2013 07:46:40 +0000
(08:46 +0100)
committer
Francois Fleuret
<francois@fleuret.org>
Thu, 28 Mar 2013 07:46:40 +0000
(08:46 +0100)
clusterer.cc
patch
|
blob
|
history
diff --git
a/clusterer.cc
b/clusterer.cc
index
60cead1
..
02a8c8b
100644
(file)
--- a/
clusterer.cc
+++ b/
clusterer.cc
@@
-180,6
+180,8
@@
scalar_t Clusterer::uninformative_lp_cluster_association(int nb_points, scalar_t
// The coefficients for the constraints are passed to the glpk
// functions with a sparse representation.
// The coefficients for the constraints are passed to the glpk
// functions with a sparse representation.
+ // ** GLPK USES INDEXES STARTING AT 1, NOT 0. **
+
int nb_coeffs = nb_points * _nb_clusters + nb_points * _nb_clusters;
int *coeff_row = new int[nb_coeffs + 1];
int nb_coeffs = nb_points * _nb_clusters + nb_points * _nb_clusters;
int *coeff_row = new int[nb_coeffs + 1];
@@
-207,8
+209,8
@@
scalar_t Clusterer::uninformative_lp_cluster_association(int nb_points, scalar_t
glp_add_cols(lp, nb_points * _nb_clusters);
// The constraints (A) will be expressed by putting directly bounds
glp_add_cols(lp, nb_points * _nb_clusters);
// The constraints (A) will be expressed by putting directly bounds
- // on the
column variables. So we need one row per (B) constraint,
- // and one per (C) constraint.
+ // on the
variables (i.e. one per column). So we need one row per
+ //
(B) constraint,
and one per (C) constraint.
glp_add_rows(lp, nb_points + _nb_clusters * nb_classes);
glp_add_rows(lp, nb_points + _nb_clusters * nb_classes);
@@
-238,11
+240,7
@@
scalar_t Clusterer::uninformative_lp_cluster_association(int nb_points, scalar_t
for(int n = 1; n <= nb_points; n++) {
int row = n;
glp_set_row_bnds(lp, row, GLP_FX, 1.0, 1.0);
for(int n = 1; n <= nb_points; n++) {
int row = n;
glp_set_row_bnds(lp, row, GLP_FX, 1.0, 1.0);
- }
-
- for(int n = 1; n <= nb_points; n++) {
for(int k = 1; k <= _nb_clusters; k++) {
for(int k = 1; k <= _nb_clusters; k++) {
- int row = n;
coeff_row[n_coeff] = row;
coeff_col[n_coeff] = nb_points * (k - 1) + n;
coeff_wgt[n_coeff] = 1.0;
coeff_row[n_coeff] = row;
coeff_col[n_coeff] = nb_points * (k - 1) + n;
coeff_wgt[n_coeff] = 1.0;
@@
-260,12
+258,6
@@
scalar_t Clusterer::uninformative_lp_cluster_association(int nb_points, scalar_t
int row = nb_points + (k - 1) * nb_classes + c;
scalar_t tau = nb_samples_per_class[c-1] / scalar_t(_nb_clusters);
glp_set_row_bnds(lp, row, GLP_FX, tau, tau);
int row = nb_points + (k - 1) * nb_classes + c;
scalar_t tau = nb_samples_per_class[c-1] / scalar_t(_nb_clusters);
glp_set_row_bnds(lp, row, GLP_FX, tau, tau);
- }
- }
-
- for(int k = 1; k <= _nb_clusters; k++) {
- for(int c = 1; c <= nb_classes; c++) {
- int row = nb_points + (k - 1) * nb_classes + c;
for(int n = 1; n <= nb_points; n++) {
if(labels[n-1] == c - 1) {
coeff_row[n_coeff] = row;
for(int n = 1; n <= nb_points; n++) {
if(labels[n-1] == c - 1) {
coeff_row[n_coeff] = row;