degradation rules - VforVitorio/F1_Strat_Manager GitHub Wiki
Degradation Rules
- Overview
- System Architecture
- Installation and Setup
- Streamlit Dashboard
- Strategy Recommendations View
- Gap Analysis View
- Radio Analysis View
- Time Predictions View
- Strategy Chat Interface
- Machine Learning Models
- Lap Time Prediction
- Tire Degradation Modeling
- Vision-based Gap Calculation
- NLP Pipeline
- Radio Transcription
- Sentiment and Intent Analysis
- Named Entity Recognition
- Expert System
- Degradation Rules
- Gap Analysis Rules
- Radio Message Rules
- Integrated Rule Engine
- Developer Guide
- API Reference
- Integration Guide
Degradation Rules
- scripts/IS_agent/N02_degradation_time_rules.ipynb
- scripts/IS_agent/N05_gap_rules.ipynb
- scripts/IS_agent/utils/N02_degradation_time_rules.py
- scripts/IS_agent/utils/N05_gap_rules.py
This document details the tire degradation rule subsystem within the F1 Strategy Manager's expert system. The component evaluates tire performance metrics to generate strategic pit stop recommendations. For related gap-based strategy rules, see Gap Analysis Rules.
Overview
Tire degradation is a critical factor in Formula 1 race strategy. As tires wear, their performance deteriorates, affecting lap times and potentially race position. The F1DegradationRules
engine continuously monitors tire performance metrics and issues strategic recommendations based on predefined thresholds.
Core Rule Definitions
The degradation rule system implements four primary rules that evaluate different aspects of tire performance:
Rule | Condition | Action | Confidence | Priority |
---|---|---|---|---|
High Degradation Pit Stop | DegradationRate > 0.3 AND TyreAge > 10 |
"pit_stop" | 0.8 | 2 |
Stint Extension | DegradationRate < 0.15 AND PredictedRate < 0.20 AND TyreAge > 12 |
"extend_stint" | 0.75 | 1 |
Early Warning | DegradationRate increase > 0.03 over 3 laps |
"prepare_pit" | 0.7 | 1 |
Predicted Degradation Alert | PredictedRate > 0.2 AND TyreAge > 8 |
"consider_pit" | 0.8 | 2 |
Fact Objects and Data Flow
The rule engine processes three types of facts:
Detailed Rule Implementation
1. High Degradation Pit Stop Rule
Triggers when tire degradation exceeds critical thresholds, indicating significant performance loss that requires immediate attention.
2. Stint Extension Recommendation Rule
Identifies opportunities to extend the current tire stint when degradation remains low despite tire age, potentially gaining track position.
3. Early Degradation Warning Rule
Monitors for rapid increases in degradation rate over consecutive laps, providing advance notice of potential pit stop needs.
4. Predicted High Degradation Alert Rule
Uses machine learning predictions to anticipate future degradation, allowing proactive strategy adjustments before performance deteriorates.
Threshold Determination
The rule thresholds were established through statistical analysis of historical race data.
The degradation thresholds were derived from quartile analysis:
- High Degradation (0.3 s/lap) - Approximates the 75th percentile of observed degradation rates
- Low Degradation (0.15 s/lap) - Approximates the 25th percentile
- Warning Threshold (0.03 s/lap increase) - Based on empirical analysis of critical performance changes
Integration with Strategy Engine
The degradation rules are implemented as an extension of the base F1StrategyEngine
class through inheritance. Each degradation rule generates StrategyRecommendation
objects that include:
- Action - The recommended strategy action (e.g., "pit_stop", "extend_stint")
- Confidence - A numeric value (0.0-1.0) indicating recommendation confidence
- Explanation - A human-readable justification for the recommendation
- Priority - Numeric priority level (higher values indicate greater urgency)
- Lap Issued - The lap number when the recommendation was generated
These recommendations flow into the complete strategy engine for final decision-making, where they may be combined with recommendations from other rule systems.
Testing Functions
The module provides several utility functions for testing the rule engine:
Single Driver Test
test_with_real_data(race_data_path, models_path)
: Tests the rule engine with a single driver's data.
Multi-Driver Test
test_multiple_drivers(race_data_path, models_path, driver_numbers=None)
: Evaluates rules across multiple drivers.
Visualization Tools
analyze_degradation_rate(degradation_data)
: Analyzes distribution of degradation ratesplot_driver_degradation_profile(degradation_data, driver_number)
: Visualizes a specific driver's degradation pattern
Example Output
When the degradation rules engine generates a recommendation, it includes a detailed explanation for the strategy team:
Recommendation:
Action: pit_stop
Confidence: 0.8
Explanation: High tire degradation rate detected (0.32 > 0.3) with significant tire age (15 laps)
Priority: 2
Lap issued: 18
Relationship to Other Systems
The degradation rules work in conjunction with other rule systems, particularly:
- Gap Rules: While degradation rules focus on absolute tire performance, gap rules consider relative positions between cars
- Lap Time Rules: Analyze overall performance trends that may be influenced by, but not limited to, tire degradation
- Radio Rules: Process team radio communications that might mention tire conditions
The complete strategy engine reconciles potentially conflicting recommendations from these systems using confidence scores and priority levels.
On this page
- Degradation Rules
- Overview
- Core Rule Definitions
- Fact Objects and Data Flow
- Detailed Rule Implementation
- 1. High Degradation Pit Stop Rule
- 2. Stint Extension Recommendation Rule
- 3. Early Degradation Warning Rule
- 4. Predicted High Degradation Alert Rule
- Threshold Determination
- Integration with Strategy Engine
- Testing Functions
- Single Driver Test
- Multi-Driver Test
- Visualization Tools
- Example Output
- Relationship to Other Systems