In this paper we propose a mathematical framework for the optimization of tuning systems. We begin with an informal definition of “tuning system.” We then propose five general constraints that seem common to their evolution. The central idea of this paper is the quantification of those constraints in terms of a set of numerical parameters. Given a choice of parameter values we use appropriate optimization methods to produce an optimal tuning for a specific set of values. Finally, we consider some historical and Javanese tunings from this perspective, and use the framework to generate a few examples of novel tuning systems.