Skip to content

Getting Started

milad edited this page May 10, 2026 · 2 revisions

This guide will help you install and run your first epidemic simulation in minutes.


๐Ÿ“‹ Prerequisites

Before you begin, make sure you have:

Requirement Version Check Command
Python 3.8 or higher python --version
pip Latest pip --version
Git (optional) Any git --version

๐Ÿ’พ Installation

Method 1: Install from PyPI (Recommended)

pip install sir-epidemic

Method 2: Install from Source (for development)

git clone https://github.com/miladrezanezhad/sir_simulator.git
cd sir_simulator
pip install -e .

Method 3: Clone only (without installing)

git clone https://github.com/miladrezanezhad/sir_simulator.git
cd sir_simulator
pip install -r requirements.txt

Verify Installation

python -c "import sir_simulator; print('โœ… Success!')"

๐ŸŽฎ Your First Simulation

1๏ธโƒฃ Run SIR Model via CLI

sir-simulator --beta 0.5 --gamma 0.2 --tmax 100

Expected output:

๐Ÿฆ  Running SIR Simulation...
Parameters: beta=0.5, gamma=0.2

โœ… Simulation complete!
๐Ÿ“Š Output shape: (500, 4)

๐Ÿ“ˆ Last 5 rows:
           time  Susceptible   Infected   Recovered
495   99.198397   105.895275    0.003002  894.101723
496   99.398798   105.895244    0.002915  894.101842
...

๐Ÿ’พ Saved to: simulation_output.csv

2๏ธโƒฃ Run Streamlit Dashboard

streamlit run src/sir_simulator/user_interface/app.py

Then open http://localhost:8501 in your browser.

3๏ธโƒฃ Run Interactive Menu

python main.py

You'll see:

๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ 
   SIR EPIDEMIC SIMULATOR
๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ ๐Ÿฆ 

   MAIN MENU
   ----------------------------------------

   1. Run SIR Model
   2. Run SEIR Model
   3. Run Network Simulation
   4. Parameter Optimization
   5. ML Prediction
   6. Scenario Comparison
   7. Run All Tests
   0. Exit

4๏ธโƒฃ Run All Tests

python run_all_tests.py

Expected output:

Ran 35 tests in 3.233s
OK

============================================================
โœ… Tests Run: 35
โœ… Successes: 35
โŒ Failures: 0
โš ๏ธ Errors: 0
============================================================

๐Ÿ“Š Understanding the Output

CLI Output CSV File

The CLI automatically saves results to simulation_output.csv with columns:

Column Description
time Time in days
Susceptible Number of susceptible individuals
Infected Number of infected individuals
Recovered Number of recovered individuals

Key Metrics

Metric Meaning
Rโ‚€ Basic reproduction number (beta/gamma)
Peak Infected Maximum number of infected individuals
Peak Day Day when peak infection occurs
Final Size Total number recovered at the end

๐Ÿงช Try Different Parameters

High Infection Rate (Outbreak)

sir-simulator --beta 0.8 --gamma 0.1 --tmax 100

Low Infection Rate (Contained)

sir-simulator --beta 0.2 --gamma 0.3 --tmax 100

Quick Recovery

sir-simulator --beta 0.5 --gamma 0.5 --tmax 100

Large Population

sir-simulator --beta 0.5 --gamma 0.2 --S0 10000 --I0 100 --tmax 200

๐Ÿ› Troubleshooting

Problem: ModuleNotFoundError: No module named 'sir_simulator'

Solution: Install the package in development mode:

pip install -e .

Problem: streamlit: command not found

Solution: Install streamlit:

pip install streamlit

Problem: UnicodeEncodeError on Windows

Solution: Update to the latest version (v1.0.1+):

pip install --upgrade sir-epidemic

Problem: Tests failing

Solution: Install all dependencies:

pip install -r requirements.txt

๐Ÿ“š Next Steps

Now that you've run your first simulation, explore:


๐Ÿ”— Related Links


โฌ† Back to Home

Clone this wiki locally