Browse Source

calculer_intra()

Signed-off-by: wmb <wmb@teknik.io>
tags/v0.1.0
wmb 9 months ago
parent
commit
6cd7a2bef7
1 changed files with 5 additions and 7 deletions
  1. 5
    7
      main.c

+ 5
- 7
main.c View File

@@ -28,8 +28,8 @@ int solution_voisine(solution *dest, const solution src);
double fonction_objective(const solution s);

static double calculer_inter(const solution s, vector *cgs);
static double calculer_intra(const solution s, vector *cgs);
#endif /* 0 */
static double calculer_intra(const solution s, vector *cgs);

solution solution_opt;
solution new_solution;
@@ -269,7 +269,6 @@ static double calculer_inter(const solution s, vector *cgs)

static double calculer_intra(const solution s, vector *cgs)
{
const size_t n = sizeof(*s) / sizeof((*s)[0]);
double intra = 0.0;
int cluster;

@@ -278,14 +277,13 @@ static double calculer_intra(const solution s, vector *cgs)
int vectors_in_this_cluster = 0;
size_t i;

centre_gravite(cluster, s, cgs[cluster], 42);

for (i = 0; i < n; i++) {
if ((*s)[i] != cluster)
for (i = 0; i < N_VECTORS; i++) {
if (s[i] != cluster)
continue;

++vectors_in_this_cluster;
intra_for_this_cluster += distance(&cg, &benchmark_data[i]);
intra_for_this_cluster += distance((const vector *) cgs[cluster],
(const vector *) benchmark_data[i]);
}

intra += intra_for_this_cluster / (double) vectors_in_this_cluster;

Loading…
Cancel
Save