diff --git a/src/users/user_windows.cpp b/src/users/user_windows.cpp index 9117d3cd116d1e0c0c6f5f47ed4ea212b7d0f865..2c37ac2bec2c1168dbd6368c822a40a729ae73c6 100644 --- a/src/users/user_windows.cpp +++ b/src/users/user_windows.cpp @@ -25,9 +25,7 @@ std::vector<DMWindow_list>::size_type DMWindow_list::index_in_dm_window(double d return content.size(); } -void DMUserMultiBehavior::init_prob(const rapidjson::Value ¶m,uint_fast32_t random_seed){ - random_gen = std::mt19937(random_seed); - +void DMUserMultiBehavior::init_prob(const rapidjson::Value ¶m){ //Red window probability initialization std::vector<double> red_prob (5,0.0); @@ -99,7 +97,8 @@ DMUserMultiBehavior::DMUserMultiBehavior( this->logger = logger; red_window_buffer = nullptr; yellow_window_buffer = nullptr; - init_prob(param,random_seed); + random_gen = std::mt19937(random_seed); + init_prob(param); } DMUserMultiBehavior::~DMUserMultiBehavior() diff --git a/src/users/user_windows.hpp b/src/users/user_windows.hpp index ded3fd4f0fcb178050fc452e9deef6533c45437a..1f5aaec67b935cc2918a6a3a2c1b4a79bdfb412d 100644 --- a/src/users/user_windows.hpp +++ b/src/users/user_windows.hpp @@ -41,13 +41,11 @@ public: uint_fast32_t random_seed, DMWindow_list *yellow_windows, DMWindow_list *red_windows, LoggerUserStat* logger); ~DMUserMultiBehavior(); - void init_prob(const rapidjson::Value ¶m, uint_fast32_t random_seed); double next_submission(); void jobs_to_submit( double date, std::list<shared_ptr<Job> > &jobs, std::list< const Profile *> &profiles); - bool is_in_yellow_window(double date); - bool is_in_red_window(double date); - void log_behavior(shared_ptr<Job> job, std::string behavior_name, long delay_time); + + protected: DMWindow_list *yellow_windows; DMWindow_list * red_windows; @@ -57,18 +55,38 @@ protected: std::uniform_real_distribution<double> distribution = std::uniform_real_distribution<double>(0.0, 1.0); LoggerUserStat *logger = nullptr ; + + void init_prob(const rapidjson::Value ¶m); + bool is_in_yellow_window(double date); + bool is_in_red_window(double date); + void log_behavior(shared_ptr<Job> job, std::string behavior_name, long delay_time); + bool C_you_later_job(double date, double next_time,shared_ptr<Job> job); /** - * function called each time the user want to submit a job it does the following : - * - if the user is in a red window - * the user adopt the behavior define in red_window_behavior - * - if the user is in a yellow window AND not in a red one - * the user adopt the behavior define in yellow_windows_behavior - * - else the user submit it job without any change + * @brief function called each time the user want to submit a job + * @details This function does the following : + * - if the user is in a red window + * the user adopt the behavior define in red_window_behavior + * - if the user is in a yellow window AND not in a red one + * the user adopt the behavior define in yellow_windows_behavior + * - else the user submit its job without any change */ bool handle_job(double date,shared_ptr<Job> job,Profile *profile); + + /** + * @brief function called when the user submit a job in red state + * @details This function do the 5 behavior for red windows of the class + * (degrad,reconfig,renonce,rigid,see_you_later) + * following the provided probabilities given at the creation of the class + */ bool red_window_behavior(double date,shared_ptr<Job> job, Profile *profile); + + /** + * @brief function called when the user submit a job in yellow state + * @details This function do the 3 behaviors for yellow windows (degrad,reconfig, rigid) + * following the provided probabilities given at the creation of the class + */ bool yellow_window_behavior(shared_ptr<Job> job, Profile *profile); double red_prob_Cyoulater,red_prob_renonce, red_prob_reconfig,red_prob_degrad; double red_prob_total;