用强化学习和反事实分析,从旧系统中提取可读的决策规则。
BlackBoxToBlueprint: Extracting Interpretable Logic from Legacy Systems using Reinforcement Learning and Counterfactual Analysis
- 通过强化学习探索输入空间,定位影响输出的关键决策边界。
- 在边界区域收集反事实样本,聚类后训练决策树生成可读规则。
- 适用于需要理解旧系统逻辑的迁移与测试场景。
现代化遗留软件系统是一项关键但具有挑战性的任务,常因缺乏文档和对原始系统复杂决策逻辑的理解而受阻。传统方法如行为克隆仅复制输入输出行为,未能捕捉其内在意图。本文提出一种新流程,可自动从视为黑箱的遗留系统中提取可解释的决策逻辑。该方法利用强化学习(RL)代理探索输入空间,通过奖励导致输出显著变化的动作来识别关键决策边界。这些反事实状态转移被收集并使用K-Means聚类。随后在聚类结果上训练决策树,以提取近似系统决策逻辑的人类可读规则。在三种不同复杂度的模拟遗留系统上验证了该流程的有效性,包括阈值逻辑、组合条件逻辑和非线性区间逻辑。结果显示,强化学习代理能有效聚焦于相关边界区域,提取出的规则准确反映了底层模拟系统的核心逻辑,为遗留系统迁移过程中的规范生成与测试用例设计提供了有前景的基础。
原文摘要 · Abstract (English)
Modernizing legacy software systems is a critical but challenging task, often hampered by a lack of documentation and understanding of the original system's intricate decision logic. Traditional approaches like behavioral cloning merely replicate input-output behavior without capturing the underlying intent. This paper proposes a novel pipeline to automatically extract interpretable decision logic from legacy systems treated as black boxes. The approach uses a Reinforcement Learning (RL) agent to explore the input space and identify critical decision boundaries by rewarding actions that cause meaningful changes in the system's output. These counterfactual state transitions, where the output changes, are collected and clustered using K-Means. Decision trees are then trained on these clusters to extract human-readable rules that approximate the system's decision logic near the identified boundaries. I demonstrated the pipeline's effectiveness on three dummy legacy systems with varying complexity, including threshold-based, combined-conditional, and non-linear range logic. Results show that the RL agent successfully focuses exploration on relevant boundary regions, and the extracted rules accurately reflect the core logic of the underlying dummy systems, providing a promising foundation for generating specifications and test cases during legacy migration.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。