Difference between revisions of "Pop1"

From Numerus
Jump to navigation Jump to search
Line 47: Line 47:


[[File: scripting3.png|Thumb|550px|center|Fig 5. Scripting Portal]]
[[File: scripting3.png|Thumb|550px|center|Fig 5. Scripting Portal]]
Let's consider each entry in the script
::<code>reset</code>
Resets the simulator; this should be the first statement of any script.
::<code>set DDT 1</code>
'''DDT''' is the airport code for the <code>deriv</code> RAM. Index 1 is assigned to the logistic growth model.
::<code>restart</code>
This command needs to follow the change in model. It re-initializes the simulation.
::<code>compare_on PCT</code>
Sets the graph (airport code '''PCT''') to comparison mode, in case it wasn't already.
::<code>clear PCT</code>
Empties the graph of earlier runs, if necessary.
::<code>set RTE 0.01</code>
Initializes the rate parameter ('''RTE''') to 0.01
::<code>run_for 200</code>
Executes the simulation for 200 steps.
::<code>restart</code>
::<code>plus RTE 0.01</code>
::<code>run_for 200</code>
<code>restart</code> clears the simulation without returning the parameters to their pre-script values;
<code>plus RTE 0.01</code> increments the rate parameter;<code>run_for 200</code>u
<code>run_for 200</code> runs with the new settings for 200 steps.
This sequence is repeated 4 times.

Revision as of 21:31, 20 February 2022

This very simple Ramp introduces the advanced features.

Obtaining Pop1

Fig 1. Studio after installing Pop1
  1. Download the file Pop1.xml from here.
  2. Launch Numerus Studio and select the File | Open Ramp(s)...; navigate to the folder containing Pop.xml and select it.
  3. When you are done Pop1 should appear on the Numerus Studio dashboard. (Fig. 1)


"Discovering" Pop1

  1. Launch Pop1, resulting in the application shown here:
Fig 2. Pop1 Ramp
  1. Open Help | About This Ramp... to learn about the model and its structure, as shown here:
Fig 3. Pop1 Documentation
The document provides a description of the model and its salient parameters, variables, etc.; use this to familiarize yourself with the model. A link appearing in the title section will lead to more in-depth documentation.
  1. You now have an opportunity to test what you learn from the documentation by possibly running the simulation several times with different parameter values.
Fig 3. Pop1 Documentation

Discovering RAMs

The documentation points out that a RAM exists for overriding the default definition of deriv.

  1. Visit the RAM page either by double-clicking on the blue text of the RAM entry, or by clicking the Op On/Off button.
Fig 4. RAM Management Portal

The RAM portal gives a general description of the model variable and shows and describes each of 2 alternatives. The first (default) implements exponential and the second logistic growth. Both use parameter r as growth rate; the second has a fixed carrying capacity of 50. It is apparent that the code used to implement these two models closely follow the equations; note, however, that each element appears as a function of 0 arguments. This is the standard approach used for coding in the Numerus Designer.

A definition in red indicates that the code has not yet been compiled; i.e., translated into runnable form. The default RAM is compiled when the Ramp is launched. Clicking the compile button performs this translation on override RAMs, following which the new version of the model is ready for use. Compilation of RAMs is generally handled automatically when you first click the Reset button before running the model with a RAM other than the default.

You may add your own RAM to the set by clicking on the + button. As a point of departure you can insert the default definition by clicking the Default button. You should make sure that your code compiles before attempting to use it. You can also test the RAM directly with the Test button, and compare its result with a test of the default RAM and any other defined RAM. A keyword entered here will appear on the RAM dashboard to remind you of the change in the model brought about by the RAM. You can also include your own documentation in plain text above the definition.

Here is a new RAM that defines the derivative as r * Pop1/2.

Fig 4. RAM Management Portal

When you are ready to proceed, close the RAM portal. The RAM selection dashboard uses a spinner to select the RAM to be used in the next run. It also shows the keyword associated with the RAM and its status (red for uncompiled, green for compiled.) Never run a model showing a red RAM in the dashboard.[1] Clicking the Reset button will attempt to compile the RAM. If the dashboard entry remains red, then the RAM contains errors and should be fixed.

Scripting

  1. Open the Scripting Portal using the button S On/Off. It contains the following script:
Fig 5. Scripting Portal

Let's consider each entry in the script

reset

Resets the simulator; this should be the first statement of any script.

set DDT 1

DDT is the airport code for the deriv RAM. Index 1 is assigned to the logistic growth model.

restart

This command needs to follow the change in model. It re-initializes the simulation.

compare_on PCT

Sets the graph (airport code PCT) to comparison mode, in case it wasn't already.

clear PCT

Empties the graph of earlier runs, if necessary.

set RTE 0.01

Initializes the rate parameter (RTE) to 0.01

run_for 200

Executes the simulation for 200 steps.

restart
plus RTE 0.01
run_for 200

restart clears the simulation without returning the parameters to their pre-script values; plus RTE 0.01 increments the rate parameter;run_for 200u run_for 200 runs with the new settings for 200 steps. This sequence is repeated 4 times.

  1. Running a non-compilable RAM will cause the model to automatically shift to the default definition, after a warning.