一种适用于无线传感器网络的规则引擎的设计与实现
详细信息    本馆镜像全文|  推荐本文 |  |   获取CNKI官网全文
摘要
规则引擎将业务决策从应用程序代码中分离出来,并使用预定义的语义模块编写业务决策。接受数据输入,解释业务规则,并根据规则做出业务决策。规则引擎的使用可以使业务规则具有明确的定义、规范的表达和系统的管理。同时,规则引擎内部的运行不受具体规则的限制,因此具有很强的可重用性,大幅度的提高了软件开发的效率。
     本文设计并实现了一种适用于无线传感器网络应用领域的规则引擎。该规则引擎应用于无线传感器网络数据采集监控平台,实现了数据分析业务规则的灵活使用与管理。该规则引擎主要包括管理控制模块、规则解析模块、规则推理模块和执行器模块。规则解析模块中,利用GPPG工具,通过编写配置文件,实现了一种规则文本编译器;规则推理模块中,通过对匹配网络和推理过程的改进,实现了一种新的引擎工作方式;执行器模块中,利用消息订阅机制与其它模块连接,实现了一种通用的软件模块接口。在应用过程中,该规则引擎响应及时、运行稳定,达到了预期的效果。
In recent years, the business rules in the enterprise software platform are constantly increasing and becoming more complex. Rule Engines are getting more attention and application. Rule Engine can separate the business decisions from the computer program, write business decisions with pre-defined semantics, receive data input, parse business rules, and make business decisions.
     In the region of wireless sensor network applications, there are a great number of data management business rules in data collection and monitoring software. Such as data filtering, data parsing, data analysis, etc. The application of Rule Engine can make these business rules have clear definitions, standard expressions and uniform management. Even non-technical person can easily grasp these rules. Moreover, the internal system of Rule Engine is separated from specific rules and is highly reusable. When a rule engine component successfully developed, it can be applied to many software modules, and greatly enhanced the efficiency of the software development.
     This paper described the design and implementation of a rule engine for wireless sensor network application after describing the principle and general implementation method of Rule Engine. The Rule Engine of this paper has some improvements according to the characteristics of data and business in software platform for wireless sensor network. This rule engine can be applied to the software platform for wireless sensor network.
     This rule engine is composed of four modules. They are engine controller module, rule parsing module, reasoning module and agenda module.
     ?Engine controller module has two main functions: one is controlling the engine, including startup and closedown. While starting the engine, there are some important mapping-tables need to initialize or update. The other function is managing rules, including adding, deleting and editing rules. The main function of rule parsing module is parsing rules and converting these rules into the form from which the reasoning module can distinguish. In this module, we use a tool named Gardens Point Parser Generator to implement a new rule parser throw editing configuration files.
     This parser can parse files which match the pro-defined grammar. The configuration file of this parser is composed of the Backus-Naur Form (BNF). This file can be divided into three parts: definition part, grammar rules part and sub-program part. We define the grammar of the parser’s input file in this file, and the parser will follow the grammar while working.
     The main function of reasoning module is construct match-tree and matching rules with facts. We improved the match-tree constructing algorithm. The main idea of this improved algorithm is: Divide the nodes of match-tree into three parts according to the nodes’function. They are pattern nodes, multi-pattern nodes and rule nodes. The rules which have uncertain variable should be push into match-tree. Construct a rule node for the rule as the child node of the root node. Search for the corresponding match node for the rule node and add the searching results to the children group of the rule node. Construct the corresponding unsearchable match node and also add them to the rule node’s children group. If these newly constructed nodes contain a multi-match node, find corresponding match nodes, of which the multi-match node is composed, and add these match nodes to the multi-match node’s children group. Repeat this process until all the rules are added to the match-tree and the construction of this tree is over.
     The main idea of reasoning process is as follows: Send the facts to corresponding match nodes which are the leaf nodes of the match-tree. These ?match nodes then send the facts they received to their father nodes which are multi-match nodes. The multi-match nodes should judge if the facts they received content the variable-consistency-restrict. If this satisfied, the facts should be saved. All of these match nodes follow this process. The rules, whose rule nodes are successfully matched, should be activated and these rules’action signal should be sent to the agenda module.
     The agenda module is responsible for dealing with the activated actions. We use message subscription mechanism to send the actions to corresponding execution modules throw Socket. The agenda links execution modules with weak coupling mechanism instead of calling function. This facilitates the module calling.
     In the application, the rule engine of this paper is applied to the data collection and monitor software platform for wireless sensor network. The rule engine is used to implement the Data Analyzer. The user of this software can edit rules throw UI. Wireless sensor network can collect the sensor data such as temperature, light and send these data to the platform. The platform then sends these data to the Data Analyzer. Data Analyzer analyzes these data according to pre-edited rules, and gets actions such as sending message, alarming.
     During the application, this rule engine can run stably and response in time. Moreover, it has friendly user interface and is easy to operate. This software also has interface of weak coupling and is highly reusable. It will have a broad prospect!
引文
[1] Robert B.Doorenbos, Production Matching for Large Learning Systems, CMU-CS, 95—113, 1995.
    [2] Charles L.Forgy, Rete: A Fast Algorithm for the Many Pattern/Many Object Pattern Match Problem, Atrificial Intelligence, 17—37,1985.
    [3] N.Abramson, Multiple Access in Wireless Digital Networks, Proceedings of the IEEE, 1360—1370, 1994.
    [4] T.Liu, M.Martonosi, Impala: A Middleware System for Managing Autonomic Parallel Sensor Systems, In ACM SIGPLAN, San Diego, USA, 2003.
    [5] 张渊, 夏清国, 基于 Rete 算法的 Java 规则引擎, 科学技术与工程, 2006 年, 第 11 期, 第 6 卷, 1548—1550.
    [6] Joseph C.Giarratano, Gary D.Riley, Expert Systems Principles and Programming, 2006.
    [7] Lee Brownston, Programming Expert Systems in OPS5, An Introduction to Rule-Based Programming, Addison-Wesley, 1985.
    [8] Kirsten Terfloth, Georg Wittenburg, Jochen Schiller, FACTS:A Rule-based Middleware Architecture for Wireless Sensor Networks, Freie University Berlin, 2005.
    [9] Pandurang Nayak, Anoop Gupta, Paul Rosenbloom, Comparison of the Rete and Treat Production Matchers for Soar, Stanford University.
    [10] James Owen, Business Rules Management Systems, June 25, 2004.
    [11] Charles L.Forgy, On the Efficient Implementation of Production Systems, Ph.D.thesis, Carnegie-Mellon University, 1979.
    [12] Hamid Pirahesh, A Rule Engine for Query Transformation in Starburst and IBM DB2 C/S DBMS, Proceedings of the Thirteenth International Conference Data Engineering, 391—400,1997.
    [13] Peter Jackson, Introduction to Expert Systems Addison-Wesley, 3rd Edition,1999.
    [14] 李德泉, 刘远航, 一个基于 Rete 算法的可视化产生式系统, 辽宁大学学报, 2002 年, 第 1 期, 第 25 卷, 27—30.
    [15] 宋震, 郭福顺, 李莲治, IMPR: 一种优于 RETE 算法的多模式/多对象匹配算法, 小型微型计算机系统, 2002 年, 第 2 期, 第 23 卷, 176—179.
    [16] 张剑, 孟波, 基于规则引擎的一种智能工作流系统研究, 计算机工程与设计, 2006 年, 第 14 期, 2591—2593.
    [17] J Frolik, QoS Control for Random Access Wireless Sensor Network, In Proceedings of the 2004 Wireless Communication and Networking Conference.
    [18] 崔莉, 鞠海玲, 苗勇, 李天璞, 刘巍, 赵泽, 无线传感器网络研究进展, 计算机研究与发展, 2005 年, 第 42 期, 163—174.
    [19] Earley J, An Efficient Context-free Parsing Algorithm, Communications of the ACM, 1970.
    [20] 金成植, 编译程序构造原理和实现技术, 高等教育出版社, 2000 年 7月, 第 1 版.

© 2004-2018 中国地质图书馆版权所有 京ICP备05064691号 京公网安备11010802017129号

地址:北京市海淀区学院路29号 邮编:100083

电话:办公室:(+86 10)66554848;文献借阅、咨询服务、科技查新:66554700