$title teacher assignment problem
*Travelling cost is to be reimbursed to teacher, which reduces the utility

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/
     K sessions /am, pm/;

SCALAR
     COST The conversion factor from travelling costs to utility measure /3/;

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;

TABLE T(I,K,J) the travelling cost for each teacher i to each school j in the two sessions

        1       2       3       4       5       6       7       8       9       10
1.am  	6	5	3	2	1	6	3	2	1	4
2.am    9	8	2	5	3	4	2	4	1	4
3.am    11	9	9	8	7	6	5	4	4	9
4.am    5	1	1	3	3	4	5	4	2	5
5.am    7	6	5	2	5	4	3	5	8	7
6.am    5	4	10	2	4	7	8	7	6	5
7.am    5	4	2	5	5	4	6	8	1	11
8.am    9	8	7	6	5	4	3	2	1	10
9.am    5	4	3	8	7	1	9	9	8	4
10.am   9       6	8	5	7	4	5	6	3	2

1.pm    8	5	6	7	9	8	7	5	5	6
2.pm    3	4	7	8	6	2	2	4	8	3
3.pm    14      12	25	3	5	9	3	5	7	8
4.pm    5       1       1       3       3       4       5       4       2       5
5.pm    7       6       5       2       5       4       3       5       8       7
6.pm    5       4       10      2       4       7       8       7       6       5
7.pm    5       4       2       5       5       4       6       8       1       11
8.pm    9       8       7       6       5       4       3       2       1       10
9.pm    5       4       3       8       7       1       9       9       8       4
10.pm   9       6       8       5       7       4       5       6       3       2;





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;

SCORE.. Z =E= (SUM(I,(SUM(K,(SUM(J,S(I,K,J)*X(I,K,J))))))) - (COST*
SUM(I,(SUM(K,(SUM(J,T(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;
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;