The constraint satisfaction problem (CSP) is a computational problem that includes a range of important problems in computer science. We point out that fundamental concepts of the CSP, such as the solution set of an instance and polymorphisms, can be formulated abstractly inside the 2-category PFinSet of finite sets and sets of functions between them. The 2-category PFinSet is a quantaloid, and the formulation relies mainly on structure available in any quantaloid. This observation suggests a formal development of generalisations of the CSP and concomitant notions of polymorphism in a large class of quantaloids. We extract a class of optimisation problems as a special case, and show that their computational complexity can be classified by the associated notion of polymorphism. [Joint work with Yuni Iwamasa and Kei Kimura. To be presented at Applied Category Theory 2021.]