metacast.event_handling.events
- Creation:
Author: Martin Grunnill Date: 2024/03/08
Description: Events for use in class EventQueue.
Module Contents
Classes
Base parent event. |
|
Parent event for events that involve changing a value or values. |
|
Transfers values between state variables. |
|
Event for changing parameter values. |
|
Change parameters to be equal to the sum of a subpopulation. |
- class metacast.event_handling.events.BaseEvent(name, times)
Base parent event.
Parameters & Attributes
- namestr
Name given to event.
- timesfloats/ints, ranges or list/tuple/set of floats/ints
Times at which event occurs.
- process()
Method for carrying out event.
- make_event_a_nullevent()
Changes method into a do null event (do nothing event). Child classes process method should start with ‘if self._do_nothing:
super().process()
else:’ or ‘if self._do_nothing:
pass
else:’
- undo_make_event_a_nullevent()
Changes method from a do null event (do nothing event). Child classes process method should start with ‘if self._do_nothing:
super().process()
else:’ or ‘if self._do_nothing:
pass
else:’
- process()
Method for carrying out event.
- Return type:
Nothing
- class metacast.event_handling.events.ValueFactorProportionChangeEvent(name, times, value=None, factor=None, proportion=None)
Bases:
BaseEventParent event for events that involve changing a value or values.
Parameters & Attributes
- namestr
Name given to event.
- timesfloats/ints, ranges or list/tuple/set of floats/ints
Times at which event occurs.
- valuefoat/int, mutually exclusive with factor and proportion.
Value that overrides original value(s).
- proportionfoat/int, mutually exclusive with value and factor.
Proportion the multiplies original value(s). Must be between 0 and 1.
- factorfoat/int, mutually exclusive with value and proportion.
Factor the multiplies original value(s).
- process()
Method for carrying out event.
- make_event_a_nullevent()
Changes method into a do null event (do nothing event).
- undo_make_event_a_nullevent()
Changes method from a do null event (do nothing event).
- property proportion
- property factor
- property value
- class metacast.event_handling.events.TransferEvent(name, times, value=None, factor=None, proportion=None, from_index=None, to_index=None)
Bases:
ValueFactorProportionChangeEventTransfers values between state variables.
Note if value, factor and proportion are all None event is a null event (do nothing event).
Parameters & Attributes
- namestr
Name given to event.
- timesfloats/ints, ranges or list/tuple/set of floats/ints
Times at which event occurs.
- valuefoat/int, optional but mutually exclusive with factor and proportion.
Value that overrides original parameter value(s).
- proportionfoat/int, optional but mutually exclusive with value and factor.
Proportion the multiplies original parameter value(s). Must be between 0 and 1.
- factorfoat/int, optional but mutually exclusive with value and proportion.
Factor the multiplies original parameter value(s).
- from_index: list-like of ints
Indexes of stat variables from which transfers take place.
- to_index: list-like of ints
Indexes of stat variables to which transfers take place.
- process()
Process event by transferring amount between state variables
- make_event_a_nullevent()
Changes method into a do null event (do nothing event).
- process(solution_at_t, time, return_total_effected=True)
Process event by transferring amount between state variables. Note if value, factor and proportion are all None event is a null event (do nothing event).
- Parameters:
solution_at_t (numpy.array) – State variable values at time t.
time (float) – Time at t.
return_total_effected (bool, default is True) – If true total number transferred is returned.
- Return type:
If return_total_effected is True, total number transferred is returned.
- class metacast.event_handling.events.ChangeParametersEvent(name, times, changing_parameters, value=None, factor=None, proportion=None)
Bases:
ValueFactorProportionChangeEventEvent for changing parameter values. Note if value, factor and proportion are all None event is a null event (do nothing event).
Parameters & Attributes
- namestr
Name given to event.
- timesfloats/ints, ranges or list/tuple/set of floats/ints
Times at which event occurs.
- changing_parameterslist-like of strings
Parameters whose values will be changed.
- valuefoat/int, optional but mutually exclusive with factor and proportion.
Value that overrides original parameter value(s).
- proportionfoat/int, optional but mutually exclusive with value and factor.
Proportion the multiplies original parameter value(s). Must be between 0 and 1.
- factorfoat/int, optional but mutually exclusive with value and proportion.
Factor the multiplies original parameter value(s).
- process()
Process event by change parameter values for parameters listed in self.changing_parameters.
- make_event_a_nullevent()
Changes method into a do null event (do nothing event).
- process(model_object, parameters_attribute, parameters)
Process event by change parameter values for parameters listed in self.changing_parameters. Note if value, factor and proportion are all None event is a null event (do nothing event).
- Parameters:
model_object (object) – Object used to define and simulate model.
parameters_attribute (string) – Attribute of model_object that sets parameters (must accept dictionary where keys are strings and values are floats/ints).
parameters (dict {str : floats/ints}) – Parameters being used by model.
- Returns:
parameters – Parameters being used by model after the values of those is list self.changing_parameters is changed.
- Return type:
dict {str : floats/ints}
- class metacast.event_handling.events.ParametersEqualSubPopEvent(name, times, changing_parameters, subpopulation_index)
Bases:
BaseEventChange parameters to be equal to the sum of a subpopulation.
Parameters & Attributes
- namestr
Name given to event.
- timesfloats/ints, ranges or list/tuple/set of floats/ints
Times at which event occurs.
- changing_parameterslist-like of strings
Parameters whose values will be changed.
- subpopulation_indexlist-like of ints
Index of subpopulation the sum of which will change self.changing_parameters to.
- process()
Process event by changing parameters to be equal to the sum of a subpopulation.
- make_event_a_nullevent()
Changes method into a do null event (do nothing event).
- process(model_object, parameters_attribute, parameters, solution_at_t)
Process event by changing parameters to be equal to the sum of a subpopulation.
- Parameters:
model_object (object) – Object used to define and simulate model.
parameters_attribute (string) – Attribute of model_object that sets parameters (must accept dictionary where keys are strings and values are floats/ints).
parameters (dict {str : floats/ints}) – Parameters being used by model.
solution_at_t (numpy.array) – State variable values at time t.
- Return type:
Nothing