Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Demand Response User
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
Open Science
Demand Response User
Commits
907ef753
Commit
907ef753
authored
3 years ago
by
Maël Madon
Browse files
Options
Downloads
Patches
Plain Diff
added experiments with a constant alpha in the 3rd campaign
parent
9fd8eadb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
campaign3.py
+19
-4
19 additions, 4 deletions
campaign3.py
instance3.py
+40
-21
40 additions, 21 deletions
instance3.py
with
59 additions
and
25 deletions
campaign3.py
+
19
−
4
View file @
907ef753
...
@@ -11,7 +11,7 @@ from dateutil import parser
...
@@ -11,7 +11,7 @@ from dateutil import parser
import
concurrent.futures
import
concurrent.futures
from
scripts.util
import
WL_DIR
from
scripts.util
import
WL_DIR
from
instance3
import
start_instance
from
instance3
import
expe_alpha_cst
,
expe_alpha_normal
###############################
###############################
# Prepare the start date sample
# Prepare the start date sample
...
@@ -44,12 +44,27 @@ with open(f"{WL_DIR}/start_days_for_campaign2.txt", 'w') as f:
...
@@ -44,12 +44,27 @@ with open(f"{WL_DIR}/start_days_for_campaign2.txt", 'w') as f:
nb_expe
=
10
nb_expe
=
10
with
concurrent
.
futures
.
ProcessPoolExecutor
()
as
executor
:
with
concurrent
.
futures
.
ProcessPoolExecutor
()
as
executor
:
# print("##############\n"
# "First batch of expe: with alpha drawn at random for each user\n"
# "##############")
# instances = []
# for i in range(nb_expe):
# print(f"Submit expe {i}")
# # expe_alpha_normal(expe_num, start_date, prepare_workload, clean_log)
# instances.append(executor.submit(
# expe_alpha_normal, i, expe_start_time[i], False, True))
# for instance in concurrent.futures.as_completed(instances):
# print(f"Expe {instance.result()} terminated")
print
(
"
##############
\n
"
"
Second batch of expe: with alpha=0.5, 0.75, 0.88
\n
"
"
##############
"
)
instances
=
[]
instances
=
[]
for
i
in
range
(
nb_expe
):
for
i
in
range
(
nb_expe
):
print
(
f
"
Submit expe
{
i
}
"
)
print
(
f
"
Submit expe
{
i
}
"
)
#
start_instance
(expe_num, start_date, prepare_workload, clean_log)
#
expe_alpha_cst
(expe_num, start_date, prepare_workload, clean_log)
instances
.
append
(
executor
.
submit
(
instances
.
append
(
executor
.
submit
(
start_instance
,
i
,
expe_start_time
[
i
],
True
,
True
))
expe_alpha_cst
,
i
,
expe_start_time
[
i
],
False
,
True
))
for
instance
in
concurrent
.
futures
.
as_completed
(
instances
):
for
instance
in
concurrent
.
futures
.
as_completed
(
instances
):
print
(
f
"
Expe
{
instance
.
result
()
}
terminated
"
)
print
(
f
"
Expe
{
instance
.
result
()
}
terminated
"
)
This diff is collapsed.
Click to expand it.
instance3.py
+
40
−
21
View file @
907ef753
...
@@ -30,13 +30,30 @@ def prepare_input_data(expe_num, start_date):
...
@@ -30,13 +30,30 @@ def prepare_input_data(expe_num, start_date):
job_walltime_factor
=
8
)
job_walltime_factor
=
8
)
def
run_expe
(
expe_num
,
seed_alpha
,
clean_log
):
def
run_expe
(
expe_num
,
alpha_cst
=
None
,
seed_alpha
=
None
,
clean_log
=
True
):
"""
Run batmen with reconfig behavior and a 4-hour DR window.
"""
Run batmen with reconfig behavior and a 4-hour DR window.
Expe_num should be a small integer (eg < 100)
Mode alpha constant (alpha_cst != None)
------------
Same alpha for all jobs (preferrably between 0.5 and 1)
Mode alpha randomly generated (seed_alpha != None)
------------
For each user, alpha is drawn at random following a Gaussian distribution
For each user, alpha is drawn at random following a Gaussian distribution
such that 0.5<alpha<1 in 95% of the cases (mean = 0.75, sigma = 0.125)
such that 0.5<alpha<1 in 95% of the cases (mean = 0.75, sigma = 0.125)
Expe_num should be a small integer (eg < 100)
"""
"""
assert
(
alpha_cst
==
None
)
!=
(
seed_alpha
==
None
),
"
Either alpha_cst or
\
seed_alpha should be non-None, and not both at the same time
"
# Useful vars and output folder
# Useful vars and output folder
EXPE_DIR
=
f
"
{
ROOT_DIR
}
/out/campaign3/expe
{
expe_num
}
/seed_alpha_
{
seed_alpha
}
"
if
seed_alpha
!=
None
:
# Initialize the random generator
random
.
seed
(
seed_alpha
)
EXPE_DIR
=
f
"
{
ROOT_DIR
}
/out/campaign3/expe
{
expe_num
}
/seed_alpha_
{
seed_alpha
}
"
else
:
EXPE_DIR
=
f
"
{
ROOT_DIR
}
/out/campaign3/expe
{
expe_num
}
/alpha_cst_
{
int
(
alpha_cst
*
100
)
:
03
d
}
"
create_dir_rec_if_needed
(
EXPE_DIR
)
create_dir_rec_if_needed
(
EXPE_DIR
)
create_dir_rec_if_needed
(
f
"
{
EXPE_DIR
}
/cmd
"
)
create_dir_rec_if_needed
(
f
"
{
EXPE_DIR
}
/cmd
"
)
EXPE_FILE
=
f
"
{
EXPE_DIR
}
/cmd/robinfile.yaml
"
EXPE_FILE
=
f
"
{
EXPE_DIR
}
/cmd/robinfile.yaml
"
...
@@ -44,22 +61,23 @@ def run_expe(expe_num, seed_alpha, clean_log):
...
@@ -44,22 +61,23 @@ def run_expe(expe_num, seed_alpha, clean_log):
pf
=
f
"
{
ROOT_DIR
}
/platform/average_metacentrum.xml
"
pf
=
f
"
{
ROOT_DIR
}
/platform/average_metacentrum.xml
"
wl
=
f
"
{
WL_DIR
}
/empty_workload.json
"
wl
=
f
"
{
WL_DIR
}
/empty_workload.json
"
uf
=
f
"
{
EXPE_DIR
}
/cmd/user_description_file.json
"
uf
=
f
"
{
EXPE_DIR
}
/cmd/user_description_file.json
"
window_size
=
4
# Initialize the random generator
random
.
seed
(
seed_alpha
)
# Demand response window, from 16 to (16 + window_size) on day2
# Demand response window, from 16 to (16 + window_size) on day2
window_size
=
4
dm_window
=
[(
24
+
16
)
*
3600
,
(
int
)
((
24
+
16
+
window_size
)
*
3600
)]
dm_window
=
[(
24
+
16
)
*
3600
,
(
int
)
((
24
+
16
+
window_size
)
*
3600
)]
# User description file
# User description file
def
user_description
(
user
):
def
user_description
(
user
):
if
seed_alpha
!=
None
:
alpha
=
random
.
normalvariate
(
0.75
,
0.125
)
else
:
alpha
=
alpha_cst
return
{
return
{
"
name
"
:
user
,
"
name
"
:
user
,
"
category
"
:
"
dm_user_reconfig
"
,
"
category
"
:
"
dm_user_reconfig
"
,
"
param
"
:
{
"
param
"
:
{
"
input_json
"
:
f
"
{
wl_folder
}
/
{
user
}
.json
"
,
"
input_json
"
:
f
"
{
wl_folder
}
/
{
user
}
.json
"
,
"
alpha_speedup
"
:
random
.
normalvariate
(
0.75
,
0.125
)
"
alpha_speedup
"
:
alpha
}
}
}
}
user_names
=
[
user_file
.
split
(
'
.
'
)[
0
]
for
user_file
in
os
.
listdir
(
wl_folder
)]
user_names
=
[
user_file
.
split
(
'
.
'
)[
0
]
for
user_file
in
os
.
listdir
(
wl_folder
)]
...
@@ -96,7 +114,7 @@ def run_expe(expe_num, seed_alpha, clean_log):
...
@@ -96,7 +114,7 @@ def run_expe(expe_num, seed_alpha, clean_log):
def
start_instance
(
expe_num
,
start_date
,
prepare_workload
=
True
,
clean_log
=
False
):
def
expe_alpha_normal
(
expe_num
,
start_date
,
prepare_workload
=
True
,
clean_log
=
False
):
# Prepare workload
# Prepare workload
if
prepare_workload
:
if
prepare_workload
:
prepare_input_data
(
expe_num
,
start_date
)
prepare_input_data
(
expe_num
,
start_date
)
...
@@ -112,17 +130,18 @@ def start_instance(expe_num, start_date, prepare_workload=True, clean_log=False)
...
@@ -112,17 +130,18 @@ def start_instance(expe_num, start_date, prepare_workload=True, clean_log=False)
return
expe_num
return
expe_num
# def main():
def
expe_alpha_cst
(
expe_num
,
start_date
,
prepare_workload
=
True
,
clean_log
=
False
):
# parser = argparse.ArgumentParser(
# Prepare workload
# description='One expe instance. To launch for example with `oarsub -l walltime=2 "./instance3 arg1 arg2 arg3"`')
if
prepare_workload
:
# parser.add_argument('expe_num', type=int, help='The expe ID')
prepare_input_data
(
expe_num
,
start_date
)
# parser.add_argument('start_date', type=int,
# help='Start of the 3-day window (in seconds since the start of the original trace)')
# args = parser.parse_args()
# start_instance(args.expe_num, args.start_date)
# Create expe folder
create_dir_rec_if_needed
(
f
"
{
ROOT_DIR
}
/out/campaign3
"
)
create_dir_rec_if_needed
(
f
"
{
ROOT_DIR
}
/out/campaign3/expe
{
expe_num
}
"
)
# Run with various random seeds
alpha_csts
=
[.
5
,
.
75
,
.
88
]
for
alpha
in
alpha_csts
:
run_expe
(
expe_num
=
expe_num
,
alpha_cst
=
alpha
,
clean_log
=
clean_log
)
# if __name__ == "__main__":
return
expe_num
# main()
\ No newline at end of file
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