How to add a new parameter to HeatbugsPlus
Here is how to add a new parameter to the HeatbugPlus
program. Assume that one wants the parameter to
be stored as an instance variable in the heatbugs,
so that they (rapidly) can access the value
each time they take a step.
1. Add the parameter to the Parameter object interface.
In Parameter.h, add the required instance variable (IV)
2. Change the Parameter object implementation.
In Parameters.m
a. in createBegin method:
- initialize the IV
- add the IV to probe'd items (if desired)
b. in initParameters method:
- add codes to the add the parameter to the parlist
At this point you can re-make the application.
The variable now should:
- be settable on run time command
- be in the -h listing
- appear in the report file
- settable via an -IF=inputfile
3. Make changes to the Heatbug object.
In Heatbug.h (the interface file):
- add the instance variable
- add the get/set accessor methods declarations
In Heatbug.m (the implementation file):
- define the get/set accessor methods
- use the variable where ever you planned!
4. Make changes to initialize the IV's in the Heatbugs.
That is, we have to transfer the values set in
the Parameters object to each Heatbug. The best
place to do this is as they are created, in the
buildObjects and/or createHeatbug methods in
the file HeatbugModelSwarm.m .
These steps are very similar to those needed to add a new
parameter to any Swarm model using the UM-ExpTools-4 Parameter
object to manage runtime settable model parameters
(and all the other things one can do with those tools).