Models

Lotka-Volterra

Contains an implementation of the Lotka Volterra model.

An implementation of a Lotka Volterra example model.

caliagent.models.lotka_volterra.simulate_lotka_volterra(alpha: float = 0.52, beta: float = 0.024, gamma: float = 0.84, delta: float = 0.026, h0: float = 34.0, l0: float = 5.9, years: ndarray | None = None) → DataFrame[source]

Run the Lotka-Volterra simulation.

Parameters:
  • alpha (float) – Sheep reproduction rate.

  • beta (float) – Predation rate.

  • gamma (float) – Wolf mortality rate.

  • delta (float) – Wolf growth rate from predation.

  • h0 (float) – Initial sheep population.

  • l0 (float) – Initial wolf population.

  • years (array-like | None) – Time points at which to evaluate the solution.

Returns:

The simulated sheep and wolf populations.

Return type:

pd.DataFrame

Wolf Sheep Predation

Contains the Mesa implementation of the Wolf Sheep Predation model.

An implementation of a Wolf Sheep Predation example model.

class caliagent.models.wolf_sheep_predation.WolfSheep(width: int = 20, height: int = 20, initial_sheep: int = 100, initial_wolves: int = 50, sheep_reproduce: float = 0.04, wolf_reproduce: float = 0.05, wolf_gain_from_food: float = 20.0, grass: bool = True, grass_regrowth_time: int = 30, sheep_gain_from_food: float = 4.0, seed: int | None = None, sheep_capacity: int = 100000, wolf_capacity: int = 50000)[source]

An implementation of the Wolf Sheep Predation model.

step() → None[source]

A single step. Fill in here.

caliagent.models.wolf_sheep_predation.wolf_sheep_step(sheep_x: ndarray, sheep_y: ndarray, sheep_energy: ndarray, sheep_alive: ndarray, sheep_slots: int, wolf_x: ndarray, wolf_y: ndarray, wolf_energy: ndarray, wolf_alive: ndarray, wolf_slots: int, grass: ndarray, grass_timer: ndarray, width: int, height: int, sheep_reproduce: float, wolf_reproduce: float, sheep_gain_from_food: float, wolf_gain_from_food: float, grass_regrowth_time: int) → tuple[int, int, int, int, int][source]

Perform a single step of the wolf-sheep predation model.

Parameters:
  • sheep_x (np.ndarray) – The x coordinates of the sheep.

  • sheep_y (np.ndarray) – The y coordinates of the sheep.

  • sheep_energy (np.ndarray) – The energy levels of the sheep.

  • sheep_alive (np.ndarray) – A boolean array indicating which sheep are alive.

  • sheep_slots (int) – The number of sheep slots.

  • wolf_x (np.ndarray) – The x coordinates of the wolves.

  • wolf_y (np.ndarray) – The y coordinates of the wolves.

  • wolf_energy (np.ndarray) – The energy levels of the wolves.

  • wolf_alive (np.ndarray) – A boolean array indicating which wolves are alive.

  • wolf_slots (int) – The number of wolf slots.

  • grass (np.ndarray) – The grass grid.

  • grass_timer (np.ndarray) – The timer for each grass cell.

  • width (int) – The width of the grid.

  • height (int) – The height of the grid.

  • sheep_reproduce (float) – The probability of sheep reproducing.

  • wolf_reproduce (float) – The probability of wolves reproducing.

  • sheep_gain_from_food (float) – The energy gained by sheep from eating grass.

  • wolf_gain_from_food (float) – The energy gained by wolves from eating sheep.

  • grass_regrowth_time (int) – The time it takes for grass to regrow after being eaten.

Returns:

The updated number of slots and counts.

Return type:

tuple[int, int, int, int, int]