Нужна помощь в правильном смещении задачи в производственном графике нескольких машин и нескольких рабочих мест.Python

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Нужна помощь в правильном смещении задачи в производственном графике нескольких машин и нескольких рабочих мест.

Сообщение Anonymous »

Я разрабатываю гибкий алгоритм планирования цеха с нечетким временем обработки, в котором я пытаюсь дефаззифицировать время производства с течением времени.
Это один из четких графиков, которые я создал. Однако я обнаружил, что по мере того, как я дефаззизирую производственные графики, у меня возникает перекрытие работ, то есть операция начинается раньше, чем предыдущая операция. Тем не менее, я позаботился о том, чтобы машинные зависимости были хорошо отсортированы. Код для просмотра этой проблемы следующий:

Код: Выделить всё

import copy
import numpy as np

# Machine dictionary with [job, machine, start, end, 0, 2] format
machine_dict = {1: [[1, 3, [120.46, 153.93, 174.0], [140.22, 179.17, 202.54], 0, 2], [2, 2, [348.02, 444.69, 502.69], [409.87, 523.72, 592.03], 0, 2]], 2: [[4, 3, [140.66, 179.74, 203.18], [159.86, 204.28, 230.92], 0, 2], [2, 4, [418.38, 534.6, 604.33], [474.35, 606.11, 685.17], 0, 2]], 3: [[2, 1, [0, 0, 0], [348.02, 444.69, 502.69], 0, 2]], 4: [[3, 2, [17.362573615775315, 17.362573615775315, 17.362573615775315], [52.10257361577531, 61.75257361577532, 67.54257361577531], 0, 2], [3, 3, [312.64, 399.47, 451.58], [579.64, 740.6300000000001, 837.24], 0, 2]], 5: [[4, 1, [0, 0, 0], [89.23, 114.02, 128.89], 0, 2]], 6: [[5, 1, [0, 0, 0], [84.93, 108.53, 122.68], 0, 2], [5, 2, [134.72, 172.15, 194.6], [184.51, 235.77, 266.52], 0, 2]], 7: [[1, 1, [0, 0, 0], [49.65, 63.45, 71.72], 0, 2], [1, 2, [120.46, 153.93, 174.0], [191.26999999999998, 244.41000000000003, 276.28], 0, 2]], 8: [[4, 5, [183.09, 233.97, 264.48], [216.45, 276.59, 312.66], 0, 2]], 10: [[4, 4, [159.86, 204.28, 230.92], [183.09, 233.97, 264.48], 0, 2]], 11: [[3, 1, [0, 0, 0], [11.0, 11.0, 11.0], 0, 2], [4, 2, [192.08999999999997, 245.46000000000004, 277.47], [243.51999999999995, 311.18000000000006, 351.76000000000005], 0, 2], [2, 3, [426.89, 545.48, 616.6300000000001], [435.4, 556.36, 628.9300000000002], 0, 2]]}

# Function to print job-wise operation details with machine, start and end times
def print_job_operations(machine_dict):
job_operations = {}

# Organize operations by job
for machine, operations in machine_dict.items():
for op in operations:
job_id, op_id, start_times, end_times, *_ = op
if job_id not in job_operations:
job_operations[job_id] = []
job_operations[job_id].append((op_id, machine, start_times, end_times))  # Store operation ID, machine, start/end times

# Now print the job-wise operations with machine, start and end times
for job_id, ops in job_operations.items():
print(f"Job {job_id}:")
for op in sorted(ops, key=lambda x: x[0]):  # Sort by operation number
print(f"   Operation {op[0]} - Machine: {op[1]}, Start Time: {op[2]}, End Time: {op[3]}")

# Function to get end time of last operation of each job
def get_last_operation_end_times(machine_dict):
job_operations = {}

# Organize operations by job
for machine, operations in machine_dict.items():
for op in operations:
job_id, op_id, start_times, end_times, *_ = op
if job_id not in job_operations:
job_operations[job_id] = []
job_operations[job_id].append((op_id, end_times))  # Store operation ID and end times

# Get the end time of the last operation for each job
last_operation_end_times = {}
for job_id, ops in job_operations.items():
last_op = max(ops, key=lambda x: x[0])  # Get the operation with the highest operation number
last_operation_end_times[job_id] = last_op[1]  # Store the end times of the last operation

return last_operation_end_times

# Printing the adjusted machine-wise and job-wise schedule
print_job_operations(machine_dict)

# Getting the end time of the last operation of each job
last_op_end_times = get_last_operation_end_times(machine_dict)
last_op_end_times
Мой код для решения этой проблемы выглядит следующим образом:

Код: Выделить всё

for machine, ops in machine_dict.items():
#Sort operations by start time (Use middle TFN value for sorting)
ops = sorted(ops, key=lambda x: x[2][1])
for op in ops:
job, opn, start, end, _, _ = op
if (opn>1):
job_prev_end=job_operations[job,opn-1][3]
else:
job_prev_end=[0,0,0]
machine_prev_end= machine_end_times[machine]
print(machine)
print("op-start",start,"op-end",end,"machine_prev_end",machine_prev_end,"job_prev_end",job_prev_end)
# Calculate the adjusted start time based on the latest end time
adjusted_start = [max(start[i], machine_prev_end[i], job_prev_end[i]) for i in range(3)]
duration = [end[i] - start[i] for i in range(3)]
adjusted_end = [adjusted_start[i] + duration[i] for i in range(3)]
# Store the adjusted operation in the final schedule
print([job, opn, adjusted_start, adjusted_end, 0, 2])
# Update end times for job and machine
job_end_times[job] = adjusted_end
machine_end_times[machine] = adjusted_end
if(job==4):
input()
adjusted_schedule[machine].append([job, opn, adjusted_start, adjusted_end, 0, 2])

Однако я считаю, что этот код не решает проблему, поскольку он принимает пары задание-операция в том порядке, в котором они запланированы на машинах (начиная с машины 1), то есть, если операция 4 задания 4 запланировано на машине 3, а операция 4–3 запланировано на машине 10, и если операция 4 задания 4 начинается до операции 4–3, это перекрытие не устраняется.
Как Могу ли я изменить смену работ/операций, чтобы избежать дублирования в производственном графике?

Подробнее здесь: https://stackoverflow.com/questions/790 ... machines-a
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»