This project simulates the Lotka-Volterra predator-prey model using Rust and visualizes the results with Plotly.
The Lotka-Volterra equations describe the dynamics of biological systems in which two species interact, one as a predator and the other as prey. This project allows you to simulate and visualize these dynamics by adjusting parameters and initial conditions.
- Prey Growth Rate (α): The rate at which the prey population grows.
- Predator Death Rate (γ): The rate at which the predator population decreases in the absence of prey.
- Predator Growth Rate per Prey Consumed (δ): The rate at which the predator population grows based on the number of prey consumed.
- Prey Death Rate due to Predation (β): The rate at which the prey population decreases due to predation.
- Initial Prey Population: The starting number of prey.
- Initial Predator Population: The starting number of predators.
- Time Period: The total duration of the simulation.
- Time Step: The interval between each step of the simulation.
-
Install the required dependencies by adding
plotly
to yourCargo.toml
:[dependencies] plotly = "0.10.0"
-
Compile and run the project using
cargo
:cargo run
-
Follow the prompts to input the parameters and initial conditions.
Here is an example of how to input the parameters:
Prey Growth Rate (α) (Default: 0.1): Predator Death Rate (γ) (Default: 0.1): Predator Growth Rate per Prey Consumed (δ) (Default: 0.01): Prey Death Rate due to Predation (β) (Default: 0.01): Initial Prey Population (thousands) (Default: 50.0): Initial Predator Population (thousands) (Default: 10.0): Time Period (weeks) (Default: 200.0): Time Step (weeks) (Default: 0.1): Prey name (Default: Rabbits): Predator name (Default: Wolves):
The simulation results will be displayed in a Plotly graph showing the population dynamics of the prey and predator over time.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any changes or improvements.