A comprehensive Formula 1 race strategy simulation and telemetry analysis tool that combines real F1 data with advanced mathematical modeling to optimize pit stop strategies.
- Realistic tire degradation curves with cliff effects
- Temperature and fuel load effects on performance
- Support for SOFT, MEDIUM, HARD, INTERMEDIATE, and WET compounds
- Configurable parameters for different tracks and conditions
- Dynamic weather simulation during races
- Track temperature calculation based on air temp, humidity, and cloud cover
- Rain intensity modeling affecting tire choice and performance
- Weather-based safety car probability adjustments
- Realistic safety car event generation
- Pit stop time reduction under safety car conditions
- Field compression effects on lap times
- Strategic advantage calculations for SC pit stops
- Brute force optimization for 1-stop and 2-stop strategies
- Multiple tire compound combinations
- Detailed stint analysis and timing
- Strategy comparison and visualization
- Modern Streamlit-based dashboard
- Real-time strategy optimization
- Interactive charts and visualizations
- Weather and safety car configuration
- Database integration for saving results
- PostgreSQL backend for storing strategies and results
- Session management and historical data
- Tire parameter storage and retrieval
- Performance analytics and comparisons
- Python 3.11+
- PostgreSQL (for database features)
- Docker (optional, for containerized deployment)
- Clone the repository
git clone https://github.com/yourusername/F1-Telemetry-Strategy-Simulator.git
cd F1-Telemetry-Strategy-Simulator- Install dependencies
pip install -r infra/requirements.txt
- Set up database (optional)
# Using Docker docker-compose -f infra/docker-compose.yml up -d db # Or install PostgreSQL locally and create database create db f1_strategy
- Run the application
streamlit run app/Home.py
The application will be available at http://localhost:8501
# Build and run with Docker Compose cd infra docker-compose up --build # Access the application at http://localhost:8501
-
Select Race Parameters
- Choose year, Grand Prix, and session type
- Configure weather conditions
- Enable/disable safety car simulation
-
Run Optimization
- Click "Load Session & Optimize Strategy"
- View optimal pit stop strategy
- Analyze tire degradation curves
-
Compare Strategies
- See multiple strategy options
- Compare total race times
- Analyze stint details
- Weather Simulation: Adjust temperature, humidity, and precipitation
- Safety Car Events: Enable realistic SC scenarios
- Database Storage: Save and retrieve strategy results
- Historical Analysis: Compare strategies across different races
Customize tire performance in sim/tyres.py:
tire_params = { "SOFT": { "base": 75.0, # Base lap time (seconds) "k": 0.10, # Degradation rate "cliff_at": 18, # Cliff effect start lap "cliff_penalty": 0.30, # Cliff penalty (seconds) "max_life": 25 # Maximum useful life } }
Adjust weather parameters in the Streamlit sidebar or modify defaults in sim/weather.py.
Configure SC likelihood in sim/sc_models.py:
self.base_sc_probability = 0.15 # 15% chance per race self.lap_sc_probability = 0.002 # 0.2% chance per lap
tm = TyreModel(tire_params) lap_time = tm.lap_time(compound, tyre_life, track_temp, fuel_load)
weather = WeatherModel() forecast = weather.simulate_weather_forecast(race_laps, conditions)
sc = SafetyCarModel() events = sc.generate_safety_car_events(race_laps, weather_forecast)
total_time, stints = simulate_plan(race_laps, start_compound, pit_plan, tyre_model)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- FastF1 for F1 data access
- Streamlit for the web interface
- Plotly for interactive visualizations
- Formula 1 for the amazing sport and data
Built with โค๏ธ for F1 by Yash Bhalla