Formal descriptions of inflectional systems face three interrelated problems: (1) the Meaning Assignment Problem: Which morphosyntactic feature specification should be assigned to a given affix? (2) the Imperfect Distribution Problem: To what degree can the paradigmatic distribution of an affix deviate from its morphosyntactic specification? and (3) the Subsegmentation Problem: Does a given string of segments consist of one or more affixes? What makes the analysis of complex inflectional systems potentially intractable is the accumulative effect of all three problems, which results in an unwieldy amount of analytic options. Existing approaches to these problems are either incompatible with standard analyses in theoretical morphology (e.g. Harris 1955; Goldsmith 2010) or address only a subset of these problems (e.g. Pertsova 2011). In this paper, we propose a unified approach to all three problems by outlining a learning algorithm that uses optimal patterns of paradigmatic distribution of potential affixes as the main criterion for computing morpheme meaning and subsegmentation of affix strings. The central idea is that learners apply local optimization in the sense of the Harmonic Serialism version of Optimality Theory (McCarthy 2010): Every optimization step identifies the affix with the optimal distribution in a paradigm, assigning a morpheme entry to it, and ‘freezes’ the substrings corresponding to the newly learned affix in the paradigm for further learning. Different constraint rankings result naturally in affix lexica optimized for specific theoretical approaches to morphology.