function [makespan, start_time,processing_time] = schedule(job_seq, job_num, machine_num) processing_time = rand(job_num, machine_num); % 生成随机处理时间 start_time = zeros(job_num, machine_num); % 记录每道工序的开始时间 end_time = zeros(job_num, machine_num); % 记录每道工序的结束时间 for j = 1:machine_num if j == 1 start_time(1, j) = 0; else start_time(1, j) = end_time(1, j-1); end end_time(1, j) = start_time(1, j) + processing_time(job_seq(1), j); end for i = 2:job_num for j = 1:machine_num if j == 1 start_time(i, j) = end_time(i-1, j); else start_time(i, j) = max(end_time(i, j-1), end_time(i-1, j)); end end_time(i, j) = start_time(i, j) + processing_time(job_seq(i), j); end end makespan = max(end_time(:, end)); end改写为流水车间调度
时间: 2023-12-07 15:02:14 浏览: 78
function [makespan, start_time,processing_time] = schedule(job_seq, job_num, machine_num)
processing_time = rand(job_num, machine_num); % 生成随机处理时间
start_time = zeros(job_num, machine_num); % 记录每道工序的开始时间
end_time = zeros(job_num, machine_num); % 记录每道工序的结束时间
for j = 1:machine_num
if j == 1
start_time(1, j) = 0;
else
start_time(1, j) = end_time(1, j-1);
end
end_time(1, j) = start_time(1, j) + processing_time(job_seq(1), j);
end
for j = 2:machine_num
for i = 1:job_num
if i == 1
start_time(i, j) = end_time(i, j-1);
else
start_time(i, j) = max(end_time(i, j-1), end_time(i-1, j));
end
end_time(i, j) = start_time(i, j) + processing_time(job_seq(i), j);
end
end
makespan = max(end_time(:, end));
end
阅读全文