This paper presents an exact algorithm for a generalisation of the classical 0–1 Knapsack Problem, called the Knapsack Problem with Group Fairness. In this problem, items are partitioned into classes, and fairness constraints affect the number of items that can or must be chosen from each class. The problem was introduced by Patel et al. (2021), where approximation algorithms are discussed. This paper describes the first exact solution approaches for the Knapsack Problem with Group Fairness, based on integer linear programming formulations and a dynamic programming algorithm. The latter allows us to establish the complexity of the problem. Finally, a set of computational experiments on benchmark instances derived from the knapsack literature compares the effectiveness of the alternative solution approaches.

