Given a set of individuals, a collection of admissible subsets, and a cost associated to each of these subsets, the Set Partitioning Problem (SPP) consists in selecting admissible subsets to build a partition of the individuals that minimizes the total cost. This combinatorial optimization problem has been used to model dozens of problems arising in specific domains of Artificial Intelligence and Operational Research, such as coalition structures generation, community detection, multilevel data analysis, workload balancing, image processing, and database optimization. All these applications are actually interested in special versions of the SPP: the admissible subsets are assumed to satisfy global algebraic constraints derived from topological or semantic properties of the individuals. For example, admissible subsets might form a hierarchy when modeling nested structures, they might be intervals in the case of ordered individuals, or rectangular tiles in the case of bidimensional arrays. Such constraints structure the search space and -if strong enoughthey allow to design tractable algorithms for the corresponding optimization problems. However, there is a major lack of unity regarding the identification, the formalization, and the resolution of these strongly-related combinatorial problems. To fill the gap, this article proposes a generic framework to design specialized dynamic-programming algorithms that fit with the algebraic structures of any special versions of the SPP. We show how to apply this ¦ An early and shorter version of this paper has been published in the Proceedings of the 2014 IEEE International Conference on Tools with Artificial Intelligence (ICTAI'14) [27] and the full document has been submitted in October 2014 to the Artificial Intelligence journal. 1 framework to two well-known cases, namely the Hierarchical SPP and the Ordered SPP, thus opening a unified approach to solve versions that might arise in the future.