Search code examples
excelmathematical-optimizationlinear-programming

Constraining the range of decision variables based on other decision variables


I have a regular classroom assignment problem with course sizes and class capacities. Decision variables are binary. The model allows assigning one course to more than one room as long as the total capacity assigned is bigger than the course size. The constraint I want to add to this model is to make sure that the respective sizes of the rooms assigned to each course are within a reasonable range (say 20 seats) from each other. How can this be done in a linear way? How can I prevent the model from assigning a course of 60 students to 2 rooms of 10 and 50 capacities and instead make sure their sizes are close together (preferably even equal).

I'm using Excel with OpenSolver.


Here's some sample data:

Course/Room   324A   321D   124B   328   Course Size   Capacity Assigned   Wasted
Management     0      0      0      1        15               25             10
Engineering    1      0      0      0        20               20              0
Science        0      1      1      0        60               75             15

Room Sizes    20     40     35     25

The objective is to minimize the total space wasted (which is 25 seats in this example).


Solution

  • Introduce variables minseat and maxseat and form the inequalities:

    minseat(course) <= seats(room)+(1-assign(course,room))*M
    maxseat(course) >= seats(room)-(1-assign(course,room))*M
    maxseat(course)-minseat(course) <= 20
    

    Alternatively put maxseat(course)-minseat(course) in the objective with some cost factor. Choose M judiciously.