Skip to content

Parameters Name Space

Clifford Bohm edited this page Jan 23, 2023 · 11 revisions

Parameters and Name Space

MABEs parameters support name space. Name space provides a way to have different versions of the same parameter. Various parts of MABE make use of name space and the documentation for those parts will define how they use name space. In addition to allowing for different versions of a parameter, name spaces provide an inheritance methodology (see Name Space Inheritance below).

For the moment, lets consider this example... We are using MABE to study a predator/prey relationship. We have a world which takes two groups. A group of wolves and a group of sheep. Now lets assume that we want the population size of the wolf group to be 10 and the population size of the sheep group to be 100. We can use name space.
In a config file where ever we want to set a value in the sheep name space we would open the name space and set the parameters and then close the name space.

%GLOBAL
  initPop = 150
  + sheep::
    initPop = 100
  - # sheep::
  + wolf::
    initPop = 10
  - # wolf::

Alternatively we could create the following config file

%
GLOBAL-initPop = 150
+ sheep::
  GLOBAL-initPop = 100
- # sheep::
+ wolf::
  GLOBAL-initPop = 10
- # wolf::

Lastly, you could create a settings file like this:

%
GLOBAL-initPop = 150
sheep::GLOBAL-initPop = 100
wolf::GLOBAL-initPop = 10

All three of these files would define the same parameters:
GLOBAL-initPop = 150
sheep::GLOBAL-initPop = 100
wolf::GLOBAL-initPop = 10

Name Space on the command line

Name space works with the "-p" option:

./MABE -p GLOBAL-initPop 150 sheep::GLOBAL-initPop 100 wolf::GLOBAL-initPop 10

Name Space Inheritance

If a parameter is requested with a name space and it can not be found, MABE will start a search for that parameter. The search will be conducted based on name space. Name spaces end in '::', but they can also contain '::' internally. If a parameter was searched for in the name space sheep::big:: and it was not found, MABE would search next in sheep:: and lastly in root::

root:: indicates the top level, and since everything is a child of "root::" we leave it off. When you see "root::" (in a config file for example) it denotes that MABE should use the top level version of the parameter.

Inheritance Example

if these parameters were set:
    GLOBAL-initPop = 45
    sheep::GLOBAL-initPop = 20
    sheep::big::GLOBAL-initPop = 10

then:
    sheep::big::GLOBAL-initPop would be 10
    sheep::small::GLOBAL-initPop would be 20 (inherited from sheep::)
    wolf::bitey::small::GLOBAL-initPop would be 45 (inherited from root::)

Clone this wiki locally