BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
mlogan
Lapis Lazuli | Level 10

Hi RobPratt, I ran your whole code and it gives me the following table. Should I get rid of any part of your code? Thanks.

 
COURSE ROOM_NO ROOM_CAPACITY ROOM_LOAD NEW_ROOM_LOAD Room_Status
CHEM101 C101 20 7 20 Available
CHEM101 C102 20 11 16 Available
CHEM101 C103 10 8 0 Available
CHEM101 C104 15 10 0 Available
BIO302 HB102 22 20 22 Available
BIO302 HB106 24 12 24 Available
BIO302 HB902 30 29 30 Available
BIO302 W102 30 31 30 Available
BIO302 AB102 40 27 13 Available
RobPratt
SAS Super FREQ

Did you get any error message in the log?  I suspect that your SAS version does not support indicator constraints (IMPLIES), in which case you should instead use the second (commented out) version of the RespectCapacity constraint.

mkeintz
PROC Star

@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.

  1.   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.

  2. 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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
RobPratt
SAS Super FREQ

@mkeintz Yes, I included both objectives, with one of them commented out.

 

Yes, you can optimize multiple objectives sequentially, with a primary objective, secondary objective, tertiary objective, and so on.  Here is one such example: SAS Help Center: Distribution 1: Which Factories and Depots to Supply Which Customers