diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-29 23:41:23 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-29 23:41:23 +0100 |
commit | 4a2c91ed9f94920b4c7771a618e4177dd8d91bc1 (patch) | |
tree | 262688ad47cac1a0794e9992a50bd2e536df48bb /src/cadet/desirability_table.c | |
parent | 93ea24d9cde704d1c8465bb5b2665855b37256a3 (diff) | |
download | gnunet-4a2c91ed9f94920b4c7771a618e4177dd8d91bc1.tar.gz gnunet-4a2c91ed9f94920b4c7771a618e4177dd8d91bc1.zip |
add path desirability calculations
Diffstat (limited to 'src/cadet/desirability_table.c')
-rw-r--r-- | src/cadet/desirability_table.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/cadet/desirability_table.c b/src/cadet/desirability_table.c new file mode 100644 index 000000000..21ec3e388 --- /dev/null +++ b/src/cadet/desirability_table.c | |||
@@ -0,0 +1,35 @@ | |||
1 | /* This file is in the public domain. */ | ||
2 | |||
3 | /** | ||
4 | * @brief Program to simulate results from #GCP_get_desirability_of_path() | ||
5 | * for various plausible inputs. | ||
6 | * @author Christian Grothoff | ||
7 | */ | ||
8 | #include <stdio.h> | ||
9 | |||
10 | int | ||
11 | main () | ||
12 | { | ||
13 | for (unsigned int num_alts=1; num_alts<10; num_alts++) | ||
14 | for (unsigned int off=0; off<10; off++) | ||
15 | for (double delta=-(int) off;delta<=5;delta += 0.25) | ||
16 | { | ||
17 | double weight_alts; | ||
18 | |||
19 | if (delta <= - 1.0) | ||
20 | weight_alts = - 1.0 * num_alts / delta; /* discount alternative paths */ | ||
21 | else if (delta >= 1.0) | ||
22 | weight_alts = 1.0 * num_alts * delta; /* overcount alternative paths */ | ||
23 | else | ||
24 | weight_alts = 1.0 * num_alts; /* count alternative paths normally */ | ||
25 | |||
26 | fprintf (stderr, | ||
27 | "Paths: %u Offset: %u Delta: %5.2f SCORE: %f\n", | ||
28 | num_alts, | ||
29 | off, | ||
30 | delta, | ||
31 | ((off + 1.0) / (weight_alts * weight_alts))); | ||
32 | } | ||
33 | |||
34 | |||
35 | } | ||