metawards.Demographic

class metawards.Demographic(name: Optional[str] = None, work_ratio: Optional[float] = None, play_ratio: Optional[float] = None, adjustment: Optional[metawards._variableset.VariableSet] = None, disease: Optional[Union[str, metawards._disease.Disease]] = None, network: Optional[Union[str, metawards._inputfiles.InputFiles]] = None)[source]

This class represents a single demographic

__init__(name: Optional[str] = None, work_ratio: Optional[float] = None, play_ratio: Optional[float] = None, adjustment: Optional[metawards._variableset.VariableSet] = None, disease: Optional[Union[str, metawards._disease.Disease]] = None, network: Optional[Union[str, metawards._inputfiles.InputFiles]] = None)[source]

Construct the Demographics

Methods

__add__(other)

__delattr__(name, /)

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__(other)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__gt__(value, /)

Return self>value.

__init__([name, work_ratio, play_ratio, …])

Construct the Demographics

__init_subclass__

This method is called when a class is subclassed.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__new__(**kwargs)

Create and return a new object.

__reduce__()

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__()

Return repr(self).

__setattr__(name, value, /)

Implement setattr(self, name, value).

__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__

Abstract classes can override this to customize issubclass().

specialise(network[, profiler, nthreads])

Return a copy of the passed network that has been specialised for this demographic.

Attributes

__annotations__

__dataclass_fields__

__dataclass_params__

__dict__

__doc__

__hash__

__module__

__weakref__

list of weak references to the object (if defined)

adjustment

How the parameters for this demographic should be changed compared to the parameters used for the whole population.

disease

The Disease that should be used for this demographic.

name

The name of this demographic.

network

The network that describes the workers and player that are part of this demographic.

play_ratio

The proportion of “play” (random movement) members in this demographic out of the entire population.

work_ratio

The proportion of “work” (fixed movement) members in this demographic out of the entire population.

__init__(name: Optional[str] = None, work_ratio: Optional[float] = None, play_ratio: Optional[float] = None, adjustment: Optional[metawards._variableset.VariableSet] = None, disease: Optional[Union[str, metawards._disease.Disease]] = None, network: Optional[Union[str, metawards._inputfiles.InputFiles]] = None)[source]

Construct the Demographics

__repr__()[source]

Return repr(self).

__str__()[source]

Return str(self).

adjustment: metawards._variableset.VariableSet = None

How the parameters for this demographic should be changed compared to the parameters used for the whole population. This is currently changed to fixed values, but future developments in VariableSet will support rules for varying relative to the whole population. If this is None then this demographic will have the same parameters as the whole population

disease: metawards._disease.Disease = None

The Disease that should be used for this demographic. Is this is None, then the global Disease is used. Otherwise this demographic will follow this Disease

name: str = None

The name of this demographic. This will be used as a label, and should be unique within the Demographics

network: metawards._inputfiles.InputFiles = None

The network that describes the workers and player that are part of this demographic. If this is None then the entire population network will be used (scaled by “work_ratio” and “play_ratio”)

play_ratio: float = 0.0

The proportion of “play” (random movement) members in this demographic out of the entire population. This can also either be a single number, or a list with a value for every ward. Whichever way is used, the sum of “play_ratio” for each demographic must equal 1.0 in each ward (every member of the play population must be represented)

specialise(network: metawards._network.Network, profiler=None, nthreads: int = 1)[source]

Return a copy of the passed network that has been specialised for this demographic. The returned network will contain only members of this demographic, with the parameters of the network adjusted according to the rules of this demographic

Parameters

network (Network) – The network to be specialised

Returns

network – The specialised network

Return type

Network

work_ratio: float = 0.0

The proportion of “work” (fixed movement) members in this demographic out of the entire population. This can either be a single number, or a list with a value for every ward. Whichever way is used, the sum of “work_ratio” for each demographic must equal 1.0 in each ward (every member of the work population must be represented)