DMCommunity.org offered the Dec-2022 Challenge “Christmas Model” created with ChatGPT. This nice model defines a set of people, a set of gifts, the happiness level, and costs of each gift. The objective is to maximize the total happiness, subject to the budget constraint that the total cost of the gifts must be less than or equal to the budget, and the constraint that each person can only receive one gift. As a holiday exercise, I tried to implement it using a free and open-sourced JavaSolver.com. Here is my solution:

I expect this code is intuitive enough for a Java developer. I only want to explain the most interesting Element constraint defined in the standard Java Constraint Programing API JSR-331 (p.30). For example,
csp.postElement(COSTS, gifts[i], “=”, costs[i]);
posts constraint COSTS[gifts[i]] = costs[i] setting the proper relations between yet unselected gifts and their costs.
Here are the execution results:
==== RESULTS ====
Alice => Flowers
Bob => Wine
Carol => Book
Dave => Chocolate
Eve => Flowers
Total Cost: 44
Total Happiness: 24
Elapsed time: 355 milliseconds
Happy 2023!