Basic Model
In this tutorial, we demonstrate adding some simple simulation logic to the tutorial exercise.
You will need an evaluation account to run this tutorial.
Scenario description
The exercise contains two simulations:
- Government
- A simulation of a country in the world
- UnitedNations
- A simulation of a global government-monitoring organization
The Government simulation is deployed twice: once as Australia, and once as Bangladesh.
The Government simulation publishes a single instance of the Country entity. This entity instance is constructed during the initialize phase of the simulation, and is updated once per simulation tick, providing updates on the population and GNP of the country.
Natural disasters occur at regular intervals during the simulation; when a natural disaster occurs, a Government simulation will send out an AidRequest message describing the nature of the disaster.
When one country is notified of an AidRequest from another country, the country receiving the AidRequest will decrease its GNP by 1% to simulate the provision of aid to the affected country.
The United Nations listens to both Country updates and AidRequest messages, but does nothing other than log the data as it is received.
Points of Interest
This simulation demonstrates how to construct simple simulation logic. Particular attention should be paid to the following:
- The
initialize()andsimulate()methods of the Government simulation; in particular, the way in which entity instances are created and updated, and messages are sent. - The
AidRequestReceiverfor the Government simulation, which demonstrates how to respond to messages. - The
CountryListenerfor the UnitedNations simulation, which demonstrates how to respond to entity updates.
Running the tutorial
Download the full project code for the Tutorial project in C++ or Java. Then download the sample user code (for C++ or Java), and unpack the user code into the tutorial project directory. This sample user code will overwrite some of the files generated by SIMplicity for the default project definition, adding simulation logic and modifying initialization scripts.
After unpacking the sample user code, you can compile and run the tutorial project.
