Euler: A System for Numerical Optimization of Programs

Swarat Chaudhuri, Armando Solar-Lezama

Introduction

Numerical optimization is a cornerstone of modern engineering, used to tune everything from physical controllers to machine learning models. However, applying these techniques directly to computer programs has historically been fraught with difficulty. Programs are inherently discrete and discontinuous; a single conditional branch or loop can transform a smooth parameter space into a "bumpy" landscape filled with cliffs, plateaus, and local minima. This "ill-conditioned" nature makes traditional gradient-based or even derivative-free optimization algorithms fail, as they get trapped in sub-optimal regions or fail to find a path toward the global minimum.

The Euler System

To address this, the authors present Euler, a system designed to bridge the gap between program analysis and numerical optimization. Euler allows developers to write "program sketches"—code containing unknown parameters or "holes" (??)—and automatically finds the optimal values for these parameters that minimize a specific cost function.

The Euler workflow begins with a sketch written in a C-like language. This sketch is processed by the Euler compiler, which transforms the program logic into a format suitable for numerical search. The resulting executable links with the GNU Scientific Library (GSL) and utilizes the Nelder-Mead simplex method, a robust derivative-free optimization algorithm, to navigate the parameter space.

Smooth Interpretation

The core innovation of Euler is Smooth Interpretation. Instead of attempting to optimize the original, jagged program function $P(x)$, Euler optimizes a smoothed version, $\bar{P}_\beta(x)$. This smoothing is achieved through Gaussian convolution, effectively "blurring" the discontinuities created by if-else statements and loops.

Comparison of a jagged program execution surface (a) and its smoothed counterpart (b) after Gaussian convolution.

As shown in the figure above, smoothing transforms a sharp "cliff" into a navigable slope. Euler employs an iterative refinement strategy: it starts with a high smoothing factor ($\beta$), creating a very blurry but globally trend-revealing landscape. Once a minimum is found in this simplified space, the system gradually reduces $\beta$, sharpening the landscape and re-optimizing using the previous result as a starting point. This "coarse-to-fine" approach allows the optimizer to follow the global trend of the function before honing in on the precise local minimum.

Evaluation: Parallel Parking Controller

The effectiveness of Euler was evaluated using a challenging parameter synthesis problem: a parallel parking controller. The goal was to find four timing and amplitude parameters ($t_1, A_1, t_2, A_2$) that would allow a simulated car to park perfectly within a designated spot. This problem is highly non-linear and discontinuous due to the physics of the simulation and the discrete control logic.

Results

The authors compared Euler's performance against a baseline Nelder-Mead (NM) search that operated directly on the unsmoothed program. In a series of 100 runs from random starting points, Euler demonstrated significantly higher reliability.

Histogram comparing the distribution of final function values for Euler versus a standard Nelder-Mead search without smoothing.

As illustrated in the histogram, Euler achieved the optimal error value (approximately 10.6) in 68% of the trials. In contrast, the standard NM method without smoothing was highly inconsistent, reaching the near-optimal range in only 26% of runs. The most frequent outcome for the baseline was an error value around 40.0, representing a failed parking attempt where the car remained significantly misaligned. These results highlight that smoothing is not just an optimization; it is often a requirement for finding any viable solution in complex program spaces.

Conclusion and Future Work

Euler demonstrates that signal processing techniques like Gaussian smoothing can be effectively applied to program analysis to enable numerical optimization. While highly successful for controller synthesis, the system currently focuses on unconstrained optimization. Future work aims to incorporate hard constraints on parameter ranges and to improve the scalability of the smoothing approximation for larger, more general software systems. By treating programs as differentiable-like surfaces, Euler opens new avenues for automated software engineering and parameter tuning.

Summary updated

BibTeX
@inproceedings{chaudhuri2012euler,
  author = {Swarat Chaudhuri and Armando Solar-Lezama},
  title = {{Euler: A System for Numerical Optimization of Programs}},
  booktitle = {CAV},
  year = {2012},
  doi = {10.1007/978-3-642-31424-7\_57},
}
Figure