diff options
Diffstat (limited to 'src/service/cadet/desirability_table.c')
-rw-r--r-- | src/service/cadet/desirability_table.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/service/cadet/desirability_table.c b/src/service/cadet/desirability_table.c new file mode 100644 index 000000000..b4db7c2dd --- /dev/null +++ b/src/service/cadet/desirability_table.c | |||
@@ -0,0 +1,34 @@ | |||
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 "platform.h" | ||
9 | #include <stdio.h> | ||
10 | |||
11 | int | ||
12 | main () | ||
13 | { | ||
14 | for (unsigned int num_alts = 1; num_alts < 10; num_alts++) | ||
15 | for (unsigned int off = 0; off < 10; off++) | ||
16 | for (double delta = -(int) off; delta <= 5; delta += 0.25) | ||
17 | { | ||
18 | double weight_alts; | ||
19 | |||
20 | if (delta <= -1.0) | ||
21 | weight_alts = -1.0 * num_alts / delta; /* discount alternative paths */ | ||
22 | else if (delta >= 1.0) | ||
23 | weight_alts = 1.0 * num_alts * delta; /* overcount alternative paths */ | ||
24 | else | ||
25 | weight_alts = 1.0 * num_alts; /* count alternative paths normally */ | ||
26 | |||
27 | fprintf (stderr, | ||
28 | "Paths: %u Offset: %u Delta: %5.2f SCORE: %f\n", | ||
29 | num_alts, | ||
30 | off, | ||
31 | delta, | ||
32 | ((off + 1.0) / (weight_alts * weight_alts))); | ||
33 | } | ||
34 | } | ||