@RobPratt
It appears to me that your OPTMODEL code maximizes the total number of SEATS available in unused rooms. Do I have that correct?
But the OP appears to ask to maximize the number of unused ROOMS (minimize number of rooms used, actually). Could there not be a configuration of room sizes that satisfy your objective but would not satisfy the OP's original request?
For instance, if there are six rooms with sizes 7, 6, 6, 5, 2, and 2.
- For total load 13, I believe your code would select a 7 and 6, maximizing the number of seats in unused rooms (6+5+2+2=15). And that result would also satisfy the objective of maximizing unassigned rooms.
- For total load 11, I think your code would use three rooms (7, and both 2's,) leaving 3 rooms (6+6+5=17) unused, maximizing seats in unused rooms. However, the minimum number of ROOMS needed for the total load would be two (7 and either 5 or 6), leaving 4 rooms free, but with smaller total capacity.
Maybe the OP doesn't care about this issue. But is there code that would do two levels of optimizing?First, minimize the count of used rooms. Then, for all combinations satisfying that objective, find one that maximizes your objective - total seats in unused rooms.