start:- available(snape,1,3), available(dumbledore,2,4),
available(potter,1,3), available(grange,1,5),
req(potter,dumbledore), req(potter,snape),
req(snape,grange), req(grange,dumbledore).
We can form the concept of free timeslots from the interval definitions of availability:
available(Person,T1,T) <=> T1 = T | true.
available(Person,T1,T) <=> T2 is T1+1, |
free_slot(Person,T1,T2),
available(Person,T2,T).
To schedule all required meetings we need just one rule:
free_slot(Prof,Start,End), free_slot(Par,Start,End),
req(Par,Prof) <=> meet(Prof,Par,Start,End).
To schedule all required meetings we then need only one rule:
free_slot(Prof,Start,End), free_slot(Par,Start,End),
req(Par,Prof) <=> meet(Prof,Par,Start,End).
This simplification rule says that provided that Prof and Par have the same free
timeslot, and that Par is required to meet Prof, then this information (i.e. the free
timeslots of each and the requirement to meet) will be deleted from the knowledge
store and replaced by the concept that Prof and Par must meet in that timeslot. (No-
tice that no parent will be assigned two intervals with the same professor or vice versa
since the parent’s requirement to meet that professor is removed by our simplification
rule.)
Suppose, for example, the school director wishes to see parents at random,
whether they need to meet him or not. We simply define req/2 as a property rather
than as an intervening concept, and relax it for the individual in question:
req(potter,dumbledore). req(potter,snape).
req(snape,grange). req(grange,dumbledore).
free_slot(Prof,Start,End),free_slot(Par,Start,End) <=>
acceptable(req(Par,Prof),B) | meet(Prof,Par,Start,End).
relax(req(Par,dumbledore)).
The last clause relaxes the requirement property only for Professor Dumbledore.
Duplicate meetings can be avoided using the simpagation rule:
req(X,Y) \ req(Y,X) <=> true .
(4)
This rule removes the second requirement, which is symmetric to the first if both
appear in the knowledge store.
34