$title teacher assignment problem
*Teachers 1, 2 and 3 must be assigned at least once to school 1, 2, and 3

SETS I teachers /1, 2, 3, 4, 5, 6, 7, 8, 9, 10/
     J schools /1, 2, 3, 4, 5, 6, 7, 8, 9, 10/
     SI(I) special teachers /1, 2, 3/	
     SJ(J) special schools /1, 2, 3/
     K sessions /am, pm/;

TABLE S(I,K,J) the combined score of the teachers' and schools' preference

	1	2	3	4	5	6	7	8	9	10
1.am	10      4       15      56      24      28      30      42      81      7
2.am    32      40      7       18      28      48      5       63      72      6
3.am    14      48      45      9       70      25      28      48      40      6
4.am    20      40      16      6       48      63      32      20      2       7
5.am    16      50      24      20      35      60      81      2       10      54
6.am    35      6       81      24      24      45      12      3       70      16
7.am    64      27      6       15      4       21      20      12      10      100
8.am    6       5       12      16      81      16      20      50      6       35
9.am    12      70      42      50      16      3       3       60      24      54
10.am   9       81      40      10      3       20      10      36      24      56

1.pm    10      4       15      56      24      28      30      42      81      7
2.pm    32      40      7       18      28      48      5       63      72      6
3.pm    14      48      45      9       70      25      28      48      40      6
4.pm    20      40      16      6       48      63      32      20      2       7
5.pm    16      50      24      20      35      60      81      2       10      54
6.pm    35      6       81      24      24      45      12      3       70      16
7.pm    64      27      6       15      4       21      20      12      10      100
8.pm    6       5       12      16      81      16      20      50      6       35
9.pm    12      70      42      50      16      3       3       60      24      54
10.pm   9       81      40      10      3       20      10      36      24      56


VARIABLES
X(I,K,J) the assignment of teacher i to school j where X is either 0 or 1
Z	the total score over the 10 schools;

POSITIVE VARIABLE X;

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
	SPECIALT(I,K) assign special schools to special teachers 
	SPECIALS(K,J) assign special teachers to special schools;	

SCORE.. Z =E= SUM(I,(SUM(K,(SUM(J,S(I,K,J)*X(I,K,J))))));
SCHOOLAM("am",J).. SUM(I, X(I,"am",J)) =E= 1;
SCHOOLPM("pm",J).. SUM(I, X(I,"pm",J)) =E= 1;

SPECIALT(SI,K).. SUM(SJ, X(SI,K,SJ)) =E=1;
SPECIALS(K,SJ).. SUM(SI, X(SI,K,SJ)) =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;

MODEL ASSIGN/ALL/;
SOLVE ASSIGN USING LP MAXIMIZING Z;