Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

yashbhalla/F1-Telemetry-Strategy-Simulator

Repository files navigation

๐ŸŽ๏ธ F1 Telemetry Strategy Simulator

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.

โœจ Features

๐Ÿ›ž Advanced Tire Modeling

  • 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

๐ŸŒค๏ธ Weather Integration

  • 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

๐Ÿšจ Safety Car Effects

  • 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

๐Ÿ“Š Strategy Optimization

  • Brute force optimization for 1-stop and 2-stop strategies
  • Multiple tire compound combinations
  • Detailed stint analysis and timing
  • Strategy comparison and visualization

๐ŸŽฏ Interactive Web Interface

  • Modern Streamlit-based dashboard
  • Real-time strategy optimization
  • Interactive charts and visualizations
  • Weather and safety car configuration
  • Database integration for saving results

๐Ÿ—„๏ธ Database Integration

  • PostgreSQL backend for storing strategies and results
  • Session management and historical data
  • Tire parameter storage and retrieval
  • Performance analytics and comparisons

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.11+
  • PostgreSQL (for database features)
  • Docker (optional, for containerized deployment)

Installation

  1. Clone the repository
git clone https://github.com/yourusername/F1-Telemetry-Strategy-Simulator.git
cd F1-Telemetry-Strategy-Simulator
  1. Install dependencies
pip install -r infra/requirements.txt
  1. 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
  1. Run the application
streamlit run app/Home.py

The application will be available at http://localhost:8501

Docker Deployment

# Build and run with Docker Compose
cd infra
docker-compose up --build
# Access the application at http://localhost:8501

๐ŸŽฎ Usage

Basic Strategy Analysis

  1. Select Race Parameters

    • Choose year, Grand Prix, and session type
    • Configure weather conditions
    • Enable/disable safety car simulation
  2. Run Optimization

    • Click "Load Session & Optimize Strategy"
    • View optimal pit stop strategy
    • Analyze tire degradation curves
  3. Compare Strategies

    • See multiple strategy options
    • Compare total race times
    • Analyze stint details

Advanced Features

  • 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

๐Ÿ”ง Configuration

Tire Parameters

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
 }
}

Weather Conditions

Adjust weather parameters in the Streamlit sidebar or modify defaults in sim/weather.py.

Safety Car Probability

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

๐Ÿ“Š API Reference

Core Classes

TyreModel

tm = TyreModel(tire_params)
lap_time = tm.lap_time(compound, tyre_life, track_temp, fuel_load)

WeatherModel

weather = WeatherModel()
forecast = weather.simulate_weather_forecast(race_laps, conditions)

SafetyCarModel

sc = SafetyCarModel()
events = sc.generate_safety_car_events(race_laps, weather_forecast)

simulate_plan

total_time, stints = simulate_plan(race_laps, start_compound, pit_plan, tyre_model)

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ™ Acknowledgments

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle ใซใ‚ˆใฃใฆๅค‰ๆ›ใ•ใ‚ŒใŸใƒšใƒผใ‚ธ (->ใ‚ชใƒชใ‚ธใƒŠใƒซ) /