1 / 28

Rule Engine-based Programming

Rule Engine-based Programming. Joinwork 研发小组整理 2004/11. 内容. 面临的问题 相关概念 解决方案 公司和产品. 管理者的要求. 为提高效率,管理流程必须自动化,即使现代商业规则异常复杂 市场要求业务规则经常变化, IT 系统必须依据业务规则的变化快速、低成本的更新 为了快速、低成本的更新,业务人员应能直接管理 IT 系统中的规则,不需要程序开发人员参与. 管理者叫来程序员,希望程序员满足他的要求. 程序员的苦恼. 程序 = 算法 + 数据结构 有些复杂的商业规则很难推导出算法和抽象出数据模型

aviva
Download Presentation

Rule Engine-based Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Rule Engine-based Programming Joinwork研发小组整理 2004/11

  2. 内容 • 面临的问题 • 相关概念 • 解决方案 • 公司和产品

  3. 管理者的要求 • 为提高效率,管理流程必须自动化,即使现代商业规则异常复杂 • 市场要求业务规则经常变化,IT系统必须依据业务规则的变化快速、低成本的更新 • 为了快速、低成本的更新,业务人员应能直接管理IT系统中的规则,不需要程序开发人员参与 管理者叫来程序员,希望程序员满足他的要求

  4. 程序员的苦恼 • 程序=算法+数据结构 有些复杂的商业规则很难推导出算法和抽象出数据模型 • 软件工程要求从需求->设计->编码 可业务规则常常在需求阶段可能还没有明确,在设计和编码后还在变化 • 业务规则嵌在系统各处代码中 对程序员来说,系统已经维护、更新困难,更不可能让业务人员来管理 程序员几乎晕倒,还好他遇见了科学家,科学家介绍了自己的研究成果…

  5. 科学家的成果 • 推理方法 • 领域知识 • 知识的表示 • 独立于知识的外壳(shell) 人工智能 (AI) 机器人 视觉 语音 专家系统 人工神经系统 自然语言

  6. 基于规则的专家系统组成

  7. 知识库 • 规则:知识的表示,模拟人类问题求解的产生式规则 • 交通法规知识的规则表示 “红灯”规则: IF 亮红灯 THEN 停下来 “绿灯”规则: IF 亮绿灯 THEN 走 • 前件( A n t e c e d e n t )、条件部分(Conditional part)、模式部分(Pattern part)或左部(Left-hand-side, LHS), • 单独的条件“亮绿灯”称为条件元素(Conditional element)或一个模式( P a t t e r n )。 • 后件( C o n s e q u e n t )或右部(Right-hand side, RHS):是规则触发时将要执行的一系列行为( A c t i o n )。

  8. 工作内存( Working memory) • 被规则所使用的事实的全局数据库 • 包含关于交通灯当前状态的事实如“亮绿灯”或“亮红灯”,这些事实可能一个或者两个同时在工作记忆中。

  9. 推理机(Inference engine) • 通过决定哪些规则满足事实或目标,并授予规则优先级,满足事实或目标的规则被加入议程。 • 正向链 (Forward chaining)和反向链(Backward chaining) • 正向链是从事实到结论的推理 • 反向链则是从假设,即要证明的结论,到事实的推理。

  10. 议程( A g e n d a ) • 由推理机创建的一个规则优先级表,这些规则匹配工作内存中的事实 • 同时会有多个规则和事实匹配,优先级最高的被触发 • 被触发规则的动作可能会产生新的事实,新的事实被加入工作内存

  11. 知识获取机(Knowledge acquisition facility) • 为用户建立的一个知识自动输入方法,以代替知识工程师去编码知识。 解释机(Explanation facility) • 解释系统的推理给用户 • 专家系统的输出

  12. 专家系统与传统程序的差别 耐心听到此处,程序员忽有所悟…

  13. 产生以下结果 一般管理系统 专家系统 基于规则引擎的 管理系统 程序员的大脑 • 进行以下快速模式匹配 业务规则嵌在各处代码中…控制与数据 \ 隐含在一起 ? 明确分开 ! 很难推导出算法 ..? 由……求解 \ 算法 ?? 规则和推理机 ..修改 \ 难 ? 较易 !! 业务规则….变化!! 扩充 \ 很大改动 ! 逐步增加….. 程序员大脑当然比专家系统速度快,以下是其计算结果

  14. 业务规则引擎架构

  15. Rules authoring environment

  16. Decision Table

  17. Ruleflow

  18. Rule Engine APIs • JSR 94 APIs for basic rule engine operations, such as rules for parsing, adding facts to the working memory, and firing rules • Expert Group: Art Technology Group Inc.(ATG)、 BEA Systems、Fujitsu Limited 、 IBM、ILOG 、 Novell, Inc. 、Oracle 、Unisys • StatusProposed Final Draft 29 Oct, 2003 Public Review 11 Sep, 2002 Community Draft Ballot 19 Feb, 2002 Community Review 19 Feb, 2002 Expert Group Formation 19 Dec, 2000 JSR Review Ballot 27 Nov, 2000

  19. Rules repository (XML) • KQML (Knowledge Query and Manipulation Language) : http://ksl.stanford.edu/knowledge-sharing • RuleML(Rule Markup Language) : http://www.dfki.uni-kl.de/ruleml • BRML : IBM CommonRules http://alphaworks.ibm.com/ • Business Rule Exchange - the Next XML Wave ? to exchange knowledge via XML, not just data.

  20. RuleML Example • Discount: If the total purchase amount of a shopping cart is > 100$ Then Set the discount for the shopping cart to 0.1% • RuleML: <rule name="Discount"> <conditionPart> <simpleCondition className="ShoppingCart" objectVariable="s"> <binaryExp operator="gt"> <field name="purchaseAmount"/> <constant type="float" value="100"/> </binaryExp> </simpleCondition> </conditionPart> <actionPart> <modify> <variable name="s"/> <assignment> <field name="discount"/> <constant type="float" value="0.1"/> </assignment> </modify> </actionPart> </rule>

  21. Rule Engine Core • 优化的RETE 算法 • 正向链 (Forward chaining) • DEMO

  22. Implement business rule engines in a J2EE enterprise

  23. J2EE rule engine architecture

  24. 程序员的杰作 • Empower business users to change and maintain their own production systems without programming help and without interrupting operations • Build and integrate sophisticated object models incorporating corporate data sources including databases and XML schemas • Use drag and drop visual layout tools to design complex rule-driven process flows with conditional branching, reusable rulesets, functions, and question sets • Personalize business processes and portals with user-specific data displays, interactive dialogs, and product recommendations • Deploy highly scalable rule systems with exceptional performance on all leading platforms 干完活,程序员去见管理者,得意的说:“… …”

  25. 公司(个人)和产品 • Fair, Isaac : Blaze Advisor v4.5 used by WebSphere Commerce • ILOG, Inc. : JRules v4.5 , Rules used by Chordiant • Yasu Technologies : QuickRules v2.6 有免费30天试用版下载 • Ernest J. Friedman-Hill : Jess 6.1 … …

  26. 市场人员的说法 • “ Business rule engines are moving toward maturity. In 2003, they will support business agility when called on to do so ” The Business Rule Engine 2003 Magic Quadrant. 7 April 2003 , Gartner • “A Gartner survey showed a return on investment of nearly 10 percent in IT costs being saved by using business rule technology. The future savings and benefits of business rule engines are expected to grow significantly over time.” Rules: Adding Intelligence to the Enterprise Architecture. 18 July 2002 , Gartner

  27. 参考材料 1. Business process automation made easy with Java Part 1 & 2 By Ahmed Abulsorour and Siva Visveswaran September 6, 2002 2. Implementing a Rule-Driven Service Oriented Architecture By Daniel C. Hayes July 2003 3. Expert Systems Principles and Programming(专家系统原理与编程) By Joesph Giarratano 4. Business Rule Exchange - the Next XML WaveBy Margaret Thorpe 5. http://www.jcp.org/en/jsr/detail?id=094 6. http://www.iLog.com 7. http://www.blazesoft.co.uk/ 8. http://www.yasutech.com 9. http://herzberg.ca.sandia.gov/jess

More Related