Description Usage model_do See Also Examples
In the CAB package, models are implemented in CAB.model child classes. The model child classes contain slots that hold functions that are necessary for the model. The model child classes also contain a slot called organism that contains all the parameters that are necessary for the model. The model_do function calls specific model functions and automatically finds their parameters in the organism slot.
1 | model_do(model, fx_name)
|
model_doFor calling functions in a CAB.model object.
model_do(model, fx_name)
modelA CAB.model object.
fx_nameA name of a model function. This refers to the slot in the CAB.model object, not the name of the function as it is in the global environment.
Returns the value that the associated function returns. If a parameter in organism is changed, use o_set to assign it.
class.CAB.model
o_set also for the example
1 2 3 4 5 6 7 8 9 10 11 | # Carrying on from the example in class.CAB.models:
good_times_model
# Take our initial value of "happiness_level" to be 100
# Use the plus_happy function in the "plus_happy" slot to add 10 to the happiness
new_happiness = model_do( good_times_model, "plus_happy" )
new_happiness
# Change the model value
o_set( good_times_model, "happiness_level", new_happiness, i = 1 )
# Check the new value
good_times_model
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.