Verified Commit 0de226e3 authored by Löscher Mario's avatar Löscher Mario
Browse files

got some better assignment

parent 0f98664a
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment