Expert Systems With Applications, Vol. 10, No. 3/4, pp. 449--455, 1996 Copyright © 1996 Elsevier Science Lid Printed in Great Britain. All rights reserved 0957-4174/96 $15.00+ 0.00
Pergamon
S0957-4174(96)00024.3
TRmTemporal Reasoner CHAI
QUEt
IntelligentSystemsLaboratory,Schoolof Applied Science,NanyangTechnologicalUniversity,NanyangAvenue,Singapore639798
WEE-CHEE SIM InformationTechnologyInstitute, 11 SciencePark Road, SingaporeSciencePark II, Singapore 117685
Abstract--A constraint-based qualitative reasoning system that integrates Allen's interval calculus, point calculus and part of Simmons' quantity lattice is presented in this paper. The highlight of the work is a simple but powerful logical system for expressing both quantitative and qualitative information managed by a temporal manager (TM). Allen's algorithm, which deals with time intervals, is extended to reason about time points. The hybrid method of propagating temporal constraints permits flexible control over both systems. We try to offset the limitations of an interval-based representation by the advantages of a point-based representation. Copyright © 1996 Elsevier Science Ltd
1. INTRODUCTION
represents an interval that begins and ends, and that occurs continuously between the endpoints.
incorporate temporal reasoning in various applications of qualitative reasoning (QR) led researchers to propose different representation schemes for temporal information. A natural way to encode temporal information is through the use of time point as well as time interval. Representation in time point is used to refer to a temporal event that requires descriptive precision by providing a quantitative or numerical representation of time. This usually involves making references to a calendar or a clock (depending on the resolution required). However, such references are not usually available; in such cases time intervals are used to give qualitative representations. When the exact knowledge of a set of temporal constraints between two events cannot be known specifically, time interval provides a qualitative disjunctive description of Allen's thirteen temporal constraints (Allen, 1983); and time points can be used to refine this set of temporal constraints when numerical information is available. T H E INCREASING NEED t o
Characteristics Important characteristics that are relevant to TR's approach to temporal representation are: • Flexibility. T R accepts two methods of input: (a)
disjunctive constraints between two events and (b) absolute dates of events. The former is less precise but provides a qualitative description. The latter is more specific and thus refines the former's representation. • Persistence. TR facilitates default reasoning of persistence assumptions as the premises of temporal constraints remain true until further information is obtained. • Granularity. T R allows both coarse and fine representation t of absolute dates. For example, a calendar gives coarse references while a clock gives fine references. • Imprecision. When absolute dates of events are not available, relative temporal knowledge is
Definition of Event An event is defined as a time duration that is enclosed by a pair of time points, namely the start point and the end point. If the two endpoints have equal quantitative values, then the event represents a specific time instance, or time point. If the two endpoints are different in value, with the start point less than the end point, then the event
~Coarse and fine representations are denoted by the common tuple [yymmddhhmmss, yymmddhhmmss]. In this case, coarse representations can be expressed in terms of years while fine representations can be expressed in terms of seconds.
449
450
C Quek et al. also accepted in the form of disjunctive qualitative representation. • Uncertainty. Incomplete temporal knowledge can be represented in disjunctive relations in both interval and point calculi, though the set of constraints used in each calculus is different.
instruct point calculus to pre-process them before sending for updating. The quantitative values of the respective intervals are stored in a structure that collaborates closely with the directed graph. The input map is responsible for mapping the tuples representing either qualitative information or quantitative information and forwarding them to the TM.
2. OVERVIEW The main contribution of TR is to provide an absolute dating mechanism to interval calculus. The inclusion of time points as in the absolute dating mechanism provides O(1) time algorithms for comparing time and uses only linear space in the number of events represented. Time comparisons are thus reduced to simple numeric comparisons. Also, the duration of time between events or the duration of an event can be easily inferred--simply subtract the date/time of the earlier event from the date/ time of the later one. In contrast, the homogeneous interval calculus runs to completion in an estimate of O(n 3) time and requires O(n 2) space. The integration of interval calculus and point calculus within TR complement each other. Interval calculus is not capable of handling numerical time points. Also, without a point-based system, the resolution of a temporal reasoner is inflexible. Hence, point calculus is introduced to address these setbacks. However, point calculus as a standalone is too rigid as references to a calendar or a clock are not usually available. Thus, interval calculus is required to allow the specification of incomplete temporal knowledge through disjunctive qualitative relations. 3. A R C H I T E C T U R E TR adopts an onion-style architecture. It is strictly modular in the way information is abstracted from one enclosing level to another as shown in Fig. 1. On receiving qualitative values from the input map, the temporal manager (TM) passes them to interval calculus to be updated directly in the directed graph. On the other hand, when quantitative values are received, the TM will
4. T E M P O R A L M A N A G E R The role of a TM in a temporal reasoning system is to achieve the following tasks: Retrieval. To find whether two events in the knowledge base of temporal relations are temporally related and how. Updating. To add or remove events and temporal relations from the knowledge base while maintaining its consistency. Any addition or removal that results in inconsistency is rejected. Figure 2 depicts the structure of the temporal manager. The interval and point calculi are two different representations for encoding temporal information. Both calculi communicate with the constraint propagation algorithm (CPA) directly. However, point calculus requires the quantity lattice (Simmons, 1986) to perform translation from point-based information to intervalbased information. New temporal assertions generated by CPA are updated in the directed graph, the cache for temporal information. Interval Calculus Allen's interval calculus (Allen, 1983), which deals solely with time intervals, is extended to reasoning about time points (point calculus). Given possibly indefinite knowledge of the relations between some events, how do we compute the strongest possible assertions about the relations between some or all events? Determining the exact solutions to this problem has been shown to be NPhard (Vilain & Kautz, 1986). Allen's interval calculus
InputMap TemporalManager
l
FIGURE 1. Architecture of TRAINER.
Comtr~utP~opagatioaAlgontlan
J
FIGURE 2. Structure of the temporal manager.
Temporal Reasoner gives an approximate solution to this problem using a three-consistency algorithm, based on constraint propagation, that is guaranteed polynomial (van Beek, 1989).
451 TABLE 1 Composition Table for Point Calculus X
<
=
>
Point Calculus
<
<
<
no info t
=
<
=
>
By limiting the expressive power of the representation language, we have a special case where the approximation algorithm is exact. Even though Allen's interval calculus has very good expressive power, it lacks computational efficiency for propagating constraints and for incremental updates of the temporal network. The computational time complexity of both tasks are found to be O(n 3) (van Beck, 1989). Further, exact time 2 cannot be easily incorporated within an interval-based system since exact time is related to time points. This leads to the development of point calculus within TR to model time points. Temporal relations between two intervals can be deduced from the values of their respective end points. This is the basis on which the interval calculus is extended to handle relations between two time points, or relations between a point and an interval. However, this may seem to be a translation from exact information (values of endpoints) to interval information (one of Allen's thirteen primitives). Since TR is designed to be a hybrid method that will handle incomplete temporal information, such translation is inevitable for three reasons. Firstly, this implies we can propagate the newly asserted quantitative values of an event to the other events in the temporal network without precisely knowing the end point values of these events. Secondly, although numerical information leads to more precision, however, very often not all numerical information of all events is available and thus qualitative reasoning is required for its expressive power of incomplete knowledge. Thirdly, the added value of qualitative reasoning lies in the guaranteed coverage of all possible temporal relationships among events.
>
no Jnfo
>
>
Quantity Lattice Simmons' quantity lattice is incorporated in TR to implement an inequality reasoner. The quantity lattice allows users to assert supplemental data, which are real values, to bind the durations of the intervals. It is also responsible for maintaining the consistency of temporal information in the directed graph. A major requirement is to encapsulate the mechanism of the quantity lattice from the TM by providing a set of general purpose functions which control access to the directed graph. The quantity lattice can be thought of as a refinement tool to the temporal network that is originally managed by the interval calculus. Its usage has also been extended to maintain a consistent partial order of time points and to 2 Exact time refers to the numerical time point values.
* As in Allen (1983), "no info" denotes the tautological relation consisting of the union of the three primitives {<, >, =}.
answer queries about relationships between time points. Two types of inferences are performed on Simmons' quantity lattice (Simmons, 1989), namely, determining the relationship between two quantities and constraining the value of an arithmetic expression. Only the former inference technique is included in TR. These inferences are carried out using graph search and numeric constraint propagation.
(I) Graph Search One of the techniques to determine the relationships between two events is by searching the temporal network containing these events. This technique is inherently qualitative. By restricting the arc labels to { <, >, = }, the point calculus can be defined in much the same way as interval calculus. This argument is further supported by Ligozat (1991). He stated that the subset of relations in Allen's interval calculus could be translated into constraints on the endpoints of { <, >, ~<, I>, = }. However, "~<" and "I>" are abbreviations of { <, = } and { >, = }, respectively. Moreover, both abbreviations possess the disjunctive meaning conforming to Allen's. Hence in TR, such repetition is streamlined to only { <, >, = }. Like interval calculus, point calculus possesses intersection and composition operations as defined in (van Beek, 1989). Unlike interval calculus, point calculus has a smaller composition table, given in Table I, where composition is defined over three inequality relations instead of Allen's thirteen primitives. The inclusion of time points along with intervals in the domain of TR minimally complicates the CPA which is based on Allen's algorithm (Allen, 1983). Only the following need to be changed: • interval vector intersections and compositions by point intersections and compositions • interval assertions by point assertions • interval-based composition table by point-based composition table. The above modifications show that there is a one-to-one mapping from interval-based operations to point-based operations. In addition, Valdrs-Prrez (1987) showed that temporal networks that are not labelled with disjunctions can be solved in O(n 3) time using the CPA. Tsang (1987) also stated that by avoiding reasoning with disjunctive
452
relations, a point-based system achieves completeness in the CPA. Ligozat (1991) expressed that the algorithm is complete when restricted to { <, >, = }. Real numbers are used to model time points. A model of a network of time points is simply a mapping between those time points and some corresponding real numbers (absolute dates). The relations between time points are mapped to relations between real numbers in the obvious way. For example, if time point A ÷ is before time point B - in the network, then A ÷'s corresponding number is less than B-'s. Consequently, this form of mapping results in a digraph that is not labelled with disjunctions. By incrementally providing quantitative values of the intervals in the network as more information becomes available, a consistent partial order of the endpoints of the intervals can be maintained. In such a case, the directed graph is said to possess the property of a consistent singleton labelling (van Beek, 1989). A consistent singleton labelling of the graph is defined as a labelling where it is possible to map the intervals to a time line and have the single relation between intervals hold. Hence, adopting the arguments of Ligozat (1991), Valdts-Ptrez (1987) and Tsang (1987), TR's hybrid method of propagating temporal constraints is sound: any relation that it infers between two points or between a point and an interval follows from the user's assertions. Moreover, the algorithm is complete. When it terminates, the closure of the assertions will have been correctly computed.
(2) Numeric Constraint Propagation Each event in the temporal network has a pair of realvalued time points associated with it. This interval represents what is known about the actual value of a symbolic event. By default it is (ur~r~owN, ur~r,Nowr~). When the value is known precisely, say on 7 January 1993, it would be represented with [19930107, 19930107] for an event with zero-width time points. For an event with non zero-width time points, if the start time point is 7 January 1993 and the end time point is 9 January 1993, then it would be [19930107, 19930109]. 3 The quantity lattice maintains the consistency of these intervals across the labelled arcs as new information arrives. It does this by numeric constraint propagation along the arcs in the directed graph. This technique is inherently quantitative. The ordering between two events can be determined if the time points associated with them are known. A numeric constraint propagator is required to determine the upper and lower bounds of events whenever a relationship is asserted between two events. The translation scheme from qualitative information to quantitative information is given in Fig. 3. For example, 3 The resolution of the time units is taken to be a day.
C. Quek et al. (B- < A-) & & (A+ < B+) (A- < B-) & & (B+ < A+)
A dudl~ B A contains B
(A- = B-) & & (B+ < A+) (B- = A-) && (A+ < B+)
A starts B A started-by B
(B- < A-) & & (A+ = B+) (A- < B-) & & (B+ = A+)
A finishes B A finished-byB
(A- < B-) && (B- < A+) && (A+ < B+) (B- < A-) & & (A- < B+) & & (B+ < A+)
A ovcdaps B A overlapped-by B
A+ = BB+=A-
A meets B A me_.t-byB
(A- = B-) & & (A+ = B+)
A equals B
FIGURE 3. Translation scheme.
if the temporal tuple A starts B is asserted, the system constrains the start time point of A to be equal to the start time point of B, and the end time point of A to be after the end time point of B. In turn, these constraints propagate to all endpoints of events in the temporal network. According to Simmons (1986), this numeric constraint propagation algorithm has the computational complexity of O(n), where n is the number of arcs in the directed graph representing the network. 5. INPUT MAP The main purpose of the input map is to provide a shield over the modules enclosed by it, which interacts directly with the user through the interfaces. It distinguishes between qualitative and quantitative inputs and transfers the corresponding temporal tuple to either the interval calculus or point calculus of the TM for maintaining the consistency of the temporal network. Currently, TR provides five templates to map user's input: • • • • •
temporal queries creation of an event in the temporal network qualitative constraints quantitative constraints duration binding. 6. APPLICATIONS
Allen (1983) introduced the interval calculus to provide a framework for the treatment of natural language processing and problem solving where temporal and tense information in sentences are extracted. Song and Cohen (1991) proposed a model for plan recognition. Chen and Chang (1990) apply interval calculus to construct a temporal logic programming environment. Poesio and Brachman (1991) developed methods for using dates (time points) as reference intervals and for meeting the challenge of repeated activities. In Simmons (1986), Simmons stated that the quantity lattice is useful in doing simulation and analysis in several domains, including geology and semiconductor fabrication, by supporting useful forms of reasoning about time and the changes that happen when processes occur. TR is a QR technique that has been developed as one
Temporal Reasoner
453
of the tools in the TRAINER 4 project for building an intelligent training system for industrial environments (Sim et al., 1994a, b). It is used as an inference mechanism in temporal knowledge representation• By mapping the topics s to be taught to the events of the temporal network, TR is applied in two areas: it is capable to check the overall consistency of the tutoring agenda. Should any inconsistency arise, due to a disjoint event, it acts as an indication for replanning the agenda • having the capabilities to handle time points and durations of events allow TR to specify the agenda of a training session.
•
7. AN ILLUSTRATION The objective of this illustration is to show how TR, itself a temporal language, can be applied to the teaching of shop floor planning for factory supervisors. The operations of the printed circuit sub-assembly for surface mount components are specifically adopted to aid this illustration. This sequence of operations is depicted in Fig. 4. For simplicity, all bad components are discarded regardless of how near they are to completion. Some difficulties of shop floor planning with respect to printed circuit board (PCB) mounting are identified: • •
variations of the supply of resources changes in demand for the product
I ~
Receivedblank PCB. Inspect for obviousdefects like (a) open, (b) short, and (c) cosmetic Apply (a)masklngliquid,and (b)masldng tape to the requiredarea. Load co.m.p.o. nents
~ect
usingautomaticinsertionmadame,
b a ~ eject
•
deviations in the delivery date line of the product.
Shortages in the supplies of resources can be a consequence of (a) resignation of human operators or (b) delay in the supply of materials required. For example, the supply of blank PCBs, masking tape, masking liquid and electronic components may fall behind schedule. Cancellations of orders will cause the level of demand of the product to fall, while the placing of more orders causes the level of demand to rise. Changes in the date line for delivery is also not uncommon. Hence, given such a highly dynamic situation of shop floor planning, it is necessary to teach scheduling skills in resource planning to the factory supervisors. Being presented with a description similar to that of Fig. 4, the factory supervisor is first asked to plan the operations of the sub-assembly accordingly. Starting with the main operations shown, the supervisor is to decompose each block to subsequent sub-operations. Hence, a hierarchical structure is imposed and the notion of reference events (Allen, 1983) is introduced. Likewise, based on the same description, an intelligent tutoring system (ITS) where TR is incorporated will construct its domain knowledge base consisting of temporal relations among the main operations and their sub operations. In addition, a support knowledge base will also be needed in the ITS so that multiple scenarios can be generated simply by altering the availabilty of resources, changing the date line or the durations of events at various stages. Hence, the plan generated by the supervisor not only has to be sequenced correctly according to time, it has to consider the amount of resources available at each state of the operation. Figure 5(a) shows a scenario where the objective is to use minimum manpower, while Fig. 5(b) depicts a case where the goal is to complete the production in the
Inspectallloadedcomponentsbeforenext stage. Solder,wash,and rezr~ovemaskingtape,
, OPl • "om I ;o,$,c, :
eject b a ~
OP3
: ,
,6--] Visual inspection.
oP4, OP5 :w;
! &
I I
ba~g~"~ eject
In-circuittesting.
O I pT.. "o1~.
O: OPEN $: SHORT C: COSIqL:TIC kfr: MASK~IGTAPE lvL MASKINGI.JQUID L: L O A D ~ $0: SOLI)I~]~IG w: WASHING I~ REMOVETAPE
'0P2
' a ~ Shipment.
FIGURE 4. Operations of printed circuit sub-assembly for surface mount components.
4TRAINER is a collaborative research project between Nanyang TechnologicalUniversity (NTU), School of Applied Scienceand the National Computer Board, Information Technology Institute. The authors would like to acknowledgethe supportand fundingby NTU. s The knowledgeof the subjectarea and its respectivetopics which the system wants to get across to the student are containedin the domain expert moduleof an intelligenttutoringsystem.
°P6
(a)
lop3, : .a. ', • 0P4 ,
I
(b)
OP6
, :O1~• "O1'8.
FIGURE 5. Two scenarios in planning.
454
C Quek et al.
shortest possible time. Figure 5(b) may also be generated to demonstrate the case when the level of demand increases. In order to speed up production to meet the targeted amount, the supervisor is required to channel more resources (human operators) for production. The scenario of moving forward the date line of production can also be explained by Fig. 5(b). Suppose the supervisor had ordered the main operations correctly by specifying the temporal relations as "OPi is before or meets OPj", 6 where i2) Depending on the resources available (human operators in this case) the student can plan the sequence of the sub-operations in at least three ways, these are depicted in Fig. 6. The ITS will compare the student's actions with TR's inferences and at the same time make reference to the resource state so as to determine the feasibility of the supervisor's actions. By computing the error function of the student's actions and the expected actions, relevant messages will be shown. Whenever an endpoint value is available, this quantitative fact is propagated by the numeric constraint propagator to all endpoints in the network. For example, OPEN
I
I
3 operators are needed as the threeh~oeoing proce~fes have to be done cou~lrently
COSMETIC
(a)
I
I
SHORT
I
! 2 openttccs are needed as one opexat~ a l ~ finishedimgecttng OPEN, can
OPEN
I
I
proceeded to inspect ~IORT. while the other opea'a~ inspects COSMETIC
COSMETIC
~)
I
I SHORT
I
(c)
I
OPEN
I
1 oI0erat(xisneeded as the three inspection procedures ate dope
CO~;~L~['IIC ~-IORT
I
I
one after ano~er
I
if we adopt the plan of Fig. 6(a) and assert the end time point of COSMETIC to be [000010], 9 this quantitative value will be propagated, thus constraining the end time point of O1>2to be equal to [000010], the start time point of OP 3 to be equal to or after [000010], the start time point of O1)4 to be after [000010], and so on. Say, at this point of time, we know the duration of OP 3 is 75 time units. This fact will be kept by the system, or else it will be propagated by the numeric constraint propagator if it is able to. This is because the numeric constraint propagator requires the start time point value of O1)3 before it can infer the end time point of O P 3 using the value of the duration of OP3. In this case, the numeric constraint propagator is able to infer that the start time point of OP4 is equal to or after [000085]. Earlier on, we had already constrained the start time point of OP4 to be after [000010]. By direct numerical comparison, the system infers that the start time point of OP, should be equal to or after [000085] in order to satisfy both constraints. This fact is again propagated to the other endpoints in the network. In this illustration, we have highlighted the following properties of TR: • ability to teach planning in conjunction with resource availability • flexibility in handling indefinite knowledge • achieve precision through absolute dating mechanism • numeric constraint propagation of point-based values, including the propagation of duration of events. 8. C O N C L U S I O N TR provides a hybrid temporal reasoning platform resulting from the integration of the interval calculus in Allen's work (Allen, 1983) and Simmons' quantity lattice (Simmons, 1986). This paper has also described an approach for designing a temporal manager that has some interesting properties: • it relies on a combined calculus that gives the same expressive power as Allen's interval calculus • the constraint propagation is sound and complete for computing consistency and consequences of assertions in the point calculus • it operates in O ( n 3) time and O(n 2) space.
FIGURE 6. Planning under constraints of resources.
REFERENCES 6oPi denotes main operation 'T' as inidicated in Fig. 4. 7In Allen (1983), Allen groupedthe relations contains, started-byand finished-byand called them the containmentrelation. However,he did not address the issue of how this relation can be applied. 8The converseis not true. An eventA having the containment relation with another event B does not designate B to be the referenceevent of A.
Allen, J. F. (1983). Maintaining knowledge about temporal intervals. Communications of the ACM, 26, 832-843. van Beek,P. (1989). Approximationalgorithmsfor temporalreasoning. 9 [000010] is just an arbitrary time unit to simplify illustration in the example.
Temporal Reasoner In Proceedings of the Eleventh International Joint Conference on Artificial Intelligence, Vol. 2, pp. 1291-1296. Chen, H. H. & Chang, C. H. (1990). IB-TEMLOG: An interval-based temporal logic language. In Proceedings of the 4th Australian Joint Conference on Artificial Intelligence, pp. 21-23. Ligozat, G. (1991). On generalized interval calculi. In Proceedings of AAA1-91, pp. 234-240. Poesio, M. & Brachman, R. J. (1991). Metric constraints for maintaining appointments: dates and repeated activities. In Proceedings of AAAI-91, pp. 253-259. Sim, W. C., Looi, C. K. & Quek, H. C. (1994a). A 2D framework of qualitative and quantitative models for an intelligent training system. In Proceedings of the East-West International Conference on Computer Technologies in Education (EW-ED '94), pt 2, pp. 95-98, Ukraine. Sire, W. C., Looi, C. K. & Quek, H. C. (1994b). Model switching techniques in an intelligent training system for an industrial
455 environment. In Proceedings of the Second Singapore International Conference on Intelligent Systems (SPICIS '94), pp. B91-B96, Singapore. Simmons, R. (1986). Commonsense arithmetic reasoning. In Proceedings of the 5th National Conference of Artificial lntelligence, Vol. 1, pp. 118-124. Song, E & Cohen, R. (1991). Temporal reasoning during plant recognition. In Proceedings of AAAI-91, pp. 247-252. Tsaing, E. P. K. (1987). The consistent labeling problem in temporal reasoning. In Proceedings of the 6th National Conference on Artificial Intelligence, Vol. 1, pp. 251-255. Vald~s-P~rez, R. E. (1987). The satisfiability of temporal constraint networks. In Proceedings of the 6th National Conference on Artificial Intelligence, Vol. 1, pp. 250-260. Vilain, M. & Kautz, H. (1986). Constraint propagation algorithms for temporal reasoning. In Proceedings of the 5th National Conference on Artificial Intelligence, Vol. 1, pp. 377-382.