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

Section 1 - Clauses, Types and Rules

1.17 Assumptions


If you watch the rule firing transcript you will notice that it is listing strange things called assumptions. This should not concern you unless your model is taking too long to run. Assumptions are generated by SDML as a way of optimisting its logic for frequently occurring situations. In the above case it is possible that another rule that depends on these assumptions will invalidate some of the conditions which it used to make the random choices. Usually this is not the case so the assumptions turn out to be correct, but in rarer circumstances SDML has to go back and try a find a new set of assumptions that is consistent with the rules given. If there is none the simulation stops with an message that says Assumptions cannot be resolved. In this case you know your rules are contradictory.

We can now write a rule to record a consumer buying some good.

Create the rule buying in the buying category with the following antecedent and consequent:

and

consumer ?cons\

chosenProducer ?cons ?bestProd ?minPrice\

requires ?cons ?req\

getsMoney ?cons ?money\

is ?volBought (min ?req (truncated ?money / ?minPrice))

bought ?cons ?volBought ?bestProd

Notice how you can use any of the arithmetic primitives as a function inside the is primitive, this simplifies rule writing.

Go to the Final rulebase in the UniversalAgent type, create a category called producers and enter the rule called sold with antecedent:

and

producer ?prod\

total ?totalSold ?vol

bought ?cons ?vol ?prod

and consequent:

and

sold ?prod ?totalSold\

report "Total sales for " ?prod " were " ?totalSold

This rule totals the sales made by each producer and records it. It also prints a message on the text report transcript to report some of the results to the modeller. If you open a text report transcript before you restart a simulation you will see the messages here. There is also a numeric report transcript to report purely numeric data - this is suitable for importing into spreadsheet and statistic programs for analysis. If you click the yes button on the save data? dialogue as you restart a simulation, you will be prompted for filenames and the contents of each transcript will be saved in the appropriate file.

Try this now.

As an exercise write rules in the Final rulebase to calculate and assert the profit made by each producer, the amount spent by each consumer and to report the average profit over all the producers on a transcript (see the comment on the primitive average in the Definitions section for guidance on this).


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

Generated with CERN WebMaker