Section 3 - Agents and some user facilities
In the Objects page of the UniversalAgent type browser select Instances of type: ModelAgent and in the Objects pane, select the command add object. Then enter model in the dialogue.
This explicitly defines an instance of type ModelAgent in the UniversalAgent called model. Now browse the universe and select the Location page. You will see that model is now a sub-agent of universe. We still have to activate it.
In the Initial eternity rulebase of type UniveralAgent enter a rule to assert the clause activeSubAgent model. That is all we are going to do in the UniveralAgent browser so you can now close it.
In the Initial eternity rulebase of ModelAgent create a category and define rules to activate the week and iteration timelevels so that they both start with number 1 (see yesterday's lesson: Section 2.8). I have already created these time level objects as instances of TimeLevel in the UniversalAgent in the intro3-1 module - you just need to assert the appropriate clauses to activate them and set the initial time.
In the Initial week rulebase of ModelAgent create a category called parameters and create a rule to assert the clause: noConsumers 10 and another rule to assert the clause noProducers 2 for all eternity.
Create an initialize category and in it write a rule using generatedInstance to create instances of type Consumer determined by the noConsumers clause (similar to that we used in the last two days) with consequent:
all eternity (and
consumer ?consumer\
activeSubAgent ?consumer)
Here we need to not only note it exists for our own use and also assert it as active.
In the Initial iteration rulebase create a category called producers and create a rule to create instances of Producer determined by the noProducers clause and assert them as active for the week only and report the names of the producers to the text transcript with a suitable message. Be careful about the uniquifying clause used by generatedInstance - it has to be different each week!
Open the simulation debugger, select step mode and start the simulation. Keep clicking on the do button until the rule create consumers has finished and the rule create producers has just appeared. (If you go to far and SDML does not seem to be responding press Control+Y and continue - it was zapping through the iterations as there was no final iteration clause ever asserted to stop it).
Now browse the universe, and then browse model in the Location page. It should look something like this.
Here we can see the simulation-generated sub-agents of model.
Now in the parameters category of the Initial week rulebase on ModelAgent create rule(s) to set the following parameter clauses for all eternity: noOfWeeks, raiseProportion, lowerProportion, profitTargetRange, marginalCostRange, fixedCostRange, capitalRange, moneyRange, requirementRange, choice and chatFactor.
Generated with CERN WebMaker