Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Cheng A.Real-time systems.Scheduling,analysis,and verification.2002.pdf
Скачиваний:
64
Добавлен:
23.08.2013
Размер:
3.68 Mб
Скачать

430

TIMING ANALYSIS OF PREDICATE-LOGIC RULE-BASED SYSTEMS

r6 -

- - - - -

-

-

r7 -

- - - - -

-

-

----npartite-------

 

 

0

 

 

 

 

1

 

 

 

 

2

3

 

 

 

4

5

 

 

 

6

7

 

 

 

after layer #0 (r0 ) B = 1 numbers of classes of WMEs 3 0 2 1 1 0 1

after layer #1 (r1 ) B = 2 numbers of classes of WMEs 3 0 3 1 2 1 1

after layer #2 (r2 r3 ) B = 5 numbers of classes of WMEs

3 0 3 1 4 1 1

after layer #3 (r4 r5 ) B = 7 numbers of classes of WMEs

3 0 3 1 4 1 1

after layer #4 (r6 r7 ) B = 9 numbers of classes of WMEs

3 0 3 1 4 1 1

*** maximal number of rule firings = 9

11.4 HISTORICAL PERSPECTIVE AND RELATED WORK

Expert system researchers have studied the issues of meeting real-time constraints in expert systems. [O’Reilly and Cromarty, 1985] were among the first to explain that increasing execution speed does not necessarily guarantee that an expert system can meet real-time performance constraints. [Laffey et al., 1988] provided an overview of real-time expert systems and described techniques for ensuring realtime performance. However, they did not present details of these techniques nor did they evaluate their performance. [Strosnider and Paul, 1994] considered the work of Laffey et al. coincidentally real-time and attempted to provide a more structured way to design smart real-time systems. However, no response-time analysis of rule-based systems was given. [Benda, 1987] and [Koch et al., 1986] described the requirements of real-time knowledge-based systems in the aerospace industry. [Payton and Bihari, 1991] argued that different levels of an intelligent control system must cooperate closely to achieve real-time performance and adaptivity.

HISTORICAL PERSPECTIVE AND RELATED WORK

431

[Barachini et al., 1988; Barachini, 1994] presented several run-time prediction methods, as opposed to pre-run-time prediction in our approach, to evaluate the time required for actions in the right-hand sides of rules to be executed. The time required by the Rete network, when a token is passed to it, is estimated. They showed that execution time prediction of embedded expert systems can be performed with finer granularity, such as in the action level. However, in his opinion, the prediction of the execution time of the entire expert system is not achievable in a tractable manner.

However, few attempts have been made to formally address the response-time analysis problem. [Abiteboul and Simon, 1991], among others, have discussed the property of termination in the context of Datalog and its extensions and showed that this property is in general undecidable. Although they have addressed the issue of whether all programs of a given language possesses the property of termination, the issue of determining whether a given program possess the property of termination is not addressed. [Lark et al., 1990] considered the design and implementation issues in the development of Lockheed Pilot’s Associate system. They advocateed using experimentation and analysis to guarantee timeliness by requiring the application programmer to set an upper bound on process duration by extensive experimentation but did not show how to verify that the system would satisfy this upper bound. [Aiken, Widom, and Hellerstein, 1992] presented a static analysis method to determine whether arbitrary sets of database production rules satisfied certain properties, including termination. A directed graph demonstrating the triggering relationship among rules is checked to see if the corresponding set of rules is guaranteed to terminate. Some conditions that guaranteed the property of termination were introduced. We derive one property of rule behavior from this idea.

[Wang and Mok, 1995] studied the response time bounded in the context of EQL rule-based systems with a fixed-size working memory. They stated that the use of more general expert systems with dynamically varying working memories for timecritical application was not feasible at this time because of the lack of a tool for analyzing those systems to predict their response time.

In this chapter, we considered a class of expert systems with dynamically varying working memories and proposed pre-run-time static analysis algorithms to predict the response time of these systems. Few attempts have been made to formalize the question of whether a rule-based program has bounded response time. The first formal frameworks were introduced in [Browne, Cheng, and Mok, 1988; Cheng et al., 1993; Cheng and Wang, 1990; Wang, Mok, and Cheng, 1990]. In [Wang and Mok, 1993], a formal analysis was introduced to predict the timing behavior of MRL programs. [Wang, 1989] and [Shaw, 1992] proposed a method to translate OPS5 programs into MRL programs for response-time bound analysis. However, the timing prediction in [Wang, Mok, and Emerson, 1993b] is based on static analysis, whose results are too pessimistic to approximate the actual bound on execution time. Note that worst-case analysis is still essential for an expert system running in a real-time environment [Musliner et al., 1995]. We have developed the two analysis approaches [Tsai and Cheng, 1994; Cheng and Chen, 2000] described in this chapter.

432 TIMING ANALYSIS OF PREDICATE-LOGIC RULE-BASED SYSTEMS

11.5 SUMMARY

The main focus of this chapter is on addressing the timing properties of predicatelogic expert systems. As more knowledge-based systems are used in real-time applications demanding guaranteed response time, it is essential to predict before run-time their worst-case response time during actual execution. As we have seen in chapter 10, this static timing analysis problem is extremely difficult, even for propositional- logic-based rule-based systems, such as EQL. For predicate-logic-based rule-based systems such as those implemented in OPS5 and OPS5-style languages, very few practical static analysis approaches exist.

In our first approach, the Cheng–Tsai timing analysis methodology for OPS5 systems, a data dependency graph (ER graph) is used to facilitate most parts of the analysis. The ER graph captures all of the logical paths of a rule-based program. We use the ER graph to detect if an OPS5 program can terminate in finite execution time. More specifically, our technique detects rules that have a finite number of firings. Once nontermination is detected, we extract every cycle in the ER graph and determine the enabling conditions of the cycles. Providing the programmer with these “culprit” conditions allows extra rules to be added to correct the program.

The programmer has the option of correcting the program to remove the cycles based on these conditions, or the analysis tool can automatically add cycle-breaking rules to the program. If the programmer chooses the latter, then after finding the enabling conditions, W , of a cycle, the tool adds rule r with W as the enabling condition to the program. By doing so, once the working memory has the WMEs matching the enabling condition of a cycle, the control flow can be switched out of the cycle to r . However, to ensure that the program flow switches to r , it is modified such that r has higher priority than the regular rules. The extra rules are further refined to remove redundant conditions and rules. Note that this modification is performed off-line, prior to the execution of the expert system, and the modified version must still satisfy the logical correctness constraints.

The timing analysis problem is in general undecidable and is PSPACE-complete for programs with finite domains, as we showed in chapter 10. A static analysis strategy for tackling the analysis problem is addressed. Similar strategies have been successfully applied to the EQL language [Browne, Cheng, and Mok, 1988; Cheng et al., 1993; Cheng and Wang, 1990]. However, for complex languages such as MRL and OPS5 which have dynamic data domain size, static timing analysis may not be suitable. We developed a tool to aid in the determination of the upper bound on the program execution time. This tool has been implemented to generate a set of WMEs that cause an OPS5 program to have maximum time consumption. A selection strategy is embedded in the tool that avoids generating timing-irrelevant WMEs.

The tool also accepts users’ data to ensure that normal program flows are followed. The set of WMEs with the timing reports generated by the OPS5 system can assist the programmer in improving the timing performance. The proposed approach requires substantial programmer assistance in examining the potential cycles. In addition, the modification of the rule base to ensure termination may not be feasible in some cases. However, our approach represents a significant step toward a

SUMMARY 433

methodology for the response-time analysis of real-time rule-based systems satisfying the constraints in this chapter. Special forms may be used to characterize the class of OPS5 programs that can be successfully analyzed by the proposed tool. This classification is based on techniques developed for EQL programs [Cheng et al., 1993].

Many approaches have been proposed to improve the performance of production systems. They may be divided into three categories [Kuo and Moldovan, 1992]:

(1) speeding up the match phase by faster sequential match algorithms, (2) speeding up the match phase by parallel processing techniques, and (3) making parallel the act phase by firing multiple-rule instantiations in a production cycle. Most of these approaches either change the architecture of the production system or support parallel hardware and software to distribute the rule sets into different processors. The results of these approaches are supposed to yield a significant speedup. This high performance would then allow the production system to meet the stringent responsetime requirements although formal verification is lacking. However, parallel production systems are still in an early stage of development. Most of these approaches are evaluated only with simulation results, without actual implementation. The ability of these parallel systems to satisfy timing constraints remains unclear, so more research needs to be done.

Since our timing analysis is based on the semantic structure of the program, our strategies should also apply to these parallel architectures in order to understand their timing behaviors. A formal verification of the timing requirement of the parallel models can be based on our analysis approach. Furthermore, few attempts have been made [Zupan and Cheng, 1994a; Zupan and Cheng, 1998] to formalize the question of whether a rule-based program can be optimized. The optimization of a rule-based program is considered much cheaper than the implementation of parallel models, although we may not expect that it can gain as much speedup as the parallel models can. It also should be an important research issue.

Another issue is to extend the proposed techniques to analyze expert systems implemented in more recent and powerful rule-based languages. These newer languages [Forgy, 1985] incorporate new conflict resolution strategies and procedural/objectoriented styles similar to non-rule-based languages. Our initial assessment is that modification of the proposed techniques is needed to handle different conflict resolution strategies. However, procedural and object-oriented expert systems, by introducing abstraction and by making certain control flows explicit, are easier to analyze [Shaw, 1989] than pure rule-based expert systems.

Our second approach, the Cheng–Chen timing analysis methodology, makes a significant contribution to the state-of-the-art for solving this static timing analysis problem by presenting a formal framework for worst-case response-time prediction of a class of OPS5 and OPS5-style production systems. The proposed analysis techniques are based on (1) the detection of termination conditions, which can be checked by a semantic analysis of the relationships among rules in a rulebase, and (2) the systematic trace of tokens in the match network. These techniques are more efficient than those that rely on longest-path analysis in a state-transition system corresponding to a given rule-based system.

434 TIMING ANALYSIS OF PREDICATE-LOGIC RULE-BASED SYSTEMS

Considering the difficulty of the timing analysis problem, this methodology provides a collection of practical techniques, implemented as a tool set, to determine an upper bound on the execution time of a class of OPS5 and OPS5-style rule-based programs. This upper bound is expressed in terms of the number of total rule firings and in terms of the number of comparisons made during each matching to determine fireable rules. The second metric is particularly important since 90% of the execution time is spent in the match phase. The execution time analysis is performed without actually running the program being analyzed. The predicted execution times and associated results can be used to optimize the program to speed its execution. In general, this analysis problem is undecidable. The fact that we are able to analyze standard benchmark programs indicates the tool set’s practicality. As a first significant step to solve the static analysis problem for OPS5 programs, we present four termination conditions for OPS5 programs which are used to determine whether a program terminates in a finite time. These conditions can be checked by a fast semantic analysis rather than a state-space analysis of the programs. Then we analyze the response time only when a program has been found to be acyclic (no loop(s) in the program).

In particular, it is found that if the rule-triggering pattern of an OPS5 program satisfies one of the observed conditions, the execution of this program always terminates in bounded time. An algorithm used to compute upper bounds on the number of recognize–act cycles during the executions of programs with acyclic rule triggering patterns has been developed. We also present an algorithm to compute upper bounds on the numbers of comparisons made by the Rete network during execution. From our experience, the upper bounds obtained by Algorithm A seem to be fairly good, but the same statement cannot be made of Algorithm M. A more accurate estimation method of the numbers of tokens maintained in two-input nodes needs to be developed.

We also show how the proposed algorithms can be applied to a class of programs with cyclic rule-triggering patterns. Due to the lack of run-time information, our analysis tool takes a conservative approach in determining the satisfiability of condition elements, and, as a result of this approach, the potential instantiation graph produced by our tool usually contains a large number of nonexistent edges/cycles. Furthermore, for the same reason, it is not realistic to try to develop an algorithm to compute the response time of OPS5 programs with cyclic potential rule firing patterns. Instead, we show how the programmer can help detect nonexistent edges/cycles in the potential instantiation graph. Given that fully automated analysis tools are extremely difficult to develop, our tool set assists the programmer by focusing on rule sets with potentially high run-time costs.

We are currently looking at other characteristics of production systems, such as rule dis-triggering patterns, to see if these characteristics can be exploited to improve the presented algorithms. We plan to expand the applicability of the algorithm to programs with cyclic rule-triggering patterns. The development of new termination conditions is also under way. Furthermore, we also plan to extend Algorithm M to analyze the execution time of the recently introduced Rete II match algorithm used in OPS/R2 [Forgy, 1985]. We believe that the way in which Algorithm M painstakingly

Соседние файлы в предмете Электротехника