Actions

class stonesoup.movable.action.move_position_action.MovePositionAction(end_time: datetime, target_value: Any, generator: Any = None)[source]

Bases: Action

This is the base class for an action that changes the position of a platform or sensor.

Parameters:
  • end_time (datetime.datetime) – Time at which modification of the attribute ends.

  • target_value (Any) – Target value.

  • generator (Any, optional) – Action generator that created the action.

act(current_time, timestamp, init_value)[source]

Return the attribute modified.

Parameters:
  • current_time (datetime.datetime) – Current time

  • timestamp (datetime.datetime) – Modification of attribute ends at this time stamp

  • init_value (Any) – Current value of the modifiable attribute

Returns:

The new value of the attribute

Return type:

Any

end_time: datetime

Time at which modification of the attribute ends.

generator: Any

Action generator that created the action.

target_value: Any

Target value.

class stonesoup.movable.action.move_position_action.GridActionGenerator(owner: object, attribute: str, start_time: datetime, end_time: datetime, resolution: float = 1, action_space: ndarray = None, action_mapping: Sequence[int] = (0, 1))[source]

Bases: ActionGenerator

This is the base class for generators that generate actions in a grid like fashion.

Parameters:
  • owner (object) – Actionable object that has the attribute to be modified.

  • attribute (str) – The name of the attribute to be modified.

  • start_time (datetime.datetime) – Start time of action.

  • end_time (datetime.datetime) – End time of action.

  • resolution (float, optional) – The size of each grid cell. Cells are assumed square.

  • action_space (numpy.ndarray, optional) – The bounds of the action space that should not be exceeded. Of shape (ndim, 2) where ndim is the length of the action_mapping. For example, np.array([[xmin, xmax], [ymin, ymax]]).

  • action_mapping (collections.abc.Sequence, optional) – The state dimensions that actions are applied to.

action_space: ndarray

The bounds of the action space that should not be exceeded. Of shape (ndim, 2) where ndim is the length of the action_mapping. For example, np.array([[xmin, xmax], [ymin, ymax]]).

action_mapping: Sequence[int]

The state dimensions that actions are applied to.

resolution: float

The size of each grid cell. Cells are assumed square.

class stonesoup.movable.action.move_position_action.NStepDirectionalGridActionGenerator(owner: object, attribute: str, start_time: datetime, end_time: datetime, resolution: float = 1, action_space: ndarray = None, action_mapping: Sequence[int] = (0, 1), n_steps: int = 1, step_size: int = 1)[source]

Bases: GridActionGenerator

This is a grid action generator that enables movement by a number of steps in the specified directions. Actions are applied symmetrically so can move by a number of steps in positive and negative directions along the specified dimensions.

Parameters:
  • owner (object) – Actionable object that has the attribute to be modified.

  • attribute (str) – The name of the attribute to be modified.

  • start_time (datetime.datetime) – Start time of action.

  • end_time (datetime.datetime) – End time of action.

  • resolution (float, optional) – The size of each grid cell. Cells are assumed square.

  • action_space (numpy.ndarray, optional) – The bounds of the action space that should not be exceeded. Of shape (ndim, 2) where ndim is the length of the action_mapping. For example, np.array([[xmin, xmax], [ymin, ymax]]).

  • action_mapping (collections.abc.Sequence, optional) – The state dimensions that actions are applied to.

  • n_steps (int, optional) – The number of steps that can be moved in either direction along specified dimensions

  • step_size (int, optional) – The number of grid cells per step

n_steps: int

The number of steps that can be moved in either direction along specified dimensions

step_size: int

The number of grid cells per step

property default_action

The default action to modify the property if there is no given action.

class stonesoup.movable.action.move_position_action.SamplePositionActionGenerator(owner: object, attribute: str, start_time: datetime, end_time: datetime, resolution: float = None, action_space: ndarray = None, action_mapping: Sequence[int] = (0, 1), n_samples: int = 10)[source]

Bases: ActionGenerator

Base action generator for sampling approaches to action generation. The action generator requires the user to define a number of samples to generate (n_samples) according to the defined sampling technique.

Parameters:
  • owner (object) – Actionable object that has the attribute to be modified.

  • attribute (str) – The name of the attribute to be modified.

  • start_time (datetime.datetime) – Start time of action.

  • end_time (datetime.datetime) – End time of action.

  • resolution (float, optional) – Resolution of action space

  • action_space (numpy.ndarray, optional) – The bounds of the action space that should not be exceeded. Of shape (ndim, 2) where ndim is the length of the action_mapping. For example, np.array([[xmin, xmax], [ymin, ymax]]).

  • action_mapping (collections.abc.Sequence, optional) – The state dimensions that actions are applied to.

  • n_samples (int, optional) – Number of samples to generate. This does not include the action to remain at the current position, meaning n_samples +1 actions will be generated.

action_space: ndarray

The bounds of the action space that should not be exceeded. Of shape (ndim, 2) where ndim is the length of the action_mapping. For example, np.array([[xmin, xmax], [ymin, ymax]]).

action_mapping: Sequence[int]

The state dimensions that actions are applied to.

n_samples: int

Number of samples to generate. This does not include the action to remain at the current position, meaning n_samples +1 actions will be generated.

property default_action

The default action to modify the property if there is no given action.

class stonesoup.movable.action.move_position_action.CircleSamplePositionActionGenerator(owner: object, attribute: str, start_time: datetime, end_time: datetime, resolution: float = None, action_space: ndarray = None, action_mapping: Sequence[int] = (0, 1), n_samples: int = 10, maximum_travel: float = 1.0)[source]

Bases: SamplePositionActionGenerator

Action generator which samples candidate future positions uniformly within a circle around the current position. Circle radius is defined by the user with maximum_travel. This generator is only applicable to 2D position actions.

Parameters:
  • owner (object) – Actionable object that has the attribute to be modified.

  • attribute (str) – The name of the attribute to be modified.

  • start_time (datetime.datetime) – Start time of action.

  • end_time (datetime.datetime) – End time of action.

  • resolution (float, optional) – Resolution of action space

  • action_space (numpy.ndarray, optional) – The bounds of the action space that should not be exceeded. Of shape (ndim, 2) where ndim is the length of the action_mapping. For example, np.array([[xmin, xmax], [ymin, ymax]]).

  • action_mapping (collections.abc.Sequence, optional) – The state dimensions that actions are applied to.

  • n_samples (int, optional) – Number of samples to generate. This does not include the action to remain at the current position, meaning n_samples +1 actions will be generated.

  • maximum_travel (float, optional) – Maximum possible travel distance. Specifies the radius of sampling area.

maximum_travel: float

Maximum possible travel distance. Specifies the radius of sampling area.

class stonesoup.movable.action.move_position_action.MaxSpeedPositionActionGenerator(owner: object, attribute: str, start_time: datetime, end_time: datetime, resolution: float = 1, action_space: ndarray = None, action_mapping: Sequence[int] = (0, 1), max_speed: float = 1, angle_resolution: float = 1.5707963267948966)[source]

Bases: ActionGenerator

Action generator which generates actions uniformly within a circle around the current position. Circle radius is defined by the max_speed of the platform and the duration of the action. This generator is only applicable to 2D position actions.

Parameters:
  • owner (object) – Actionable object that has the attribute to be modified.

  • attribute (str) – The name of the attribute to be modified.

  • start_time (datetime.datetime) – Start time of action.

  • end_time (datetime.datetime) – End time of action.

  • resolution (float, optional) – The interval in distance travelled for each action.

  • action_space (numpy.ndarray, optional) – The bounds of the action space that should not be exceeded. Of shape (ndim, 2) where ndim is the length of the action_mapping. For example, np.array([[xmin, xmax], [ymin, ymax]]).

  • action_mapping (collections.abc.Sequence, optional) – The state dimensions that actions are applied to.

  • max_speed (float, optional) – The maximum speed that the platform can move in m/s.

  • angle_resolution (float, optional) – The interval in angle for each action.

action_space: ndarray

The bounds of the action space that should not be exceeded. Of shape (ndim, 2) where ndim is the length of the action_mapping. For example, np.array([[xmin, xmax], [ymin, ymax]]).

action_mapping: Sequence[int]

The state dimensions that actions are applied to.

max_speed: float

The maximum speed that the platform can move in m/s.

resolution: float

The interval in distance travelled for each action.

angle_resolution: float

The interval in angle for each action.

property default_action

The default action to modify the property if there is no given action.

action_from_value(value=None) MovePositionAction[source]

Given a value for the position, generates the action would achieve that value.

Parameters:

value (StateVector) – Property value for which the action is required.

Returns:

Action which will achieve this position.

Return type:

MovePositionAction