hi, i am trying to make an automated class scheduling . Can you suggest how can i constraint the assignment of rooms only to their predefined buildings only. Also how to avoid assigning time in between lunchbreak
update: I already solved the issue with predefined buildings, but I’m stuck on how to assign class codes that are not assigned due to lack of rooms. now I want the unassigned class codes to be assigned from the available rooms remaining, ignoring the building constraint
# Sets
set CODE;
set ROOMS;
set DAYS ordered := {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};
set TIME ordered := {"8:00am - 9:00am", "9:00am - 10:00am", "10:00am 11:00am", "11:00am - 12:00nn", "1:00pm - 2:00pm", "2:00pm - 3:00pm", "3:00pm - 4:00pm", "4:00pm - 5:00pm"};
# Paramaters
param program{CODE} symbolic;
param section{CODE} symbolic;
param course_num{CODE} symbolic;
param course_title{CODE} symbolic;
param room{CODE} symbolic;
param lec{CODE} >= 0;
param lab{CODE} >= 0;
param teaching_load{CODE} >= 0;
param building{CODE} symbolic;
param buildings{ROOMS} symbolic;
param floor{ROOMS} symbolic;
param type{ROOMS} symbolic;
param lecture{ROOMS} binary;
param laboratory{ROOMS} binary;
# Read data from Excel
load amplxl.dll;
table overall IN "amplxl" "timetable.xlsx" "overall":
CODE <- [CODE], program, section, course_num, course_title, room, lec, lab, teaching_load, building;
table rooms IN "amplxl" "timetable.xlsx" "rooms":
ROOMS <- [ROOMS], buildings, floor, type, lecture, laboratory;
read table overall;
read table rooms;
var assignment{CODE, ROOMS, DAYS, TIME} binary;
var room_assigned{CODE, ROOMS} binary;
# Constraints
subject to building_constraint {c in CODE, r in ROOMS}:
room_assigned[c, r] = if buildings[r] = building[c] then 1 else 0;
subject to required_hours_per_code{c in CODE}:
sum{r in ROOMS, d in DAYS, t in TIME} assignment[c, r, d, t] = lec[c] + lab[c];
subject to no_conflicts {r in ROOMS, d in DAYS, t in TIME}:
sum {c in CODE} assignment[c, r, d, t] <= 1;
subject to available_slots {c in CODE, r in ROOMS, d in DAYS, t in TIME}:
assignment[c, r, d, t] <= room_assigned[c, r];
#subject to assign_remaining_rooms {c in CODE, r in ROOMS, d in DAYS, t in TIME}:
# assignment[c, r, d, t] = if room_assigned[c, r]= 0 then 1 else 0;