02 01 strategy recommendations view - VforVitorio/F1_Strat_Manager GitHub Wiki

Strategy Recommendations View

Relevant source files

Main Components

1. Statistics Dashboard

The top section displays key metrics of the recommendations:

  • Total number of recommendations
  • Number of unique action types
  • Average confidence score
  • Maximum priority level

2. Filtering and Sorting Controls

The view provides extensive filtering capabilities:

  • Confidence threshold slider
  • Priority level multiselect
  • Race phase filtering
  • Sorting options (lap-based, confidence-based, or priority-based) The filters affect all visualizations and cards displayed below.

3. Visualization Components

3.1 Recommendation Timeline

A scatter plot visualization where:

  • X-axis represents lap numbers
  • Y-axis represents different recommendation types
  • Point size represents confidence level
  • Color represents action type This timeline provides a race-wide overview of when different recommendations are triggered.

3.2 Distribution Charts

Two charts that show:

  1. Priority Distribution - Pie chart showing the distribution of recommendations by priority level
  2. Confidence Distribution - Histogram showing the distribution of confidence scores These visualizations help users understand the overall characteristics of the recommendations dataset.

4. Recommendation Cards

Detailed cards displaying specific recommendation information:

  • Action type and lap number
  • Explanation text
  • Confidence score and priority level
  • Rule that fired the recommendation
  • Additional context (tire compound, race phase)
  • Simulation capability for impact analysis The cards can be viewed in two modes:
  • Grouped by action type
  • Chronological view (sorted by lap number)

Optimal Strategy Generation

The view includes functionality to generate an optimal race strategy by selecting a compatible subset of recommendations. The algorithm resolves conflicts between incompatible actions that occur within a short time span.

Conflict Resolution Logic

The optimal strategy generator identifies and resolves conflicts using an incompatibility matrix. Actions that are mutually exclusive (like pit_stop and extend_stint) cannot both be included if they occur within 2 laps of each other. The algorithm prioritizes recommendations based on:

  1. Lap number (ascending)
  2. Priority (descending)
  3. Confidence (descending) It ensures at least one pit stop is included in the final strategy, even if it needs to be added separately.

Strategy Visualizations

The optimal strategy is visualized through:

  1. Step Chart - Shows the sequence of actions across laps
  2. Swimlane Chart - Displays actions organized by type across laps
  3. Summary Table - Tabular data with all recommendation details

Strategy Comparison

The strategy comparison section allows users to compare different strategy approaches:

  1. Optimal Strategy - Balanced approach based on priority, confidence, and timing
  2. Aggressive Strategy - Higher priority actions earlier in the race
  3. Conservative Strategy - Lower priority actions later in the race

Key Comparison Metrics

The comparison extracts and displays:

  • First pit stop lap
  • Number of pit stops
  • Shortest and longest stint durations
  • Action counts by type
  • Total number of actions
  • Action sequence visualization These metrics help teams evaluate the trade-offs between aggressive and conservative approaches.

Alternative Strategy Generation

The component can generate alternative strategies using modified selection algorithms:

  1. Aggressive Strategy - Prioritizes:
    • Highest priority actions
    • Earliest intervention
    • Higher confidence scores
  2. Conservative Strategy - Prioritizes:
    • Lowest priority actions
    • Later interventions
    • Higher confidence scores Both alternatives use the same conflict resolution approach as the optimal strategy but with different sorting priorities.

Data Flow and Integration

The Strategy Recommendations View integrates with other components in the F1 Strategy Manager system:

The view receives recommendation data from the expert system, processes it using helper functions, generates optimal strategies, and renders the UI components through Streamlit.

Styling and Visual Design

The component uses custom CSS styling defined in the application's style.css file for:

  • Stat cards
  • Recommendation cards
  • Charts and visualizations
  • Filters and controls The styling follows a dark theme with consistent color coding for different action types. | Action Type | Color Code | | ----------------------- | ---------- | | pit_stop | #FF5733 | | extend_stint | #33FF57 | | prepare_pit | #5733FF | | perform_undercut | #33FFEC | | defensive_pit | #FF33EB | | prioritize_pit | #FFBD33 | | prepare_rain_tires | #3385FF | | reevaluate_pit_window | #FF3333 | | recovery_push | #FCFF33 | | push_strategy | #33FFBD | | perform_overcut | #BD33FF | | consider_pit | #FF8833 | | adjust_pit_window | #33FFC1 |