Application of rule-based systems, decision tables, and decision trees in state monitoring, situation classification (situation assessment) and decision support is similar from both technical point of view and intended aims. All of the mentioned tools are working according to similar principles and differ mainly with respect to internal knowledge representation scheme and details concerning inference control mechanism. Hence, in many application the selection of particular tool is arbitrary, and may depend on individual preferences, size of the problem to be solved, type of underlying logic (propositional vs. predicate logic), etc. However, the main basic scheme of operation remain the same: for a given input state description, find the appropriate pattern matching it (rule precondition, condition part of decision table or sequence of conditions in a decision tree), and finally select the appropriate item (rule of rule-based system, row or column of a decision table, decision path in decision tree) and execute it. The basic mode of work is illustrated with the figure below.
Thus the basic scheme of operation is the same for all of the discussed tools. Below some particular problem concerning implementation and application will be presented. We start with situation recognition or situation assessment which is also the basic mechanism checking if and which rule preconditions, decision table conditional part or decision tree sequence recognition.
It is possible to use a combination of knowledge representation formalisms - in such a case the formulae representing the total information should be composed of separate parts expressed with use of a single formalism. For simplicity of the discussion we assume that one of the formalism has been chosen. The extension to simultaneous use of several formalism (knowledge representation language) is straightforward.
The basic assumption is that the state of the system is monitored, and
with respect to the application of an appropriate signal-to-symbol transformation
approach a formula describing current state is formed at certain time intervals.
Such a formula -- to be denoted with
- keeps the information about current state, i.e. systems parameters, relations
holding, etc. for an assumed duration of time, sometimes referred to as
time
window. Note that in fact it is not necessary to write the formula
explicitly - certain components should be just accessible if necessary.
Now let us suppose that for identification of specific situations or
(preconditions, failures, etc.) of the considered system a set of formulae
defining (and simultaneously describing) certain expected ones was defined.
Let be a set of situation
formulae defining possible situations of interest and let
,
where each
is a situation
formula defining certain type of situation.
The problem of identifying specific situation defined with formula
can be now replaced by checking if this formula generalises a formula
describing current state, i.e. if
Note that most of the above features are in one or another way represented
and dealt with in any knowledge-based control and supervision systems.
The paper [Laffey et al, 1988]
outlines about fifty different applications ranging from aeronautical and
space systems to communication, financial, medical, and automatic control
applications, including robotic and autonomous vehicle implementations.
One of a most appealing examples consists of a real-time expert system
controlling a robot ping-pong player.
A number of applications in more classical domains of automatic control are reported as well. In some review papers applications of knowledge-based systems to expert supervisory control, supervision, diagnosis, and control in the domain of automatics are reported [Tzafestas, 1987], [Tzafestas, 1989], [Tzafestas 1989a]. Example applications include self-tuning PID controller, a rule-based self-tuning supervisor, an expert system for distillation control synthesis, and expert supervisory control of a turbo-charged diesel engine.
For the above problems one cannot provide a general theory and practical
solutions depend on the specific problem. Moreover, the presented above
classification referring to the structure of supervision systems is to
a high degree a matter of convention. In fact, all the problems are strongly
interconnected and selection of a solution to certain problems in one of
the above-indicated groups can project on and significantly influence the
solutions of other problems in different groups. Among the areas of mutual
penetration one can distinguish at least two of great importance. First,
the input and output problems interleave with the knowledge representation
ones, and second, the knowledge representation problems influence the solutions
of reasoning problems.
The input and output problems are to certain degree similar, since both of them concern the problems of interface between knowledge-based supervision system and environment. Practical solutions depend on the character of signals (electrical, mechanical, chemical, biological, etc.), acquisition possibility (detection, measurement, observation, etc.), possibility of performing control actions, accessible sensors and actuators, required accuracy, etc. Practical solutions may include the application of abundant variety of instruments used in classical and non-classical automatic control, including cameras and image processing and interpretation systems for input, as well as robotic or manipulator systems capable of performing complex mechanical operations for output.
Knowledge representation problems are strongly interconnected with reasoning problems. The basic problem of knowledge representation concerns the practical representation of state formulae. The theoretical introduction and presentation in Chapter 4 and 6 provides only a general framework which should be adjusted to any specific case.
Note that with regard to the above mentioned rough classification
of facts only the ones belonging to the first two groups should be necessarily
explicitly represented in the knowledge base. It may be unreasonable to
keep the input facts and input user facts in the memory, since any time
they are necessary they can be `read' from the input interface and the
user can be simply asked for them. Finally, deducible, mathematical, and
domain-specific facts can be generated according to current needs with
use of special inference mechanisms, and probably this would be more efficient
than keeping them all the time in the knowledge-base. Using such a partially
implicit knowledge representation scheme can significantly contribute to
saving the memory required for state representation. Simultaneously, it
can speed up execution, since generation of certain facts can be faster
than search for them in a large knowledge base and the time required for
knowledge base actualisation is significantly reduced. However, implicit
knowledge provides additional problems for reasoning mechanism, and particularly
for the matching procedures. In case some facts are represented implicitly,
direct matching of facts included in some simple formula (possibly the
one describing preconditions of some transformation rule) against state
formula is no longer satisfactory -- specialised matching procedures covering
the generation of implicit facts are required. In general, a trade-off
between explicit and implicit knowledge representation must be considered
and various factors should be taken into account.
For practical considerations the following types of facts have been
selected:
As an example it is shown how the above facts are encoded as terms
of some meta-facts being Prolog clauses. Any such fact can have a number
of arguments apart from the term encoding the logical formula; for the
example implementation we have chosen three arguments: type of the
logical fact (as above), atom, i.e. the appropriate logical formula,
and its current truth-value. The following extract from Prolog program
shows the appropriate structure.
{ *** Types of facts *** }
{
state - specified by the state formula
control - special facts specifying state of the controller
memory
user - specified by the user
input - to be read as input data
infer - fact to be inferred according to given rules
special - interpreted according to special rules
The form of any fact in database is:
fact(<type>,<atom>,<truth-value>).
and f(<type>,<atom>) for preconditions,
where:
<type> = one of the above types,
<atom> = specification of the atomic formula defining the
fact,
<truth_value> = current status; true/false.
}
To summarise, one cannot expect a single, universal solution providing a consistent approach to solving practical implementation problems. Further, only the most obvious ones were roughly sketched out in this section. In the following subsections an attempt at analysis of certain particular problems and putting forward some practical guidelines was undertaken. Some of the considerations are supported with simple examples of practical applications.
The above scheme outlines the basic algorithm of reasoning in a
knowledge-based control system. The main modifications incorporated in
practical applications may concern the following problems:
Segmentation of rule-base is a commonly used paradigm in a number
of different knowledge based systems. The main goal of such segmentation
is to reduce the number of rules considered at a time by temporal putting
aside the rules which are not applicable. The key to select the rules is
the current context. In control systems the context may be defined
with regard to the mode of operation, such as for example automatic,
semi_automatic,
manual_control,
etc. Another factor used for determining the context can take into account
the current status of operation, for example normal_operation,
start,
stop,
emergency,
failure,
diagnosis,
etc. Note that within a context
it is possible to distinguish several subcontexts, and thus perform further
segmentation. In this way a natural hierarchy in the set of rules is introduced.
The reasoning control mechanism works then in a hierarchical way as well
-- it is first to determine the appropriate context (and possibly - subcontext),
and next - perform
standard search and activation cycle taking into account only the limited to the determined context set of rules. Such an approach provides the possibility to speed up execution, but is also important for making the rule-base much more transparent to the user, and thus easier to understand, supervise, modify and debug.
Conflict resolution mechanisms are usually based on some arbitrary assumptions
(such as that the order of rules indicates simultaneously the hierarchy
of execution; such an approach constitutes one of the principles of Prolog
programming language), or some heuristic rules, for example assigning some
numerical priorities to rules. In general, the most typical conflict resolution
mechanisms operate with respect to the following possible principles:
Of course, a realistic system can combine the above approaches and
still use some other ones. However, no general solution can be suggested
since the design and implementation of reasoning control is a highly specialised,
domain-specific task.
As an illustration, the basic implemented strategy is a linear search of rules with execution of he first rule found; after execution of the rule the search cycle is repeated. The order of rules specification is equivalent to establishing priorities - the first rule has the highest priority, the second one lower, etc. A simplest implementation can be as follows:
run:-
repeat,
findrule(_Number),
executerule(_Number),
test,!.
findrule(_Number):-
rule(_Number,_,_Preconditions,_,_,_),
consistent(_Preconditions),!.
executerule(_Number):-
rule(_Number,_,_Preconditions,_,_Dels,_Adds),
consistent(_Preconditions),
remove(_Dels),
add(_Adds).
test:-
rule(1,_,_Preconditions,_,_,_),
consistent(_Preconditions).
remove([]):- !.
remove([_F|_T]):- retract(fact(_F)),remove(_T).
add([]):- !.
add([_F|_T]):- assert(fact(_F)),add(_T).
The simplest version of a rule interpreter as presented above uses simplified rule format and the simplest test for rule preconditions. Another version of a rule interpreter for linear search an execution of first rule found is listed below.
run:-
write('LOOP'),nl,
findrule(_Number,_Name,_Preconditions,_Negative_preconditions),
executerule(_Number,_Name,_Preconditions,_Negative_preconditions),
!,
run.
run:-
nl,nl,nl, write('No rule applicable; operation halted').
findrule(_Number,_Name,_Preconditions,_Negative_preconditions):-
rule(_Number,_Name,_,_Preconditions,_Negative_preconditions,_,_,_,_,_),
write('Find rule: testing preconditions: '), write(_Number),nl,
satisfied(_Preconditions),
unsatisfied(_Negative_preconditions).
executerule(_Number,_Name,_Preconditions,_Negative_preconditions):-
rule(_Number,_Name,_,_Preconditions,_Negative_preconditions,
_Action,_Delete_results,_Add_results,_Message,_Next_rules),
write('Exec rule: No testing of preconditions: '), write(_Number),nl,
{satisfied(_Preconditions),
unsatisfied(_Negative_preconditions), }
write('Action executed: '),write(_Action),nl,
remove(_Delete_results),
add(_Add_results),
write(' *** INFO *** '),nl,write(_Message),nl.
remove([]):- !.
remove([f(_Type,_Term)|_T]):-
retract(fact(_Type,_Term,_)),remove(_T).
add([]):- !.
add([f(_Type,_Term)|_T]):-
write(_Type),write(' '), write(_Term),nl,
process(f(_Type,_Term),f(_Type,_New_term)),
write(f(_Type,_New_term)),nl,
assert(fact(_Type,_New_term,true)),add(_T).
process(f(state,angle(plus(_Angle,_Alpha))),f(state,angle(_New_angle))):-
data(_Alpha,_Given),
write(_Given),nl,
_New_angle is _Angle + _Given,
write(_New_angle),nl,!.
process(_Term,_Term).
This version does not test the preconditions of a rule found twice and incorporates different scheme of loop in Prolog.
In the work [Ligeza, 1993] a modification of the basic interpretation algorithm allowing for flexible switching among rules has been proposed. The idea is that if domain expert knowledge about plausible dynamic reordering of rules is available, it can be encoded with use of the next part of rules. The meaning of this specification is as follows: if, after execution of some rule it is likely/reasonable to try execution of a given sequence of
rules, the basic linear search can be temporarily abandoned and the specified rules can be tried first. This mechanism allows for very flexible and general reordering of rule execution. In fact, a dynamic LIFO (last in first out) queue is incorporated in the reasoning control mechanism. A ''two-level'' interpreter performing the search and execution according to this strategy can be as follows:
run:-
write('LOOP NEXT RULES'),nl,
pick(_Number),
findrule(_Number,_Name,_Preconditions,_Negative_preconditions),
executerule(_Number,_Name,_Preconditions,_Negative_preconditions),
!,
run.
run:-
next([]),
write('LOOP LINEAR'),nl,
findrule(_Number,_Name,_Preconditions,_Negative_preconditions),
executerule(_Number,_Name,_Preconditions,_Negative_preconditions),
!,
run.
run:-
nl,nl,nl, write('No rule applicable; operation halted').
pick(_Number):-
next([]),!,fail.
pick(_Number):-
retract(next([_First|_Rest])),
eq(_Number,_First),
assert(next(_Rest)).
pick(_Number):- pick(_Number).
\end{verbatim}
For correct execution the queue next/1 must be initialised, e.g. by an empty list specification.
Another modification and extension of the proposed mechanism can consist
in assigning the rules numerical priorities and dynamic modifications of
them. This can be done by specifying a proper function in the next section
of any rule; then the rules can be ordered for any cycle of search with
respect to current priorities.