Objective
Develop a new Tool for the Agents4Gov (LABIC – ICMC/USP) project that implements a SIR (Susceptible–Infectious–Recovered) epidemiological model simulation, based on standard differential-equation formulations.
The goal is to enable users in public-service contexts to simulate disease spread scenarios under different parameters (infection rate, recovery rate, initial populations) and analyse outcomes such as peak infections, duration, and recovered count.
Optional: Based on the reference implementation described here:
https://scientific-python.readthedocs.io/en/latest/notebooks_rst/3_Ordinary_Differential_Equations/02_Examples/Epidemic_model_SIR.html
Description
The SIR Model Simulator Tool must support the following workflow:
-
Input Parameters
- Total population size (N)
- Initial number of infected individuals (I₀)
- Initial number of recovered individuals (R₀)
- Transmission rate (β)
- Recovery rate (γ)
- Simulation period (e.g., days)
- Time step or resolution (optional)
- Optional: intervention effect modifier (e.g., reduced β after a given day)
-
Model Execution
- Use the classic SIR differential equations:
dS/dt = –β * S * I / N
dI/dt = β * S * I / N – γ * I
dR/dt = γ * I
- Integrate over the specified simulation period (e.g., using
scipy.integrate.odeint or equivalent).
- Compute time-series results for S(t), I(t), R(t).
-
Output / Analysis
- Provide time-series data for each compartment (S, I, R) at each timestep.
- Compute key metrics:
- Peak number of infected and the time at which it occurs.
- Total number recovered by end of simulation.
- Duration until infection drops below a threshold (e.g., I(t) < 1).
- Optional: Apply a simple scenario comparison (e.g., with and without intervention) and highlight differences.
-
Presentation
- Return structured JSON output including parameter settings, key metrics, and optionally sampled time-series arrays.
- Provide a brief interpretive summary text (e.g., “Under the given parameters, the epidemic peak occurs at day 35 with ~12 % of population infected.”).
Expected Behavior (User Flow)
- User opens Open WebUI → Tools → SIR Model Simulator.
- User enters the simulation parameters (N, I₀, R₀, β, γ, period) via LLM/Agent chat interaction.
- The tool runs the model.
- The tool returns:
- JSON output with all metrics and time-series summary.
- A short textual summary of key findings.
- If enabled, a plot visualization.
- User can modify parameters and rerun to compare scenarios.
Configuration
- Valve name:
llm_sir_explainer
- If configured, the Valve uses a local LLM to interpret the scenario results (e.g., describing what the parameters imply, recommending public-health ideas).
- Dependencies:
numpy, scipy, matplotlib (or plotly), pandas (optional)
- Data size consideration: The time-series length should be suitable for UI performance (e.g., limit max timesteps to 1,000).
- Parameter validation: Ensure β, γ > 0, N > I₀ + R₀, etc. Provide informative error messages if invalid.
Deliverables
Acceptance Criteria
Objective
Develop a new Tool for the Agents4Gov (LABIC – ICMC/USP) project that implements a SIR (Susceptible–Infectious–Recovered) epidemiological model simulation, based on standard differential-equation formulations.
The goal is to enable users in public-service contexts to simulate disease spread scenarios under different parameters (infection rate, recovery rate, initial populations) and analyse outcomes such as peak infections, duration, and recovered count.
Optional: Based on the reference implementation described here:
https://scientific-python.readthedocs.io/en/latest/notebooks_rst/3_Ordinary_Differential_Equations/02_Examples/Epidemic_model_SIR.html
Description
The SIR Model Simulator Tool must support the following workflow:
Input Parameters
Model Execution
scipy.integrate.odeintor equivalent).Output / Analysis
Presentation
Expected Behavior (User Flow)
Configuration
llm_sir_explainernumpy,scipy,matplotlib(orplotly),pandas(optional)Deliverables
tools/sir_model_simulator/main.py– tool logic for SIR model simulationREADME.md– usage and configuration guiderequirements.txt– dependencies (numpy,scipy,matplotlib)test_sir_model.py– basic sanity testsdocs/README.mdwith reference to this toolAcceptance Criteria