A Machine Learning Surrogate for Fuel Anti-Knock Resistance Calculation
Replacing a Legacy Calculation Bottleneck in Combustion Engine Analytics with a Machine Learning Surrogate Model
1. Executive Summary
This case study describes a Random Forest surrogate model that replaced a legacy, single-case calculation tool used to estimate a fuel's resistance to uncontrolled combustion (knock) based on its composition. The surrogate reduced batch calculation time from several minutes to a few seconds, a 60 to 75x speedup, reproduced the legacy tool's output with R2 greater than 0.990 and error within a fraction of a percent, and eliminated the runtime bottleneck that made iterative or repeated analysis impractical.
2. Context
A fuel's resistance to uncontrolled combustion is a critical parameter for configuring and operating internal combustion engines, directly affecting knock resistance and combustion behavior across varying fuel compositions. In operation, a physical sensor on the plant already supplies this value directly to the engine controller. For engineering analysis, however, such as retrospective studies, configuration reviews, and reporting, calculating this resistance parameter required a legacy software tool built on closed C code, accessible only via manual single-case entry or a batch wrapper.
Even using the wrapper, a full batch run of the available dataset, several thousand fuel composition states, took several minutes. This was tolerable for a one-off calculation, but a hard constraint on any workflow requiring repeated or iterative use.
3. Opportunity
Two structural limitations motivated a machine learning approach rather than reimplementation:
- No documented mathematical formulation was available, since the calculation logic was embedded in closed legacy C code, making direct reimplementation infeasible.
- The legacy tool offered no way to reduce runtime for repeated use, since it had no API and was not designed for integration into modern analytical pipelines.
Given these constraints, a surrogate model trained to approximate the legacy tool's input-output mapping was the most viable path to removing the runtime bottleneck without altering the tool's underlying calculation behavior.
4. Implementation
A Random Forest Regressor was trained on real field-measured fuel compositions, using resistance values calculated by the legacy tool as ground-truth labels. Of the full set of composition variables accepted by the legacy tool, a feature importance analysis identified a small subset responsible for the large majority of predictive power, and the final model was trained on this reduced feature set with no measurable loss in accuracy.
4.1 Technical Stack
- Python and scikit-learn (Random Forest Regressor)
- Feature importance analysis for dimensionality reduction
- 10-fold Shuffle Cross Validation
4.2 Key Technical Challenges
- Label provenance: Training labels came from real field measurements run through the legacy tool, not synthetic or evenly sampled data. The model's reliable range is therefore bounded by operating conditions actually observed in the field, not the full theoretical composition space.
- Feature reduction without accuracy loss: Reducing the input set required validation through cross-validation that the dropped variables carried no meaningful signal, rather than assuming importance rankings alone were sufficient.
- Validating against a black-box reference: Since the legacy tool's internal calculation logic was inaccessible, model validation relied entirely on matching its outputs statistically through R2 and error distribution, rather than on a theoretical or first-principles check.
5. Impact
- Batch calculation time reduced from several minutes to a few seconds, a 60 to 75x speedup.
- R2 greater than 0.990 against legacy tool output, with error within a fraction of a percent, validated via 10-fold Shuffle Cross Validation on a held-out portion of the dataset.
- Input requirements reduced, simplifying future data collection.
- Removed the runtime bottleneck that made iterative analysis, pipeline integration, and retrospective study of historical data impractical.
- Demonstrated a reusable pattern for ML-assisted virtual sensors, estimating fuel or gas-quality parameters from existing data without dedicated physical measurement.
6. Model Scope and Limitation
The model was trained and validated on real field-measured fuel compositions, meaning its accuracy reflects the range of operating conditions actually observed, not the full theoretical composition space. Within this range, the model shows strong agreement with the legacy tool.
Predictions for fuel compositions significantly outside this observed range should be treated with caution, since extrapolation performance has not been validated. In practice, the model is recommended for interpolation within the training domain, with periodic retraining as new field measurements expand that range over time.
7. Key Insights
- Matching a legacy tool's behavior statistically, without access to its internal logic, is a valid and sometimes necessary validation strategy. It also means the surrogate inherits the legacy tool's blind spots and cannot be checked against first principles.
- Speed gains only translate into real impact if the original bottleneck was reruns, not calculation once. The value here came specifically from turning a one-off-tolerable runtime into a negligible one, not just from raw speedup.
- Because training data came from real field measurements rather than a designed sweep, the model's trustworthy range is defined empirically, not theoretically, and requires periodic retraining as new field data expands that range.