0

i'm facing an issue with a Minizinc code that have to schedule some exams in available rooms and periods. I skip the entire problem and code, because i've just a problem in the definition of this soft constraint:

some exams are targeted as exclusive or not, meaning that they need a room for just themselves, this is a soft consraint, so i need to minimize its number of violations. In fact each exam scheduled in the same room and period of an exam requiring a dedicated room counts as one violation.

The data and variables useful for this constraint are:

  • Exams (the number of exams to be scheduled)
  • room_exclusive (a vector of boolean that stands for the exclusivity required by each exam)
  • room_assignment (a variable vector of the assigned room to each exam)
  • period_assignment (a variable vector of the period assigned to exams)
  • roomexclusivity (an int vector that counts the exclusivity violations for each exams)
  • roomexclusivity_violations (the total number of violations).

For example if four exams share the room, and two of them require a dedicated room, the total number of violations is six. Each of those two has three other exams in the same room.

I've thought to make a two cycle control on each exam in order to find first an exclusive exam and then to check if it shares its room and period with other exams. The issue may be in the sum(e2 in 1..Exams, e1!=e2), because i've wrote it without know if it's right in Minzinc syntax to put e1!=e2.

constraint
  forall(e1 in 1..Exams)  
    (roomexclusivity[e1]=sum(e2 in 1..Exams, e1!=e2)(bool2int(room_exclusive[e1]=true /\ room_assignment[e1]=room_assignment[e2] /\ period_assignment[e1]=period_assignment[e2])));

constraint
  roomexclusivity_violation=sum(e in 1..Exams)(bool2int(roomexclusivity[e]>0));

The error i get is on (roomexclusivity[e1].. line:

syntax error at `('; expected `)' after body expression in generator call

0 Answers0