Abstract
Partitioning a set of elements into a given number of classes to find a globally optimal solution can be challenging due to the combinatorial explosion of the problem size. In the univariate case, where elements can be ordered, the number of partitions is significantly lower than in the multivariate case, and the problem is easier to handle. In this article, we focus on the univariate case and propose using complete enumeration to find a globally optimal solution. Although complete enumeration may also be computationally prohibitive as the number of elements and classes increases, it can be feasible in some situations. For such cases, we propose an algorithm that generates all contiguous partitions for a variable number of classes to be used with any objective function or set of constraints.•We compare exact problem sizes and approximate time complexities for multivariate and univariate partitioning.•We fill a technical gap in the literature by providing a valuable tool for researchers or engineers who need to exactly solve unusual univariate partitioning problems.•We use a convenient data structure for representing partitions of elements into classes and an iterative algorithm that simulates nested loops for any depth level, allowing for efficient generation of all possible contiguous partitions.