Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
batmen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sepia-pub
mael
batmen
Commits
31469486
Commit
31469486
authored
2 years ago
by
jgatt
Browse files
Options
Downloads
Patches
Plain Diff
state computation has been move to its own class
parent
f748ee8a
Branches
multibehavior_mono_multi_core
Branches containing commit
Tags
Tags containing commit
1 merge request
!20
merge requested multibehavor_mono_multi_core
Pipeline
#6018
passed
2 years ago
Stage: build-and-test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/users/broker.cpp
+3
-2
3 additions, 2 deletions
src/users/broker.cpp
src/users/broker.hpp
+1
-0
1 addition, 0 deletions
src/users/broker.hpp
src/users/user_windows.cpp
+42
-22
42 additions, 22 deletions
src/users/user_windows.cpp
src/users/user_windows.hpp
+26
-8
26 additions, 8 deletions
src/users/user_windows.hpp
with
72 additions
and
32 deletions
src/users/broker.cpp
+
3
−
2
View file @
31469486
...
@@ -54,6 +54,7 @@ Broker::Broker(rapidjson::Document *user_description_file)
...
@@ -54,6 +54,7 @@ Broker::Broker(rapidjson::Document *user_description_file)
PPK_ASSERT_ERROR
(
red_windows_list
->
have_no_common_element
(
yellow_windows_list
),
PPK_ASSERT_ERROR
(
red_windows_list
->
have_no_common_element
(
yellow_windows_list
),
"Error red_windows field and yellow_windows field have at least one common element in their interval"
);
"Error red_windows field and yellow_windows field have at least one common element in their interval"
);
}
}
state_automata
=
new
DMWindowAutomata
(
dm_window
,
red_windows_list
,
yellow_windows_list
);
//seed parameter parsing
//seed parameter parsing
bool
seed_defined
=
false
;
bool
seed_defined
=
false
;
...
@@ -163,8 +164,8 @@ Broker::Broker(rapidjson::Document *user_description_file)
...
@@ -163,8 +164,8 @@ Broker::Broker(rapidjson::Document *user_description_file)
seed_defined
,
seed_defined
,
"No field 'seed' defined although dm_user_multi_behavior "
"No field 'seed' defined although dm_user_multi_behavior "
"needs it"
);
"needs it"
);
user
=
new
DMUserMultiBehavior
(
name
,
param
,
dm_window
,
user
=
new
DMUserMultiBehavior
(
name
,
param
,
seed_generator
(),
yellow_windows_list
,
red_windows_list
,
seed_generator
(),
state_automata
,
logger_user_stat
);
logger_user_stat
);
}
}
/* Feedback user */
/* Feedback user */
...
...
This diff is collapsed.
Click to expand it.
src/users/broker.hpp
+
1
−
0
View file @
31469486
...
@@ -66,4 +66,5 @@ private:
...
@@ -66,4 +66,5 @@ private:
/* (Optional) Red and Yellow windows for MultiBehavior DM users */
/* (Optional) Red and Yellow windows for MultiBehavior DM users */
DMWindow_list
*
red_windows_list
=
nullptr
;
DMWindow_list
*
red_windows_list
=
nullptr
;
DMWindow_list
*
yellow_windows_list
=
nullptr
;
DMWindow_list
*
yellow_windows_list
=
nullptr
;
DMWindowAutomata
*
state_automata
=
nullptr
;
};
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/users/user_windows.cpp
+
42
−
22
View file @
31469486
...
@@ -22,15 +22,44 @@ bool DMWindow_list::have_no_common_element( DMWindow_list* compare_list) const
...
@@ -22,15 +22,44 @@ bool DMWindow_list::have_no_common_element( DMWindow_list* compare_list) const
return
intersect
.
is_empty
();
return
intersect
.
is_empty
();
}
}
DMWindowAutomata
::
DMWindowAutomata
(
DMWindow
*
dm_window
,
DMWindow_list
*
red_windows
,
DMWindow_list
*
yellow_windows
)
{
this
->
dm_window
=
dm_window
;
this
->
red_windows
=
red_windows
;
this
->
yellow_windows
=
yellow_windows
;
}
bool
DMWindowAutomata
::
is_in_red_state
(
double
date
){
// Check whether the date is in a red window
return
(
dm_window
&&
dm_window
->
date_in_dm_window
(
date
))
||
(
red_windows
&&
red_windows
->
date_in_dm_window
(
date
));
}
bool
DMWindowAutomata
::
is_in_yellow_state
(
double
date
){
// Check whether the date is in yellow window
return
yellow_windows
&&
yellow_windows
->
date_in_dm_window
(
date
);
}
bool
DMWindowAutomata
::
has_red_state
()
{
return
dm_window
||
red_windows
;
}
bool
DMWindowAutomata
::
has_yellow_state
()
{
return
yellow_windows
;
}
DMWindowAutomata
::~
DMWindowAutomata
()
{
}
StateAutomata
::~
StateAutomata
()
{
}
DMUserMultiBehavior
::
DMUserMultiBehavior
(
DMUserMultiBehavior
::
DMUserMultiBehavior
(
const
std
::
string
&
name
,
const
rapidjson
::
Value
&
param
,
DMWindow
*
window
,
const
std
::
string
&
name
,
const
rapidjson
::
Value
&
param
,
uint_fast32_t
random_seed
,
DMWindow_list
*
y_windows
,
uint_fast32_t
random_seed
,
StateAutomata
*
state_automata
,
LoggerUserStat
*
logger
)
DMWindow_list
*
r_windows
,
LoggerUserStat
*
logger
)
:
DMUserRenonce
(
name
,
param
,
nullptr
),
DMUserReconfig
(
name
,
param
,
nullptr
),
:
DMUserRenonce
(
name
,
param
,
window
),
DMUserReconfig
(
name
,
param
,
window
),
DMUserDegrad
(
name
,
param
,
nullptr
)
DMUserDegrad
(
name
,
param
,
window
)
{
{
yellow_windows
=
y_windows
;
this
->
state_automata
=
state_automata
;
red_windows
=
r_windows
;
this
->
logger
=
logger
;
this
->
logger
=
logger
;
random_gen
=
std
::
mt19937
(
random_seed
);
random_gen
=
std
::
mt19937
(
random_seed
);
red_prob_multi_core
=
vector
<
double
>
(
R_TOTAL_MULTI
,
0.0
);
red_prob_multi_core
=
vector
<
double
>
(
R_TOTAL_MULTI
,
0.0
);
...
@@ -73,7 +102,7 @@ double DMUserMultiBehavior::parse_proba_param(const rapidjson::Value ¶m,
...
@@ -73,7 +102,7 @@ double DMUserMultiBehavior::parse_proba_param(const rapidjson::Value ¶m,
}
}
void
DMUserMultiBehavior
::
init_prob_mono_core
(
const
rapidjson
::
Value
&
param
,
std
::
vector
<
double
>
&
red_prob_array
,
std
::
vector
<
double
>
&
yellow_prob_array
){
void
DMUserMultiBehavior
::
init_prob_mono_core
(
const
rapidjson
::
Value
&
param
,
std
::
vector
<
double
>
&
red_prob_array
,
std
::
vector
<
double
>
&
yellow_prob_array
){
//Red window probability initialization
//Red window probability initialization
if
(
dm_window
||
red_windows
)
if
(
state_automata
->
has_red_state
()
)
{
{
std
::
vector
<
string
>
red_config
(
R_TOTAL_MONO
,
""
);
std
::
vector
<
string
>
red_config
(
R_TOTAL_MONO
,
""
);
red_config
[
R_DEGRAD_MONO
]
=
"red_prob_degrad_mono_core"
;
red_config
[
R_DEGRAD_MONO
]
=
"red_prob_degrad_mono_core"
;
...
@@ -86,7 +115,7 @@ void DMUserMultiBehavior::init_prob_mono_core(const rapidjson::Value ¶m,std:
...
@@ -86,7 +115,7 @@ void DMUserMultiBehavior::init_prob_mono_core(const rapidjson::Value ¶m,std:
}
}
// Yellow probability Initialization
// Yellow probability Initialization
if
(
yellow_windows
)
if
(
state_automata
->
has_yellow_state
()
)
{
{
std
::
vector
<
string
>
yellow_config
(
Y_TOTAL_MONO
,
""
);
std
::
vector
<
string
>
yellow_config
(
Y_TOTAL_MONO
,
""
);
yellow_config
[
Y_DEGRAD_MONO
]
=
"yellow_prob_degrad_mono_core"
;
yellow_config
[
Y_DEGRAD_MONO
]
=
"yellow_prob_degrad_mono_core"
;
...
@@ -99,7 +128,7 @@ void DMUserMultiBehavior::init_prob_mono_core(const rapidjson::Value ¶m,std:
...
@@ -99,7 +128,7 @@ void DMUserMultiBehavior::init_prob_mono_core(const rapidjson::Value ¶m,std:
void
DMUserMultiBehavior
::
init_prob_multi_core
(
const
rapidjson
::
Value
&
param
,
std
::
vector
<
double
>
&
red_prob_array
,
std
::
vector
<
double
>
&
yellow_prob_array
){
void
DMUserMultiBehavior
::
init_prob_multi_core
(
const
rapidjson
::
Value
&
param
,
std
::
vector
<
double
>
&
red_prob_array
,
std
::
vector
<
double
>
&
yellow_prob_array
){
//Red window probability initialization
//Red window probability initialization
if
(
dm_window
||
red_windows
)
if
(
state_automata
->
has_red_state
()
)
{
{
std
::
vector
<
string
>
red_config
(
R_TOTAL_MULTI
,
""
);
std
::
vector
<
string
>
red_config
(
R_TOTAL_MULTI
,
""
);
red_config
[
R_DEGRAD_MULTI
]
=
"red_prob_degrad_multi_core"
;
red_config
[
R_DEGRAD_MULTI
]
=
"red_prob_degrad_multi_core"
;
...
@@ -114,7 +143,7 @@ void DMUserMultiBehavior::init_prob_multi_core(const rapidjson::Value ¶m,std
...
@@ -114,7 +143,7 @@ void DMUserMultiBehavior::init_prob_multi_core(const rapidjson::Value ¶m,std
}
}
// Yellow probability Initialization
// Yellow probability Initialization
if
(
yellow_windows
)
if
(
state_automata
->
has_yellow_state
()
)
{
{
std
::
vector
<
string
>
yellow_config
(
Y_TOTAL_MULTI
,
""
);
std
::
vector
<
string
>
yellow_config
(
Y_TOTAL_MULTI
,
""
);
yellow_config
[
Y_DEGRAD_MULTI
]
=
"yellow_prob_degrad_multi_core"
;
yellow_config
[
Y_DEGRAD_MULTI
]
=
"yellow_prob_degrad_multi_core"
;
...
@@ -337,23 +366,15 @@ void DMUserMultiBehavior::log_behavior(shared_ptr<Job> & job,std::string behavio
...
@@ -337,23 +366,15 @@ void DMUserMultiBehavior::log_behavior(shared_ptr<Job> & job,std::string behavio
}
}
}
}
bool
DMUserMultiBehavior
::
is_in_red_window
(
double
date
){
// Check whether the date is in a red_window
return
(
dm_window
&&
dm_window
->
date_in_dm_window
(
date
))
||
(
red_windows
&&
red_windows
->
date_in_dm_window
(
date
));
}
bool
DMUserMultiBehavior
::
is_in_yellow_window
(
double
date
){
// Check whether the date is in yellow_window
return
yellow_windows
&&
yellow_windows
->
date_in_dm_window
(
date
);
}
bool
DMUserMultiBehavior
::
handle_job
(
double
date
,
shared_ptr
<
Job
>
job
,
Profile
*
profile
)
bool
DMUserMultiBehavior
::
handle_job
(
double
date
,
shared_ptr
<
Job
>
job
,
Profile
*
profile
)
{
{
//red_windows and dm_windows check
//red_windows and dm_windows check
if
(
is_in_red_
window
(
date
))
{
if
(
state_automata
->
is_in_red_
state
(
date
))
{
return
red_window_behavior
(
date
,
job
,
profile
);
return
red_window_behavior
(
date
,
job
,
profile
);
}
}
// yellow_windows check
// yellow_windows check
if
(
is_in_yellow_
window
(
date
)){
if
(
state_automata
->
is_in_yellow_
state
(
date
)){
/*
/*
* We decide at random the behavior (rigid,degrad, reconfig)
* We decide at random the behavior (rigid,degrad, reconfig)
* that will be done on this job
* that will be done on this job
...
@@ -365,4 +386,3 @@ bool DMUserMultiBehavior::handle_job(double date, shared_ptr<Job> job, Profile *
...
@@ -365,4 +386,3 @@ bool DMUserMultiBehavior::handle_job(double date, shared_ptr<Job> job, Profile *
return
rigid_job
(
job
,
profile
,
1.0
);
return
rigid_job
(
job
,
profile
,
1.0
);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/users/user_windows.hpp
+
26
−
8
View file @
31469486
...
@@ -25,6 +25,29 @@ struct DMWindow_list
...
@@ -25,6 +25,29 @@ struct DMWindow_list
};
};
class
StateAutomata
{
public:
virtual
bool
is_in_red_state
(
double
date
)
=
0
;
virtual
bool
is_in_yellow_state
(
double
date
)
=
0
;
virtual
bool
has_red_state
()
=
0
;
virtual
bool
has_yellow_state
()
=
0
;
virtual
~
StateAutomata
();
};
class
DMWindowAutomata
:
public
StateAutomata
{
public:
DMWindowAutomata
(
DMWindow
*
dm_window
,
DMWindow_list
*
red_windows
,
DMWindow_list
*
yellow_windows
);
bool
is_in_yellow_state
(
double
date
);
bool
is_in_red_state
(
double
date
);
bool
has_yellow_state
();
bool
has_red_state
();
~
DMWindowAutomata
();
private:
DMWindow
*
dm_window
;
DMWindow_list
*
red_windows
;
DMWindow_list
*
yellow_windows
;
};
/**
/**
* @brief User class that adopts a different set of submission behaviors depending
* @brief User class that adopts a different set of submission behaviors depending
* on the energy state (red, yellow, green)
* on the energy state (red, yellow, green)
...
@@ -40,9 +63,8 @@ class DMUserMultiBehavior : public DMUserRenonce,public DMUserReconfig,
...
@@ -40,9 +63,8 @@ class DMUserMultiBehavior : public DMUserRenonce,public DMUserReconfig,
{
{
public:
public:
DMUserMultiBehavior
(
DMUserMultiBehavior
(
const
std
::
string
&
name
,
const
rapidjson
::
Value
&
param
,
DMWindow
*
window
,
const
std
::
string
&
name
,
const
rapidjson
::
Value
&
param
,
uint_fast32_t
random_seed
,
DMWindow_list
*
yellow_windows
,
uint_fast32_t
random_seed
,
StateAutomata
*
state_automata
,
LoggerUserStat
*
logger
);
DMWindow_list
*
red_windows
,
LoggerUserStat
*
logger
);
~
DMUserMultiBehavior
();
~
DMUserMultiBehavior
();
double
next_submission
();
double
next_submission
();
void
jobs_to_submit
(
void
jobs_to_submit
(
...
@@ -56,8 +78,7 @@ protected:
...
@@ -56,8 +78,7 @@ protected:
R_RIGID_MONO
,
R_TOTAL_MONO
};
R_RIGID_MONO
,
R_TOTAL_MONO
};
enum
yellow_behavior_multi
{
Y_DEGRAD_MULTI
,
Y_RECONFIG_MULTI
,
Y_RIGID_MULTI
,
Y_TOTAL_MULTI
};
enum
yellow_behavior_multi
{
Y_DEGRAD_MULTI
,
Y_RECONFIG_MULTI
,
Y_RIGID_MULTI
,
Y_TOTAL_MULTI
};
enum
yellow_behavior_mono
{
Y_DEGRAD_MONO
,
Y_RIGID_MONO
,
Y_TOTAL_MONO
};
enum
yellow_behavior_mono
{
Y_DEGRAD_MONO
,
Y_RIGID_MONO
,
Y_TOTAL_MONO
};
DMWindow_list
*
yellow_windows
;
StateAutomata
*
state_automata
;
DMWindow_list
*
red_windows
;
std
::
mt19937
random_gen
;
std
::
mt19937
random_gen
;
std
::
uniform_real_distribution
<
double
>
distribution
std
::
uniform_real_distribution
<
double
>
distribution
=
std
::
uniform_real_distribution
<
double
>
(
0.0
,
1.0
);
=
std
::
uniform_real_distribution
<
double
>
(
0.0
,
1.0
);
...
@@ -71,9 +92,6 @@ protected:
...
@@ -71,9 +92,6 @@ protected:
void
init_prob_multi_core
(
const
rapidjson
::
Value
&
param
,
void
init_prob_multi_core
(
const
rapidjson
::
Value
&
param
,
vector
<
double
>
&
red_prob_array
,
vector
<
double
>
&
yellow_prob_array
);
vector
<
double
>
&
red_prob_array
,
vector
<
double
>
&
yellow_prob_array
);
void
check_deprecated_param
(
const
rapidjson
::
Value
&
param
);
void
check_deprecated_param
(
const
rapidjson
::
Value
&
param
);
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
,
void
log_behavior
(
shared_ptr
<
Job
>
&
job
,
std
::
string
behavior_name
,
long
delay_time
,
double
random_value
);
long
delay_time
,
double
random_value
);
bool
rigid_job
(
shared_ptr
<
Job
>
job
,
Profile
*
profile
,
double
random_number
);
bool
rigid_job
(
shared_ptr
<
Job
>
job
,
Profile
*
profile
,
double
random_number
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment