desirability_table.c 1010 B

123456789101112131415161718192021222324252627282930313233
  1. /* This file is in the public domain. */
  2. /**
  3. * @brief Program to simulate results from #GCP_get_desirability_of_path()
  4. * for various plausible inputs.
  5. * @author Christian Grothoff
  6. */
  7. #include <stdio.h>
  8. int
  9. main()
  10. {
  11. for (unsigned int num_alts = 1; num_alts < 10; num_alts++)
  12. for (unsigned int off = 0; off < 10; off++)
  13. for (double delta = -(int)off; delta <= 5; delta += 0.25)
  14. {
  15. double weight_alts;
  16. if (delta <= -1.0)
  17. weight_alts = -1.0 * num_alts / delta; /* discount alternative paths */
  18. else if (delta >= 1.0)
  19. weight_alts = 1.0 * num_alts * delta; /* overcount alternative paths */
  20. else
  21. weight_alts = 1.0 * num_alts; /* count alternative paths normally */
  22. fprintf(stderr,
  23. "Paths: %u Offset: %u Delta: %5.2f SCORE: %f\n",
  24. num_alts,
  25. off,
  26. delta,
  27. ((off + 1.0) / (weight_alts * weight_alts)));
  28. }
  29. }