[Next] [Previous] [Up] [Top] [Contents]

Section 1 - Clauses, Types and Rules

1.4 Experimenting with SDML Clauses


Click on the Experiment tag. Delete the text in the left hand pane and type

fixedCost ?prod ?fc

Then press the command button of the mouse in that pane and select evaluate content. The result should look something like this.

The first word (fixedCost) is the keyword, the next two (?prod ?fc) beginning with question marks are variables. SDML variables can be thought of as named slots that can match with anything on the database in the corresponding positions. The right hand pane now shows all the possible matchings of that clause with the knowledge on the database. These are called bindings. Basically SDML looks for all substitutions for variables in the clause that will match the information on the database and then returns them.

Edit the text in the left hand pane to read:

and

fixedCost ?prod ?fc\

greater ?fc 200\

then use the mouse command button in that pane to select evaluate content.

You will see that the possible bindings are now only those which will satisfy the whole compound clause typed in, namely those producers with fixed cost greater than 200. Basically if you have more than one clause you want to be true at the same time you join them with the logical operator and. I have used the tab button on the keyboard to make the clause more readable - strictly this is unnecessary.

Change the text in the left hand pane to read:

and

fixedCost ?prod ?fc\

(or

greater ?fc 250\

less ?fc 100)\

then press the command button in that pane and select evaluate content. For today whenever we ask you to evaluate a clause on the Experiment pane it will be to use the command button like this.

Now you get a list of all producers with fixed cost greater than 250 or less than 100 (if there are any). The terminator at the end of the lines is a "\". The grouping of statements is specified using brackets.

Negation in SDML is called notInferred. This acts in the same way as ordinary negation (i.e. not) in most circumstances. We will go into the subtle differences in another section.

Change the text in the left hand pane to read:

and

fixedCost ?prod ?fc\

notInferred greater ?fc 200\

This will give all the producers that have fixed costs less than or equal to 200.

Change the text in the left hand pane and evaluate:

and

fixedCost ?prod ?fc\

marginalCost ?prod ?mc\

= ?vol 34\

is ?totalCost ?fc + ?vol * ?mc

This gives us the total cost for producing 34 units for each producer. Notice that in every binding ?vol is the same (34) since we set it that way with "=". The keyword "is" implements the declarative arithmetic - it binds only with a result that would match the result of the arithmetic expression. Of course, we may want to see the total cost for varying volumes for each producer.

Change the text in the left hand pane and evaluate:

and

fixedCost ?prod ?fc\

marginalCost ?prod ?mc\

inInterval ?vol 0 100 10\

is ?totalCost ?fc + ?vol * ?mc

The clause inInterval ?vol 0 100 10 binds the variable ?vol to the numbers between 0 and 100 in steps of 10. The inInterval is extremely useful - it corresponds to the for loop in many imperative languages.


An introduction to SDML - Bruce Edmonds - 13 JUL 99
[Next] [Previous] [Up] [Top] [Contents]

Generated with CERN WebMaker