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

Section 2 - Modules, Time Levels and Lists

2.7 Stopping simulations


Now go to the Initial week rulebase in the type browser for ModelAgent and create a rule called number of consumers in the setting parameters category to set the clause noConsumers to 10. Then create a rule in the creation category using generatedInstance called create consumers to create the number of consumers set by the noConsumers clause and assert this for all eternity using the consumer ?consumer clause (if you have forgotten the syntax of any clauses look at the Definitions page). If you are really stuck on how to do this look at yesterday's lesson (or ask).

Go back to the setting parameters category and create rules to assert moneyRange 100 300, and requirementRange 15 35 for all eternity.

Now in the Content rulebase create a rule called allocate money for week to the setup week category exactly as we did yesterday (or differently if you want!). Make the consequent of the form all week (getsMoney ?consumer ?amount). Similarly write a rule to set requires ?consumer ?amount for each week.

Open a rule firing transcript and start the simulation.

You will notice that the initial eternity rule fires first, then the initial week rules then the simulation keeps on firing the money and requirements rule week after week. We have not provided any rule to stop the simulation - so it just keeps going

To stop the simulation, ensure an SDML window is selected, then hold down the Control key on the key board and press the "Y" button simultaneously. The Simulation Debugger will then appear with the message User Interrupt and the simulation will halt.

In the initial week rulebase add a rule in the category setting parameters called number of weeks to assert the clause noOfWeeks 5 for all eternity, then add a rule in the Content rulebase (category finishing name last week) with antecedent:

and

noOfWeeks ?no\

time week ?no

and consequent:

final week

We put this rule into the Content rulebase because we want it to be fired every week.

Now start the simulation again and watch the result on the rule firing transcript.

Now the simulation should stop at the end of week 5. We could have asserted the final week clause at any time during the week to make it the last week. This is still not quite right because the first week starts at 0 instead of 1. We can fix this with the clause intialTime.

In the Initial eternity rulebase enter a rule called start times under the category time to assert the clause initialTime week 1.


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

Generated with CERN WebMaker