Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
User expired
2018s-advanced-distributed-systems
Commits
0de226e3
Verified
Commit
0de226e3
authored
Dec 10, 2018
by
Löscher Mario
Browse files
got some better assignment
parent
0f98664a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
36 deletions
+34
-36
scheduler/preprocessing.py
scheduler/preprocessing.py
+34
-36
No files found.
scheduler/preprocessing.py
View file @
0de226e3
...
...
@@ -85,6 +85,35 @@ def assign_tasks(solution_hours, solution, durations, machine_count):
return
def
getMinRuntime
(
processes
,
machine
):
min_time
=
9999999999
for
process
in
processes
:
if
min_time
>
process
[
machine
]:
min_time
=
process
[
machine
]
return
min_time
def
get_batch_durations
(
durations
):
batch_durations
=
[]
batch_durations
.
append
(
calculate_batch_duration
([
0
,
7
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
1
,
8
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
2
,
9
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
3
,
10
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
4
,
11
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
5
,
12
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
6
,
13
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
14
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
15
,
22
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
16
,
23
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
17
,
24
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
18
,
25
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
19
,
26
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
20
,
27
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
21
,
28
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
29
],
durations
))
return
batch_durations
def
best_performance_under_limit
(
max_width
:
int
,
prices
:
List
[
float
],
...
...
@@ -108,23 +137,7 @@ def best_performance_under_limit(
#
if
strategy
==
"Cheapest"
:
# information extrapolated by drawing a dot graph, keep strongly tied functions together
batch_durations
=
[]
batch_durations
.
append
(
calculate_batch_duration
([
0
,
7
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
1
,
8
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
2
,
9
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
3
,
10
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
4
,
11
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
5
,
12
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
6
,
13
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
14
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
15
,
22
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
16
,
23
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
17
,
24
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
18
,
25
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
19
,
26
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
20
,
27
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
21
,
28
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
29
],
durations
))
batch_durations
=
get_batch_durations
(
durations
)
batch_costs
=
cost_per_process_and_machine
(
batch_durations
,
prices
)
...
...
@@ -166,6 +179,7 @@ def best_performance_under_limit(
#write solution
current_price
=
max_price
current_solution
[
solutions_machine
[
max_price_position
]]
=
math
.
ceil
(
solutions_hours
[
max_price_position
]
/
3600
*
prices
[
solutions_machine
[
max_price_position
]])
batch_durations
=
get_batch_durations
(
durations
)
index
=
0
for
solution
in
solutions_hours
:
...
...
@@ -175,6 +189,8 @@ def best_performance_under_limit(
local_price
=
math
.
ceil
(
solution
/
3600
)
*
prices
[
solutions_machine
[
index
]]
factor
=
math
.
floor
(
max_price
/
local_price
)
new_runtime
=
solution
/
factor
if
new_runtime
>
getMinRuntime
(
batch_durations
,
index
):
new_runtime
=
getMinRuntime
(
batch_durations
,
index
)
new_price
=
math
.
ceil
(
solution
/
3600
/
factor
)
*
prices
[
solutions_machine
[
index
]]
*
factor
if
(
new_runtime
<
solutions_hours
[
max_price_position
]
*
0.9
):
# 0.9 to simulate the traffic time needed to transfer
current_price
=
new_price
...
...
@@ -188,25 +204,7 @@ def best_performance_under_limit(
# The calculation only uses homogeneous VM distribution currently
# Greedy
batch_durations
=
[]
batch_durations
.
append
(
calculate_batch_duration
([
0
,
7
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
1
,
8
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
2
,
9
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
3
,
10
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
4
,
11
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
5
,
12
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
6
,
13
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
14
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
15
,
22
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
16
,
23
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
17
,
24
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
18
,
25
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
19
,
26
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
20
,
27
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
21
,
28
],
durations
))
batch_durations
.
append
(
calculate_batch_duration
([
29
],
durations
))
batch_durations
=
get_batch_durations
(
durations
)
assign_tasks
(
solutions_hours
[
max_price_position
],
solutions_machine
[
max_price_position
],
batch_durations
,
current_solution
[
solutions_machine
[
max_price_position
]])
return
current_price
,
current_solution
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment