Skip to content
Snippets Groups Projects
Commit 0cdfef48 authored by jgatt's avatar jgatt
Browse files

fix : fixed error that prevent compilation

parent a44b2b91
No related branches found
No related tags found
1 merge request!12Merge Request multibehavior
Pipeline #5426 passed
#include "broker/log_user_stat.hpp"
#include "users/log_user_stat.hpp"
#include "../pempek_assert.hpp"
BehaviorStat::BehaviorStat(Job* job,
BehaviorStat::BehaviorStat(shared_ptr<Job> job,
std::string behavior_name,double time_delayed){
this->job = job;
this->behavior_name = behavior_name;
......@@ -41,7 +41,7 @@ LoggerUserStat::LoggerUserStat(std::string log_folder)
begin_to_write=0;
}
void LoggerUserStat::add_stat(Job *job,std::string behavior_name, double time_delayed){
void LoggerUserStat::add_stat(shared_ptr<Job> job,std::string behavior_name, double time_delayed){
BehaviorStat to_add = BehaviorStat(job,behavior_name,time_delayed);
behaviors.push_back(to_add);
if(behaviors.size()-begin_to_write >= write_threshold){
......
......@@ -6,13 +6,13 @@
/**
* library dedicated to logging user_behavior
*/
using namespace std;
struct BehaviorStat {
Job *job;
shared_ptr<Job> job;
std::string behavior_name;
double time_delayed;
double submission_time;
BehaviorStat( Job* job,
BehaviorStat( shared_ptr<Job> job,
std::string behavior_name,double time_delayed);
std::vector<std::string> split_id();
boost::basic_format<char> format();
......@@ -24,7 +24,7 @@ struct BehaviorStat {
class LoggerUserStat {
public :
LoggerUserStat(std::string log_folder);
void add_stat(Job *job,std::string behavior_name, double time_delayed);
void add_stat(shared_ptr<Job> job,std::string behavior_name, double time_delayed);
void log_stat();
protected :
bool put_header;
......
......@@ -458,7 +458,7 @@ DMUserMultiBehavior::~DMUserMultiBehavior()
}
void DMUserMultiBehavior::jobs_to_submit(
double date, std::list<Job *> &jobs, std::list<Profile *> &profiles)
double date, std::list<shared_ptr<Job>> &jobs, std::list< const Profile *> &profiles)
{
DMUserRenonce::jobs_to_submit(date, jobs, profiles);
}
......@@ -558,7 +558,7 @@ bool DMUserDegrad::handle_job(double date, shared_ptr<Job> job, Profile *profile
return true;
}
bool DMUserRenonce::renonce_job(shared_ptr<Job> job,Profile *profile)
bool DMUserRenonce::renonce_job(shared_ptr<Job> job)
{
/* Signals that the job must not be executed and delete it from the
* original queue */
......@@ -570,7 +570,7 @@ bool DMUserRenonce::renonce_job(shared_ptr<Job> job,Profile *profile)
+= job->nb_requested_resources * std::stol(job->profile);
return false;
}
bool DMUserRenonce::handle_job(double date, Job *job, Profile *profile)
bool DMUserRenonce::handle_job(double date, shared_ptr<Job> job, Profile *profile)
{
if (dm_window->date_in_dm_window(date))
{
......@@ -604,7 +604,7 @@ bool DMUserDelay::delay_job(shared_ptr<Job> job)
/* Return "Do not execute now" */
return false;
}
bool DMUserDelay::handle_job(double date, Job *job, Profile *profile)
bool DMUserDelay::handle_job(double date, shared_ptr<Job> job, Profile *profile)
{
if (dm_window->date_in_dm_window(date))
{
......@@ -618,7 +618,7 @@ bool DMUserDelay::handle_job(double date, Job *job, Profile *profile)
}
}
bool DMUserMultiBehavior::C_you_later_job(double date, double next_time,Job* job)
bool DMUserMultiBehavior::C_you_later_job(double date, double next_time,shared_ptr<Job> job)
{
/* Log... */
log_behavior(job,"C_you_later",next_time);
......@@ -630,14 +630,16 @@ bool DMUserMultiBehavior::C_you_later_job(double date, double next_time,Job* job
/* Put job back in the queue and sort */
SortableJobOrder::UpdateInformation update_info(0);
original_trace->insert_job(job);
Job *j = new Job();
*j = *job;
original_trace->insert_job(j);
original_trace->sort_queue(&update_info);
/* Return "Do not execute now" */
return false;
}
bool DMUserMultiBehavior::red_window_behavior(double date,Job* job,Profile *profile)
bool DMUserMultiBehavior::red_window_behavior(double date,shared_ptr<Job> job,Profile *profile)
{
/*
* We decide at random the behavior
......@@ -686,7 +688,7 @@ bool DMUserMultiBehavior::red_window_behavior(double date,Job* job,Profile *prof
return true;
}
}
bool DMUserMultiBehavior::yellow_window_behavior(Job* job,Profile *profile){
bool DMUserMultiBehavior::yellow_window_behavior(shared_ptr<Job> job,Profile *profile){
/*
* We decide at random the behavior (rigid, degrad, reconfig)
* that will be done on this job
......@@ -722,7 +724,7 @@ bool DMUserMultiBehavior::yellow_window_behavior(Job* job,Profile *profile){
}
}
void DMUserMultiBehavior::log_behavior(Job *job, std::string behavior_name, double delay_time)
void DMUserMultiBehavior::log_behavior(shared_ptr<Job> job, std::string behavior_name, double delay_time)
{
if(logger){
logger->add_stat(job,behavior_name,delay_time);
......@@ -759,7 +761,7 @@ bool DMUserMultiBehavior::is_in_yellow_window(double date){
}
return false;
}
bool DMUserMultiBehavior::handle_job(double date, Job *job, Profile *profile)
bool DMUserMultiBehavior::handle_job(double date, shared_ptr<Job> job, Profile *profile)
{
/*
* function called each time the user want to submit a job it does the following :
......
......@@ -4,7 +4,7 @@
#include "users/user.hpp"
#include <random>
#include "queue.hpp"
#include "broker/log_user_stat.hpp"
#include "users/log_user_stat.hpp"
/**
* The demand response window during which the users are enclined to reduce
* their consumption. (semi-closed interval [inf, sup[)
......@@ -229,10 +229,10 @@ class DMUserMultiBehavior : public DMUserRenonce, public DMUserDelay,
double yellow_prob_total;
double next_submission();
void jobs_to_submit(
double date, std::list<Job *> &jobs, std::list<Profile *> &profiles);
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(Job* job, std::string behavior_name, double delay_time);
void log_behavior(shared_ptr<Job> job, std::string behavior_name, double delay_time);
protected:
DMWindow_list *yellow_windows;
DMWindow_list * red_windows;
......@@ -242,8 +242,8 @@ class DMUserMultiBehavior : public DMUserRenonce, public DMUserDelay,
std::uniform_real_distribution<double> distribution
= std::uniform_real_distribution<double>(0.0, 1.0);
LoggerUserStat *logger = nullptr ;
bool C_you_later_job(double date, double next_time,Job* job);
bool handle_job(double date,Job *job,Profile *profile);
bool red_window_behavior(double date,Job *job, Profile *profile);
bool yellow_window_behavior(Job *job, Profile *profile);
bool C_you_later_job(double date, double next_time,shared_ptr<Job> job);
bool handle_job(double date,shared_ptr<Job> job,Profile *profile);
bool red_window_behavior(double date,shared_ptr<Job> job, Profile *profile);
bool yellow_window_behavior(shared_ptr<Job> job, Profile *profile);
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment