APS开源源码解读: 排程工具 optaplanner II
上篇
排产,原则上也就是分配时间,分配资源;保证资源日历约束,保证工艺路线约束。我们看一下如何实现optaplanner 优化的
- 定义一个move, 一个move可能改变了分配到的资源,也可能改变了一个资源上的顺序。改变即意味着优化的可能
- 原本分配的资源,把后工序移到前面来。前后各算一个score. 通过socreDirector中定义的beforeVariableChanged/afterVariableChanged
- 再更新另一个资源上的链,同时前后继续scoreDirector触发
- 另一个shadow variable: Start time,通过StartTimeUpdatingVariableListener触发改变。这里的改变保证了不同资源上的job满足工艺路线的约束
模型
如何建模对一个优化问题非常关键
Chain Structure:
The previousAllocation can now be either a Resource (anchor) or another Allocation
Resource becomes a shadow variable automatically updated based on the chain
This creates a clean chain: Resource -> Allocation1 -> Allocation2 -> …
Move Simplification:
No need for separate resource change moves
Single ChainChangeMove handles both resource changes and sequence changes
When moving to a different resource, just set the previous to be the resource
When moving within same resource, set previous to be another allocation
Benefits:
Simpler code structure
Fewer variables to maintain
More efficient move generation
Better encapsulation of the chaining logic
Automatic resource updates through shadow variable
过程
本文我们继续试图学习optaplanner来进行排产规划。
When a move changes an allocation’s resource and/or sequence:
When OptaPlanner/timefold selects a move:
- Check if move is doable (isMoveDoable)
- Verify resource compatibility
- Check for circular dependencies
- Validate sequence constraints
- Execute the move (doMove)
- Update primary planning variables
- Shadow variable listener triggers
- Start/end times cascade update
- Score calculation
- Check hard constraints
- Resource conflicts
- Job dependencies
- Resource compatibility
- Evaluate soft constraints
- Makespan
- Setup times
- Resource preferences
- Accept/Reject move based on score
- If better: keep change
- If worse: maybe keep (based on meta-heuristic)
The previousAllocation shadow variable is updated first
This triggers the AnchorShadowVariable (resource) to update
The StartTimeUpdatingVariableListener then recalculates timing
Chain Update Process:
When an allocation moves to a new resource:
a. It disconnects from its old chain (previous/next allocations are relinked)
b. Inserts into new resource’s chain at specified position
c. Updates shadow variables (resource, start time) for moved allocation
d. Recursively updates all downstream allocations in both chains
Impact on Route Dependencies:
The StartTimeUpdatingVariableListener ensures timing consistency
When start time changes, it propagates updates down the chain
If jobs have dependencies across resources, you’ll need additional constraints
Can add precedence constraints between related jobs
例如
Before:
Resource1 -> Allocation1 -> Allocation2 -> Allocation3
Resource2 -> Allocation4 -> Allocation5
After:
Resource1 -> Allocation1 -> Allocation3
Resource2 -> Allocation4 -> Allocation2 -> Allocation5
The system will:
Update Allocation2’s previousAllocation to Allocation4
Update Allocation2’s resource to Resource2
Recalculate start times for Allocation2 and all subsequent allocations
Update Allocation3’s previousAllocation to Allocation1
Recalculate start times in Resource1’s chain
细节
当一个move发生的时候:
- isMoveDoable() is checked
- doMove() is called if move is doable
- Score is calculated after each change
- Move is accepted/rejected based on score
During doMove()
- beforeVariableChanged() notifies ScoreDirector
- Chain updates occur
- afterVariableChanged() notifies ScoreDirector
- Shadow variables update automatically
- Score calculator runs automatically
Score calculation triggers:
- After every genuine variable change
- After shadow variables update
- After variable listeners complete their updates
- Before move acceptance/rejection decision
// Move implementation for changing position in chain
public class ChainChangeMove extends AbstractMove<JobShopSchedule> {private final Allocation allocation;private final Object newPrevious; // Can be Resource or Allocation@Overrideprotected void doMoveOnGenuineVariables(ScoreDirector<JobShopSchedule> scoreDirector) {Object oldPrevious = allocation.getPreviousAllocation();Allocation nextAllocation = findNextAllocation(allocation);// Remove allocation from old chain positionif (nextAllocation != null) {scoreDirector.beforeVariableChanged(nextAllocation, "previousAllocation");nextAllocation.setPreviousAllocation(oldPrevious);scoreDirector.afterVariableChanged(nextAllocation, "previousAllocation");}// Insert allocation at new chain positionAllocation newNext = null;if (newPrevious instanceof Allocation) {newNext = findNextAllocation((Allocation) newPrevious);}// Update the moved allocation's previousscoreDirector.beforeVariableChanged(allocation, "previousAllocation");allocation.setPreviousAllocation(newPrevious);scoreDirector.afterVariableChanged(allocation, "previousAllocation");// Update the next allocation's previous if it existsif (newNext != null) {scoreDirector.beforeVariableChanged(newNext, "previousAllocation");newNext.setPreviousAllocation(allocation);scoreDirector.afterVariableChanged(newNext, "previousAllocation");}}
}
ScoreDirector manages this process
scoreDirector.beforeVariableChanged()
→ Make changes
→ scoreDirector.afterVariableChanged()
→ Shadow updates
→ Score calculation
→ Move acceptance
For chain moves specifically:
a. Original chain score is calculated
b. Move changes are applied
c. New chain score is calculated
d. Downstream impacts are scored
e. Total impact determines move acceptance
相关文章:
APS开源源码解读: 排程工具 optaplanner II
上篇 排产,原则上也就是分配时间,分配资源;保证资源日历约束,保证工艺路线约束。我们看一下如何实现optaplanner 优化的 定义一个move, 一个move可能改变了分配到的资源,也可能改变了一个资源上的顺序。改变即意味着优…...
科技是把双刃剑,巧用技术改变财务预测
数字化和全球化的双向驱动,引领我国各行各业在技术革新的浪潮中不断扬帆。这一趋势不仅带来了前所未有的突破与创新,推进企业迈向数据驱动决策的新未来,同时也伴随着一些潜在的问题和挑战。科技的普及就像是一场革命,在财务管理领…...
vscode默认添加python项目的源目录路径到执行环境(解决ModuleNotFoundError: No module named问题)
0. 问题描述 vscode中编写python脚本,导入工程目录下的其他模块,出现ModuleNotFoundError: No module named 错误 在test2的ccc.py文件中执行print(sys.path) 查看路径 返回结果发现并无’/home/xxx/first_demo’的路径,所以test2下面的文…...
【每日刷题】Day143
【每日刷题】Day143 🥕个人主页:开敲🍉 🔥所属专栏:每日刷题🍍 🌼文章目录🌼 1. 200. 岛屿数量 - 力扣(LeetCode) 2. LCR 105. 岛屿的最大面积 - 力扣&…...
基于Springboot智能学习平台的设计与实现
基于Springboot智能学习平台的设计与实现 开发语言:Java 框架:springboot JDK版本:JDK1.8 数据库:mysql 5.7 数据库工具:Navicat11 开发软件:idea 源码获取:https://download.csdn.net/downlo…...
黑马javaWeb笔记重点备份11:Web请求与响应
请求 SpringBoot内置Servlet 在Tomcat这类Web服务器中,是不识别我们自己定义的Controller的,但在tomcat中是可以识别 Servlet程序的。在SpringBoot进行web程序开发时,它内置了一个核心的Servlet程序 DispatcherServlet,称之为 核…...
H5对接海康硬盘录像机视频简单说明
开发过程中使用HTML5(通常是通过Web技术栈,如HTML、CSS、JavaScript)与海康威视(Hikvision)的硬盘录像机(DVR)进行视频对接,通常涉及以下步骤: 获取DVR的RTSP流地址:海康威视DVR支持RTSP协议,你可以通过DVR的管理界面获取每个摄像头的RTSP流地址。 使用视频播放器库…...
测试人必备的Linux常用命令大全...【全网最全面整理】
Linux常用命令大全(非常全!!!) 最近都在和Linux打交道,感觉还不错。我觉得Linux相比windows比较麻烦的就是很多东西都要用命令来控制,当然,这也是很多人喜欢linux的原因,…...
苹果AI落后两年?——深度解析苹果在AI领域的挑战与前景
# 苹果AI落后两年?——深度解析苹果在AI领域的挑战与前景 近年来,人工智能(AI)领域的技术竞争日益激烈,各大科技巨头纷纷推出突破性的AI产品。然而,关于苹果公司在AI领域的表现,最近传出一些内…...
三菱PLC伺服-停止位置不正确故障排查
停止位置不正确时,请确认以下项目。 1)请确认伺服放大器(驱动单元)的电子齿轮的设定是否正确。 2)请确认原点位置是否偏移。 1、设计近点信号(DOG)时,请考虑有足够为0N的时间能充分减速到爬行速度。该指令在DOG的前端开始减速到爬行速度&…...
Mybatis 批量操作存在则更新或者忽略,不存在则插入
Mybatis 批量操作新增,如果存在重复有下列2种处理方式: 1、存在则忽略代码示例: <insert id"insertDuplicateKeyIgnoreList">INSERT IGNORE INTO specs(status,type,code,name,create_time,create_by)VALUES<foreach col…...
「C/C++」C++ STL容器库 之 std::deque 双端队列容器
✨博客主页何曾参静谧的博客📌文章专栏「C/C」C/C程序设计📚全部专栏「VS」Visual Studio「C/C」C/C程序设计「UG/NX」BlockUI集合「Win」Windows程序设计「DSA」数据结构与算法「UG/NX」NX二次开发「QT」QT5程序设计「File」数据文件格式「PK」Parasoli…...
一招教你解决Facebook广告账号问题
这段时间,我们写了很多文章来探讨Facebook的广告账户问题:《Facebook被封号该怎么办》《Facebook二不限、三不限账号是什么》《Facebook海外户(三不限)和账单户该如何选择》《如何区分真假Facebook三不限海外户》相信看过这些文章…...
MySQL启动报错:InnoDB: Unable to lock ./ibdata1 error
MySQL启动报错:InnoDB: Unable to lock ./ibdata1 error 在OS X环境下MySQL启动时报错: 016-03-03T00:02:30.483037Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 35 2016-03-03T00:02:30.483100Z 0 [Note] InnoDB: Check that you do not alr…...
Linux终端之旅: 打包和压缩
在 Linux 世界中,打包和压缩文件是管理系统资源、传输数据和备份的重要技能。通过命令行工具如 tar、gzip、zip 等,我们可以高效地将多个文件或目录打包为一个文件,并通过压缩减少其体积。接下来,我将记录学习如何利用这些工具&am…...
PDA手持机提升管理效率和准确性
在当今快节奏的商业世界中,管理效率和准确性是企业成功的关键因素。而 PDA 手持机的出现,为企业管理带来了革命性的变革,成为提升管理效率和准确性的有力武器。 PDA 手持机,即个人数字助理手持设备,集数据采集、存储、…...
C++ [项目] 愤怒的小鸟
现在才发现C游戏的支持率这么高,那就发几篇吧 零、前情提要 此篇为 制作,由于他没有CSDN,于是由我代发 一、基本介绍 支持Dev-C5.11版本(务必调为英文输入法),基本操作看游戏里的介绍,怎么做的……懒得说,能看懂就看注释,没有的自己猜,如果你很固执……私我吧 …...
群控系统服务端开发模式-市场分析
刚刚我把群控系统服务端开发模式的文档全部整理了一下,结果发现还缺市场分析这篇文档没有上传,不好意思啦。 一、前言 在互联网高速发展且稳定的时代,营销系统是自运营公司线上最好的系统。加上现在直播行业很火,引流很重要&#…...
智能听诊器革新宠物健康监测
在宠物健康护理领域,智能听诊器的引入标志着一个新时代的开启,它正成为宠物医疗保健的新宠。这款设备通过高精度传感器捕捉宠物的心跳和呼吸声,为宠物主人和兽医提供精确的健康数据。 智能听诊器的即时反馈功能,使得主人能够通过…...
2000-2023年上市公司绿色专利申请授权面板数据
2000-2023年上市公司绿色专利申请授权面板数据 1、时间:2000-2023年 2、来源:国家知识产权局、WPIO清单 3、指标:年份、股票代码、股票简称、行业名称、行业代码、省份、城市、区县、区县代码、上市状态、绿色专利申请总量、绿色发明专利申…...
springboot 百货中心供应链管理系统小程序
一、前言 随着我国经济迅速发展,人们对手机的需求越来越大,各种手机软件也都在被广泛应用,但是对于手机进行数据信息管理,对于手机的各种软件也是备受用户的喜爱,百货中心供应链管理系统被用户普遍使用,为方…...
ES6从入门到精通:前言
ES6简介 ES6(ECMAScript 2015)是JavaScript语言的重大更新,引入了许多新特性,包括语法糖、新数据类型、模块化支持等,显著提升了开发效率和代码可维护性。 核心知识点概览 变量声明 let 和 const 取代 var…...
深入浅出:JavaScript 中的 `window.crypto.getRandomValues()` 方法
深入浅出:JavaScript 中的 window.crypto.getRandomValues() 方法 在现代 Web 开发中,随机数的生成看似简单,却隐藏着许多玄机。无论是生成密码、加密密钥,还是创建安全令牌,随机数的质量直接关系到系统的安全性。Jav…...
关键领域软件测试的突围之路:如何破解安全与效率的平衡难题
在数字化浪潮席卷全球的今天,软件系统已成为国家关键领域的核心战斗力。不同于普通商业软件,这些承载着国家安全使命的软件系统面临着前所未有的质量挑战——如何在确保绝对安全的前提下,实现高效测试与快速迭代?这一命题正考验着…...
基于Java Swing的电子通讯录设计与实现:附系统托盘功能代码详解
JAVASQL电子通讯录带系统托盘 一、系统概述 本电子通讯录系统采用Java Swing开发桌面应用,结合SQLite数据库实现联系人管理功能,并集成系统托盘功能提升用户体验。系统支持联系人的增删改查、分组管理、搜索过滤等功能,同时可以最小化到系统…...
为什么要创建 Vue 实例
核心原因:Vue 需要一个「控制中心」来驱动整个应用 你可以把 Vue 实例想象成你应用的**「大脑」或「引擎」。它负责协调模板、数据、逻辑和行为,将它们变成一个活的、可交互的应用**。没有这个实例,你的代码只是一堆静态的 HTML、JavaScript 变量和函数,无法「活」起来。 …...
WEB3全栈开发——面试专业技能点P7前端与链上集成
一、Next.js技术栈 ✅ 概念介绍 Next.js 是一个基于 React 的 服务端渲染(SSR)与静态网站生成(SSG) 框架,由 Vercel 开发。它简化了构建生产级 React 应用的过程,并内置了很多特性: ✅ 文件系…...
【HarmonyOS 5】鸿蒙中Stage模型与FA模型详解
一、前言 在HarmonyOS 5的应用开发模型中,featureAbility是旧版FA模型(Feature Ability)的用法,Stage模型已采用全新的应用架构,推荐使用组件化的上下文获取方式,而非依赖featureAbility。 FA大概是API7之…...
土建施工员考试:建筑施工技术重点知识有哪些?
《管理实务》是土建施工员考试中侧重实操应用与管理能力的科目,核心考查施工组织、质量安全、进度成本等现场管理要点。以下是结合考试大纲与高频考点整理的重点内容,附学习方向和应试技巧: 一、施工组织与进度管理 核心目标: 规…...
Python 高级应用10:在python 大型项目中 FastAPI 和 Django 的相互配合
无论是python,或者java 的大型项目中,都会涉及到 自身平台微服务之间的相互调用,以及和第三发平台的 接口对接,那在python 中是怎么实现的呢? 在 Python Web 开发中,FastAPI 和 Django 是两个重要但定位不…...
