当前位置: 首页 > news >正文

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:

  1. Check if move is doable (isMoveDoable)
  • Verify resource compatibility
  • Check for circular dependencies
  • Validate sequence constraints
  1. Execute the move (doMove)
  • Update primary planning variables
  • Shadow variable listener triggers
  • Start/end times cascade update
  1. Score calculation
  • Check hard constraints
    • Resource conflicts
    • Job dependencies
    • Resource compatibility
  • Evaluate soft constraints
    • Makespan
    • Setup times
    • Resource preferences
  1. 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发生的时候:

  1. isMoveDoable() is checked
  2. doMove() is called if move is doable
  3. Score is calculated after each change
  4. Move is accepted/rejected based on score

During doMove()

  1. beforeVariableChanged() notifies ScoreDirector
  2. Chain updates occur
  3. afterVariableChanged() notifies ScoreDirector
  4. Shadow variables update automatically
  5. Score calculator runs automatically

Score calculation triggers:

  1. After every genuine variable change
  2. After shadow variables update
  3. After variable listeners complete their updates
  4. 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

上篇 排产&#xff0c;原则上也就是分配时间&#xff0c;分配资源&#xff1b;保证资源日历约束&#xff0c;保证工艺路线约束。我们看一下如何实现optaplanner 优化的 定义一个move, 一个move可能改变了分配到的资源&#xff0c;也可能改变了一个资源上的顺序。改变即意味着优…...

科技是把双刃剑,巧用技术改变财务预测

数字化和全球化的双向驱动&#xff0c;引领我国各行各业在技术革新的浪潮中不断扬帆。这一趋势不仅带来了前所未有的突破与创新&#xff0c;推进企业迈向数据驱动决策的新未来&#xff0c;同时也伴随着一些潜在的问题和挑战。科技的普及就像是一场革命&#xff0c;在财务管理领…...

vscode默认添加python项目的源目录路径到执行环境(解决ModuleNotFoundError: No module named问题)

0. 问题描述 vscode中编写python脚本&#xff0c;导入工程目录下的其他模块&#xff0c;出现ModuleNotFoundError: No module named 错误 在test2的ccc.py文件中执行print(sys.path) 查看路径 返回结果发现并无’/home/xxx/first_demo’的路径&#xff0c;所以test2下面的文…...

【每日刷题】Day143

【每日刷题】Day143 &#x1f955;个人主页&#xff1a;开敲&#x1f349; &#x1f525;所属专栏&#xff1a;每日刷题&#x1f34d; &#x1f33c;文章目录&#x1f33c; 1. 200. 岛屿数量 - 力扣&#xff08;LeetCode&#xff09; 2. LCR 105. 岛屿的最大面积 - 力扣&…...

基于Springboot智能学习平台的设计与实现

基于Springboot智能学习平台的设计与实现 开发语言&#xff1a;Java 框架&#xff1a;springboot JDK版本&#xff1a;JDK1.8 数据库&#xff1a;mysql 5.7 数据库工具&#xff1a;Navicat11 开发软件&#xff1a;idea 源码获取&#xff1a;https://download.csdn.net/downlo…...

黑马javaWeb笔记重点备份11:Web请求与响应

请求 SpringBoot内置Servlet 在Tomcat这类Web服务器中&#xff0c;是不识别我们自己定义的Controller的&#xff0c;但在tomcat中是可以识别 Servlet程序的。在SpringBoot进行web程序开发时&#xff0c;它内置了一个核心的Servlet程序 DispatcherServlet&#xff0c;称之为 核…...

H5对接海康硬盘录像机视频简单说明

开发过程中使用HTML5(通常是通过Web技术栈,如HTML、CSS、JavaScript)与海康威视(Hikvision)的硬盘录像机(DVR)进行视频对接,通常涉及以下步骤: 获取DVR的RTSP流地址:海康威视DVR支持RTSP协议,你可以通过DVR的管理界面获取每个摄像头的RTSP流地址。 使用视频播放器库…...

测试人必备的Linux常用命令大全...【全网最全面整理】

Linux常用命令大全&#xff08;非常全&#xff01;&#xff01;&#xff01;&#xff09; 最近都在和Linux打交道&#xff0c;感觉还不错。我觉得Linux相比windows比较麻烦的就是很多东西都要用命令来控制&#xff0c;当然&#xff0c;这也是很多人喜欢linux的原因&#xff0c…...

苹果AI落后两年?——深度解析苹果在AI领域的挑战与前景

# 苹果AI落后两年&#xff1f;——深度解析苹果在AI领域的挑战与前景 近年来&#xff0c;人工智能&#xff08;AI&#xff09;领域的技术竞争日益激烈&#xff0c;各大科技巨头纷纷推出突破性的AI产品。然而&#xff0c;关于苹果公司在AI领域的表现&#xff0c;最近传出一些内…...

三菱PLC伺服-停止位置不正确故障排查

停止位置不正确时&#xff0c;请确认以下项目。 1)请确认伺服放大器(驱动单元)的电子齿轮的设定是否正确。 2&#xff09;请确认原点位置是否偏移。 1、设计近点信号(DOG)时&#xff0c;请考虑有足够为0N的时间能充分减速到爬行速度。该指令在DOG的前端开始减速到爬行速度&…...

Mybatis 批量操作存在则更新或者忽略,不存在则插入

Mybatis 批量操作新增&#xff0c;如果存在重复有下列2种处理方式&#xff1a; 1、存在则忽略代码示例&#xff1a; <insert id"insertDuplicateKeyIgnoreList">INSERT IGNORE INTO specs(status,type,code,name,create_time,create_by)VALUES<foreach col…...

「C/C++」C++ STL容器库 之 std::deque 双端队列容器

✨博客主页何曾参静谧的博客&#x1f4cc;文章专栏「C/C」C/C程序设计&#x1f4da;全部专栏「VS」Visual Studio「C/C」C/C程序设计「UG/NX」BlockUI集合「Win」Windows程序设计「DSA」数据结构与算法「UG/NX」NX二次开发「QT」QT5程序设计「File」数据文件格式「PK」Parasoli…...

一招教你解决Facebook广告账号问题

这段时间&#xff0c;我们写了很多文章来探讨Facebook的广告账户问题&#xff1a;《Facebook被封号该怎么办》《Facebook二不限、三不限账号是什么》《Facebook海外户&#xff08;三不限&#xff09;和账单户该如何选择》《如何区分真假Facebook三不限海外户》相信看过这些文章…...

MySQL启动报错:InnoDB: Unable to lock ./ibdata1 error

MySQL启动报错&#xff1a;InnoDB: Unable to lock ./ibdata1 error 在OS X环境下MySQL启动时报错&#xff1a; 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 世界中&#xff0c;打包和压缩文件是管理系统资源、传输数据和备份的重要技能。通过命令行工具如 tar、gzip、zip 等&#xff0c;我们可以高效地将多个文件或目录打包为一个文件&#xff0c;并通过压缩减少其体积。接下来&#xff0c;我将记录学习如何利用这些工具&am…...

PDA手持机提升管理效率和准确性

在当今快节奏的商业世界中&#xff0c;管理效率和准确性是企业成功的关键因素。而 PDA 手持机的出现&#xff0c;为企业管理带来了革命性的变革&#xff0c;成为提升管理效率和准确性的有力武器。 PDA 手持机&#xff0c;即个人数字助理手持设备&#xff0c;集数据采集、存储、…...

C++ [项目] 愤怒的小鸟

现在才发现C游戏的支持率这么高&#xff0c;那就发几篇吧 零、前情提要 此篇为 制作,由于他没有CSDN,于是由我代发 一、基本介绍 支持Dev-C5.11版本(务必调为英文输入法),基本操作看游戏里的介绍,怎么做的……懒得说,能看懂就看注释,没有的自己猜,如果你很固执……私我吧 …...

群控系统服务端开发模式-市场分析

刚刚我把群控系统服务端开发模式的文档全部整理了一下&#xff0c;结果发现还缺市场分析这篇文档没有上传&#xff0c;不好意思啦。 一、前言 在互联网高速发展且稳定的时代&#xff0c;营销系统是自运营公司线上最好的系统。加上现在直播行业很火&#xff0c;引流很重要&#…...

智能听诊器革新宠物健康监测

在宠物健康护理领域&#xff0c;智能听诊器的引入标志着一个新时代的开启&#xff0c;它正成为宠物医疗保健的新宠。这款设备通过高精度传感器捕捉宠物的心跳和呼吸声&#xff0c;为宠物主人和兽医提供精确的健康数据。 智能听诊器的即时反馈功能&#xff0c;使得主人能够通过…...

2000-2023年上市公司绿色专利申请授权面板数据

2000-2023年上市公司绿色专利申请授权面板数据 1、时间&#xff1a;2000-2023年 2、来源&#xff1a;国家知识产权局、WPIO清单 3、指标&#xff1a;年份、股票代码、股票简称、行业名称、行业代码、省份、城市、区县、区县代码、上市状态、绿色专利申请总量、绿色发明专利申…...

深度强化学习在《我的世界》AI智能体开发中的实战应用

1. 项目概述与核心价值最近在AI与游戏开发交叉领域&#xff0c;一个名为“MineAI”的项目引起了我的注意。这个项目由开发者Mattias发起&#xff0c;其核心目标非常明确&#xff1a;利用人工智能技术&#xff0c;让一个智能体能够自主地学习并玩转《我的世界》&#xff08;Mine…...

普通机床改造成键槽铣床

普通机床在机械加工领域应用广泛&#xff0c;但功能相对单一&#xff0c;若想拓展其加工范围&#xff0c;将其改造成键槽铣床是个不错的选择。改造的核心在于通过加装特定部件&#xff0c;让机床具备铣削键槽的能力。普通机床原本的直线运动和旋转运动基础&#xff0c;为改造提…...

AI生成的前端界面,为什么总是不够好看?

为什么 AI 生成的界面总是"差那么一口气"&#xff1f;用 AI 写前端&#xff0c;你有没有遇到过这种情况——代码跑起来没问题&#xff0c;功能都有&#xff0c;但打开一看&#xff0c;总感觉哪里不对劲。间距挤、排版乱、视觉层次平、配色说不上哪里丑但就是丑……和…...

LSI转型启示:从PowerPC到ARM架构的通信处理器战略演进

1. 从垂直整合到无晶圆厂&#xff1a;LSI的转型之路 在半导体这个行当里待久了&#xff0c;你会发现一个有趣的现象&#xff1a;那些能活下来并且活得不错的公司&#xff0c;往往不是技术最激进的&#xff0c;而是最能适应变化的。LSI&#xff08;LSI Corporation&#xff0c;后…...

Productivity 的核心不是任务管理:拆解 Claude 的 L1/L2 记忆缓存

我们假设这样一个场景&#xff1a;项目群里有人扔过来一句"ask todd to do the PSR for oracle"。对一个刚入职的新同事&#xff0c;这句话基本等于乱码——todd 是哪个 todd&#xff1f;PSR 是什么报告&#xff1f;oracle 指公司还是某笔交易&#xff1f;得反问三轮…...

模具工装全生命周期智能化管理,工业Agent驱动的落地方法详解

站在2026年的时间节点回望&#xff0c;制造业的数字化转型已从简单的“系统上云”演进为“智能体进场”。 传统的模具管理往往深陷“纸质单据多、维护靠经验、数据孤岛深”的泥潭。 随着实在智能新一代企业级「龙虾」矩阵智能体数字员工的全面普及&#xff0c;模具工装全生命周…...

wkhtmltopdf对page=break-after:always属性支持的支持

wkhtmltopdf分页问题深度解析&#xff1a;page-break-after失效原因及解决方案问题背景在使用wkhtmltopdf生成PDF文档时&#xff0c;许多开发者都会遇到一个令人困惑的问题&#xff1a;CSS的page-break-after: always属性为什么不生效&#xff1f; 这个问题在需要精确控制分页位…...

Qt 3D实战:如何给你的三维场景添加第一人称和环绕相机控制器(Qt 5.15.2)

Qt 3D相机控制实战&#xff1a;打造沉浸式交互体验的五大核心策略 在三维可视化应用中&#xff0c;相机控制就像用户的眼睛和双手&#xff0c;直接决定了交互体验的流畅度与沉浸感。当开发者使用Qt 3D构建模型查看器、设计工具或简单游戏时&#xff0c;如何选择合适的相机控制器…...

NanoPi M6硬件解析与嵌入式开发实践

1. NanoPi M6 硬件架构深度解析NanoPi M6 是一款基于 Rockchip RK3588S SoC 设计的单板计算机&#xff0c;其硬件配置在当前 SBC 领域堪称旗舰级。作为长期从事嵌入式开发的工程师&#xff0c;我认为这款板卡最值得关注的是其平衡的性能与扩展性设计。1.1 核心处理器性能剖析RK…...

基于本地AI与向量数据库的智能书签管理系统实战

1. 项目概述&#xff1a;当书签管理遇上AI智能如果你和我一样&#xff0c;是个重度网络冲浪者&#xff0c;或者从事需要大量信息检索的工作&#xff0c;浏览器收藏夹&#xff08;书签&#xff09;大概率已经成了一个“数字黑洞”。我敢打赌&#xff0c;你的书签栏里塞满了各种链…...