|
|
|
|||
|
Reaction
Rules
|
|
|
So, in a sense, rule-based systems are already to some extent event-driven. As we saw when we first talked about rule-based systems, the rules have a left-hand side, consisting of the conditions under which the rule is supposed to operate, and a right-hand side, consisting of the actions that it is supposed to perform. The rule responds to the events listed on its left-hand side, and the Rete algorithm ensures that this happens in an efficient. Yet this is not always going to be enough. As we saw in the last edition on real time AI, there are times when a system has to operate under well-defined time constraints-that is, deadlines. How can we guarantee this in a rule-based system? One way is through the concept of "salience". The reaction rules-the ones which need to respond to particular events-are given a higher salience than other rules. Thus, when the Rete network (this is another term for the Rete algorithm) identifies a number of rules which potentially can execute at a given time, the higher salience ones are given priority. This can work well under certain circumstances, where all that is needed is the ability to respond quickly. Yet there can be other circumstances where there is a well-defined deadline-you want to respond quickly, but not too quickly. How can a reaction rule take this into account? Well, it can do so by establishing a particular deadline by which it needs to have a response. Then, when the deadline is reached, a second reaction rule is executed taking action. Let's illustrate this point with a simple example:
These are reaction rules (simplified for purposes of illustration) that might appear in an electronic marketplace for buying and selling stocks. In the first rule, "consider-offer", an offer comes in from another player offering to buy a stock (which we own) at 50.00. At the present time, we actually consider the fair value of the stock to be 49.9375, so this looks like a good deal for us. However, let's say the rules of this particular marketplace mean that an offer remains open for 5 seconds. It isn't necessarily to our advantage to act immediately. So instead we establish a deadline of 5 seconds in the future (by which time we have to act), and we also note that our current decision would be to sell. In the second rule, "accept-offer", five seconds have elapsed, and if nothing has changed, we do at this point decide to sell. So if nothing happens, we will sell in five seconds. But this allows for the possibility that another rule (not shown here) might execute in the meantime, changing our decision. The biggest difference between these reaction rules and more standard rules is that they have a clear concept of time. Otherwise they can fit into a standard rule based system. Existing Rete technology doesn't necessarily handle time-based issues in an especially efficient manner; however, it would probably not be too difficult to extend the Rete approach to deal with time in as clear a manner as it handles everything else. More information about Rete networks may be found at the Jess homepage. This site explains Rete (which is Latin for "net") from the context of the Jess language, which we've talked about in earlier editions. Jess is one AI language that uses Rete, but it is certainly not the only one. The rules given in the examples above are intended to look more or less like Jess. |
|
||||||||||||||||||||||||||
| Home | ||||||||||||||||||||||||||||
|
Home: Ramalila.NET
|
![]() |
|
Legals: |