Commit 0f98664a by Löscher Mario

### got some assignment

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