I'd like to figure out how to write this constraint: I have a list of exams,every exam has a duration; the final output is the display of a real timetable, in the columns there are the available hours, four in the morning and four in the afternoon, with two hours in the middle of lunch which won't be available.So,let me make this perfectly clear,if I have two exams and each exam has an assigned duration, I'd like to show the number of the exam in the timetable linked to their duration,because my variables are the exams.
For example: I have two exams and the first takes one hours,the second three hours
int: Exams;
array[1..Exams] of int: Exams_duration;
int: Slotstime; % number of slots
int: Rooms; % number of rooms
array[1..Slotstime,1..Rooms] of var 0..Exams: Timetable_exams;
%Data
Exams=2;
Exam_duration=[1,3];
Slotstime=4;
I'd like to have this output: [1,2,2,2] and not [0,0,0,4] (in vertical mode) Is it possible to do in Minizinc? The code for the second output is:
constraint forall (p in 1..Rooms)
(
sum (s in 1..Slotstime) (Timetable_exams[s,p])
= sum (f in 1..Exams)(Exams_duration[f])
);
Thanks in advance