$title teacher assignment problem SETS I teachers /1, 2, 3, 4, 5/ J schools /1, 2, 3, 4, 5/ K sections /am, pm/; ALIAS(J,L); SCALAR MAXDIST the max distance to travel by teacher from am to pm school /5/; TABLE S(I,K,J) the combined score of the teachers' and schools' preference 1 2 3 4 5 1.am 10 4 15 56 24 2.am 32 40 7 18 28 3.am 14 48 45 9 70 4.am 20 40 16 6 48 5.am 16 50 24 20 35 1.pm 10 4 15 56 24 2.pm 32 40 7 18 28 3.pm 14 48 45 9 70 4.pm 20 40 16 6 48 5.pm 16 50 24 20 35 TABLE D(J,L) the distance between school J and school L 1 2 3 4 5 1 0 5 12 7 1 2 5 0 2 8 3 3 12 2 0 8 2 4 7 8 8 0 3 5 1 3 2 3 0 VARIABLES X(I,K,J) the assignment of teacher i to school j where X is either 0 or 1 Y(I,J,L) indicate whether there is a teacher travelling from school J to L Z the total score over the 10 schools; INTEGER VARIABLE X; INTEGER VARIABLE Y; EQUATIONS SCORE define the total score which is the objective function SCHOOLAM(K,J) restriction that only one teacher is assigned to one am session SCHOOLPM(K,J) restriction that only one teacher is assigned to one pm session TEACHERAM(I,K) restriction that only one am session is assigned to one teacher TEACHERPM(I,K) restriction that only one pm session is assigned to one teacher DIFFSCH(I,J) restriction that each teachers are assigned to two different school DIST(I,J,L) restriction on the max distance to travel between am and pm school ASST(I,J,L); SCORE.. Z =E= SUM(I,(SUM(K,(SUM(J,S(I,K,J)*X(I,K,J))))))+1000*(SUM((I,J,L),Y(I,J,L))); SCHOOLAM("am",J).. SUM(I, X(I,"am",J)) =E= 1; SCHOOLPM("pm",J).. SUM(I, X(I,"pm",J)) =E= 1; TEACHERAM(I,"am").. SUM(J, X(I,"am",J)) =E= 1; TEACHERPM(I,"pm").. SUM(J, X(I,"pm",J)) =E= 1; DIFFSCH(I,J).. X(I,"pm",J)-(1- X(I,"am",J)) =L= 0; ASST(I,J,L).. Y(I,J,L) - (X(I,"am",J)/2+X(I,"pm",L)/2)=L=0; DIST(I,J,L).. Y(I,J,L)*D(J,L) =L= MAXDIST; MODEL ASSIGN/ALL/; SOLVE ASSIGN USING MIP MAXIMIZING Z;