Projet du cours MPRI 2.24.2 "Résolution de problèmes d'optimisation avec heuristiques de recherche" : https://wikimpri.dptinfo.ens-cachan.fr/doku.php?id=cours:c-2-24-2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ParameterOptimizer.h 2.1KB

  1. #ifndef PARAMETEROPTIMIZER_H
  2. #define PARAMETEROPTIMIZER_H
  3. #include <iostream>
  4. #include <vector>
  5. #include <string>
  6. #include <sstream>
  7. #include <fstream>
  8. #include "heuristics/SearchHeuristic.h"
  9. #include "analysis/analysis.h"
  10. struct ConfidenceInterval {
  11. ConfidenceInterval(double d, double m, double u, double t=-1) : down{d}, mean{m}, up{u}, thresold{t} {};
  12. double down;
  13. double mean;
  14. double up;
  15. double thresold;
  16. };
  17. struct TestWave {
  18. TestWave(int nb, double q, int d=0) : nb_tests{nb}, slq{q}, depth{d} {};
  19. int nb_tests;
  20. double slq; // Student Law Quartile
  21. int depth;
  22. };
  23. class ParameterOptimizer
  24. {
  25. public:
  26. ParameterOptimizer(std::default_random_engine& randomizer);
  27. virtual ~ParameterOptimizer();
  28. // Algorithms
  29. virtual SearchHeuristic* get_context(unsigned int num_context, double parameter, std::default_random_engine& randomizer) = 0;
  30. virtual std::string display_context(unsigned int num_context);
  31. void set_nb_contexts(unsigned int nb_contexts);
  32. // Interval
  33. void set_study_interval(double initial_parameter, double final_parameter, double parameter_step);
  34. // Test waves
  35. void add_test_wave(int nb_tests, double student_law_quartile, int depth=0);
  36. // Running
  37. virtual std::string get_context_for_csvfile(unsigned int num_context);
  38. void save_run(std::string filename);
  39. std::vector<ConfidenceInterval> run_step(int num_step=0, bool displaying=true);
  40. std::vector<ConfidenceInterval> run_step(int num_step, int first_context, int nb_explored_contexts, double initial_parameter, double final_parameter, double parameter_step, bool displaying=true);
  41. std::vector<ConfidenceInterval> run(bool displaying=true);
  42. protected:
  43. private:
  44. unsigned int m_nb_contexts;
  45. std::default_random_engine& m_randomizer;
  46. double m_initial_parameter;
  47. double m_final_parameter;
  48. double m_parameter_step;
  49. std::vector<TestWave> m_waves;
  50. bool m_saving_in_csvfile;
  51. std::string m_csvfile_name;
  52. };
  53. #endif // PARAMETEROPTIMIZER_H