Flexible-Job-Shop-Scheduling-Problem解读
admin
2024-03-13 07:27:44
0

本次解读的代码来自:

https://github.com/samy-barrech/Flexible-Job-Shop-Scheduling-Problem/tree/master/app

关于生产排程的问题。

点评

  • 方法相对全面
  • 没有体现出工艺路线,按照线性做下去

数据

6   6   1   
6   1   3   1   1   1   3   1   2   6   1   4   7   1   6   3   1   5   6   
6   1   2   8   1   3   5   1   5   10  1   6   10  1   1   10  1   4   4   
6   1   3   5   1   4   4   1   6   8   1   1   9   1   2   1   1   5   7   
6   1   2   5   1   1   5   1   3   5   1   4   3   1   5   8   1   6   9   
6   1   3   9   1   2   3   1   5   5   1   6   4   1   1   3   1   4   1   
6   1   2   3   1   4   3   1   6   9   1   1   10  1   5   4   1   3   1   

第一行:代表6个job,6个机器,每个工序平均需要1台机器
之后的6行代表其中的6job,第二行是第一个job,需要6个工序来完成,第一个工序可以1台机器完成,机器3,需要1个单位时间。

OOD

  • job
    • 待完成activity
    • 已完成activity
  • activity
    • 属于的job
    • 待完成operation
    • 已完成operation
  • operation
    • operation用那个机器
    • 花的时间
  • machine
    • operation
    • 增加operation, 最大operation
    • 处理的operation

规则

1 parse => jobs_list, machines_list

2 heuristic = Heuristic().select

3 Scheduler(machine_list, jobs_list)

4 Scheduler.run(heuristic)

def run(self, heuristic, verbose=True):# Disable print if verbose is Falseif not verbose:sys.stdout = Nonecurrent_step = 0while len(self.__jobs_to_be_done) > 0:  # 只要有未完成工作current_step += 1best_candidates = heuristic(self.__jobs_to_be_done, self.__max_operations, current_step)  # 不同规则返回最佳candidatefor id_machine, candidates in best_candidates.items():  # 最佳候选里,是关于多个机器,其能承受最大工序的machine = self.__machines[id_machine - 1]  # id转化为对象for activity, operation in candidates:if not (machine.is_working_at_max_capacity() or activity.is_pending):  # 符合条件的分配给机器machine.add_operation(activity, operation)for machine in self.__machines:  # 机器时间开始流动machine.work()for job in self.__jobs_to_be_done:  # 检查更新job是否完整状态if job.is_done:self.__jobs_to_be_done = list(filter(lambda element: element.id_job != job.id_job, self.__jobs_to_be_done))self.__jobs_done.append(job)print(colored("[SCHEDULER]", "green"), "Done in " + str(current_step) + " units of time")# Reenable stdoutif not verbose:sys.stdout = self.__original_stdoutreturn current_step
class Heuristics:# When a choice between multiple operations is available, always pick the first one@staticmethoddef select_first_operation(jobs_to_be_done, max_operations, _):best_candidates = {}for job in jobs_to_be_done:  # 从待完成的job里找到best_candidatecurrent_activity = job.current_activity  # 向下选择activity/ operation,由于activity要按顺序完成,选择每个job当前best_operation = current_activity.shortest_operation  # 当前里最短的工序if best_candidates.get(best_operation.id_machine) is None:  # 如果最佳候选里暂时没有这台机器的安排best_candidates.update({best_operation.id_machine: [(current_activity, best_operation)]})elif len(best_candidates.get(best_operation.id_machine)) < max_operations:  # 如果最佳候选还能继续安排工作,加上去best_candidates.get(best_operation.id_machine).append((current_activity, best_operation))else:  # 机器已经满载了,那么就从里面选list_operations = best_candidates.get(best_operation.id_machine)  for key, (_, operation) in enumerate(list_operations):if operation.duration < best_operation.duration:  # 原本候选集里比最新这个时间更短的,pop一个出去list_operations.pop(key)breakif len(list_operations) < max_operations:  # 如果有pop,就把最新的加上去。否则其实还是原本的候选list_operations.append((current_activity, best_operation))return best_candidates

时间流动

亲测

相关内容

热门资讯

三度闯关终成功 龙辰科技成功过... 上证报中国证券网讯(记者 张雪)2月27日,龙辰科技上市申请获得北交所上市委审核通过。此次为公司第三...
我国自3月1日起对原产于加拿大... 新华社北京2月28日电(记者谢希瑶)商务部28日公布对原产于加拿大的进口油菜籽反倾销调查的最终裁定,...
原创 硬... 美国这回在关税问题上栽了个大跟头。 不是小打小闹,是硬生生被自己最高法院拦腰斩断了政策根基。 特朗普...
原创 美... 特朗普在2026年2月24日那天,站在国会大厅里,一口气讲了1小时47分钟。 这是美国历史上最长的一...
【招商引资项目】华能上都新能源... 华能上都新能源外送基地联营项目是锡林郭勒盟聚焦清洁能源外送、深化央地合作、服务京津冀能源保障的重点招...
刘军连:白癜风患者如何护理肘部... 肘部是白癜风的高发部位,此处关节活动频繁,易受衣物摩擦、桌面挤压,且长期暴露在外,易受紫外线直射,皮...
谷歌的世纪豪赌:借百年的钱,买... 作者 | 丁卯 2月10日,谷歌母公司Alphabet在全球债券市场投下一枚震撼炸弹。 此次Alph...
仁东控股集团股份有限公司 一、重要提示 本年度报告摘要来自年度报告全文,为全面了解本公司的经营成果、财务状况及未来发展规划,投...
原创 深... 你要说这两年深圳的“港味儿”有多浓?去趟山姆超市或者COCO Park溜达一圈就知道了。别说普通话,...
原创 下... 黄金市场正处在一个前所未有的紧绷时刻。 2026年2月26日,伦敦现货黄金价格在一天之内上演了深V反...
上海安路信息科技股份有限公司2... 本公司董事会及全体董事保证本公告内容不存在任何虚假记载、误导性陈述或者重大遗漏,并对其内容的真实性、...
日本试采深海稀土泥,成本是中国... 来源:市场资讯 (来源:时报新征途) 央视网近日报道,日本是全球第二大稀土消费国,仅次于中国。但日...
原创 雷... 本来以为2月28日晚上,小米在巴塞罗那的发布会就是走个过场,把小米17系列在海外发一发,结果雷总根本...
人民币汇率破6.87,按现价算... 这段时间人民币兑美元汇率一直在不断上升。 截至目前,人民币在岸和离岸对美元汇率纷纷都破了6.87,其...
原创 扛... 特朗普向中国服软,中方禁令引起连锁反应。 2月26日,中国就将继续推进对中国履行中美第一阶段经贸协议...
原创 发... 先看一个老生常谈的现象:春节酒店价格又涨了。 今年春节出游的情绪明显回升,外出“旅游式过年”与返乡“...
经纪业务管理薄弱、营销宣传不规... (图片来源:视觉中国) 蓝鲸新闻2月28日讯(记者 王婉莹)中山证券合规问题再添“新伤”。日前,深圳...
以色列突袭伊朗!炸弹落在德黑兰... 来源:市场资讯 (来源:预见能源) 德黑兰市中心的爆炸声,让全球石油市场的神经瞬间绷到最紧。 2月...
金饰克价,冲上1600元!最新... 据央视新闻消息,当地时间28日,伊朗首都德黑兰发生爆炸。以色列国防部长表示,以色列对伊朗发动了先发制...
做到全球第一却累亏28亿,大疆... 出品 | 创业最前线 作者 | 星空 编辑 | 蛋总 美编 | 倩倩 审核 | 颂文 在全球人口老龄...