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
0f98664a
Verified
Commit
0f98664a
authored
Dec 10, 2018
by
Löscher Mario
Browse files
got some assignment
parent
81148dba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
4 deletions
+45
-4
scheduler/preprocessing.py
scheduler/preprocessing.py
+45
-4
No files found.
scheduler/preprocessing.py
View file @
0f98664a
...
...
@@ -70,6 +70,21 @@ def calculate_batch_duration(processes: List[int], durations):
return
batch
def
assign_tasks
(
solution_hours
,
solution
,
durations
,
machine_count
):
total_duration
=
solution_hours
*
machine_count
machine
=
1
index
=
1
machine_duration
=
0
for
process
in
durations
:
print
(
"Assigned batch "
+
str
(
index
)
+
" to machine "
+
str
(
machine
))
machine_duration
+=
process
[
solution
]
if
(
machine_duration
>=
solution_hours
):
machine_duration
=
0
machine
+=
1
index
+=
1
return
def
best_performance_under_limit
(
max_width
:
int
,
prices
:
List
[
float
],
...
...
@@ -130,10 +145,10 @@ def best_performance_under_limit(
solutions_hours
.
append
(
runtime
)
solutions_machine
.
append
(
machines
[
0
])
machineHours
=
math
.
ceil
(
runtime
/
3600
)
#
print(str(runtime) + " seconds")
#
print(machines)
#
print("Machine hours: " + str(machineHours))
#
print("Costs: " + str(machineHours * prices[machines[0]]))
print
(
str
(
runtime
)
+
" seconds"
)
print
(
machines
)
print
(
"Machine hours: "
+
str
(
machineHours
))
print
(
"Costs: "
+
str
(
machineHours
*
prices
[
machines
[
0
]]))
#test if we can reduce costs or runtime (without network traffic
index
=
0
...
...
@@ -146,6 +161,8 @@ def best_performance_under_limit(
max_price_position
=
index
index
+=
1
max_price
=
6
#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
]])
...
...
@@ -161,6 +178,7 @@ def best_performance_under_limit(
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
solutions_hours
[
index
]
/=
factor
current_solution
=
[
0
for
machine
in
prices
]
max_price_position
=
index
current_solution
[
solutions_machine
[
index
]]
=
factor
*
math
.
ceil
(
solutions_hours
[
index
]
/
3600
)
...
...
@@ -168,4 +186,27 @@ def best_performance_under_limit(
print
(
"final duration[s]: "
+
str
(
solutions_hours
[
max_price_position
]))
# 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
))
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