Professional Documents
Culture Documents
Moiz Alam Said
Moiz Alam Said
Total Marks: 04
Obtained Marks:
Assignment # 02
Last date of Submission: 29 October 2023
Section: BSAI-4A
import itertools
# Define the time required for each job for each crane in a 4x4
matrix time_matrix = [
[4, 2, 5, 7],
[12, 5, 4, 5],
[6, 3, 7, 14]
def calculate_total_time(assignment):
total_time = 0
for i in range(len(assignment)):
total_time +=
time_matrix[i][assignment[i]] return
total_time
itertools.permutations crane_permutations =
itertools.permutations(range(4))
best_assignment = None
min_total_time = float('inf')
# Iterate through all permutations and find the one with the
total_time = calculate_total_time(assignment)
min_total_time = total_time
best_assignment = assignment
min_total_time)
Output: