Algernon Tutorial 4.c
System Design
previous index
System Design
One class that worked on this problem produced the following
design document:
- Ontology Changes
- Make a subclass of
Person
called Customer
.
- Add slot
address
from Customer
to String
.
Use slot phone_number
on Customer.
- Create a slot
advertisements
from Customer
to Advertisement
.
- Create a
cost
slot from Advertisement
to Float
.
Calculate its value based on the number of words in the ad.
- Make a new subclass of
Transaction
called Payment
.
- Create a slot
payments
from Customer
to Payment
.
- Create new transaction slots:
amount
, Date
.
- Create a
Balance
slot from Customer
to Number
.
- Create a
rate_per_word
slot from Advertisement
to Float
.
- Later, we realized we also needed:
- A
content_size
slot from Content
to Integer
.
- Instead of an
advertisements
slot on Customer
, use the
purchaserOf
slot that is the inverse of purchaser
. This was
renamed from inverse_of_purchaser
.
- Add a
payer
slot from Payment
to Customer
, with inverse slot payments
.
- Create a
Reports
class that contains generated reports.
- Rules
- FC: calculate cost of ad when the content of the ad changes. Get rate per word from the rate_per_word slot on Advertisement.
- FC: Validation: payment must be > 0.00.
- BC: Produce a report of all customers with a balance > 0.00.
- FC: Calculate cost of the ad, add it to customer's balance.
- FC: When a new payment is received, subtract from customer's balance.
- Testing
- Create a new customer. ((:ADD-INSTANCE (?x Customer) (:NAME ?x TestCustomer)))
- Assert the content_size of the Personals Ad "Silly". Assert a purchaser for it too.
((content_size instance_00091 75) (purchaser instance_00091 TestCustomer))
- Or create a new ad and assert its rate_per_word and content_size. This should
fire Rule 1, which should fire Rule 3.
- Then you can get the list of customers with balances, using
ask: ((BalanceReport Reports ?report))
- Then, assert a payment for the purchaser of the ad, and check the balance again.
Notes
- We store rules as instances of
:ALGERNON-RULE
, which is
a subclass of :CONSTRAINT
. This is where Protégé likes
rules to be kept.
- A rule stored in the KB requires three slots:
RuleBody
: :ALGERNON-RULE
to :STRING
.
RuleClass
: :ALGERNON-RULE
to a subclass of :THING
.
RuleSlot
: :ALGERNON-RULE
to an instance of :SLOT. This restricts
the rule to firing only when the given slot is modified.
- You can also add a
RuleTraceLevel
slot from :ALGERNON-RULE
to
one of a list of symbols: {:SILENT, :NORMAL, :VERBOSE, :DETAIL, :DEBUG}
.
Make :NORMAL
be the default.
- We also recommended that you add the :NAME and :DOCUMENTATION slots to rules.
- The rule to produce a report is the hardest to set up. It needs to be triggered
by querying a slot of a frame. Let's set up a Reports class, with each report being
an instance. We'll generate one report a day.
previous index
Author: Micheal Hewett
Email: mhewett@users.sf.net
Last Updated: Monday, June 06, 2005