* Final Project for C&O 370 By: Eoin Brady,
* Julia Rhee, and
* Kevin Williams.
* Core Problem
SETS
T teachers / T1*T10 /
S schools / S1*S10 / ;
TABLE TP(T, S) preferences of teachers
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
T1 1 20 20 20 20 20 20 20 20 20
T2 20 20 1 20 20 20 20 20 20 20
T3 20 1 20 20 20 20 20 20 20 20
T4 20 20 20 20 20 1 20 20 20 20
T5 20 20 20 20 1 20 20 20 20 20
T6 20 20 20 20 20 20 20 1 20 20
T7 20 1 20 20 20 20 20 20 20 20
T8 20 20 20 1 20 20 20 20 20 20
T9 20 20 20 20 20 1 20 20 20 20
T10 20 20 20 20 20 20 20 1 20 20 ;
TABLE SP(S, T) preferences of schools
T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
S1 20 20 20 20 1 20 20 20 20 20
S2 1 20 20 20 20 20 20 20 20 20
S3 20 20 1 20 20 20 20 20 20 20
S4 20 20 20 1 20 20 20 20 20 20
S5 20 20 20 20 20 20 1 20 20 20
S6 20 20 20 20 20 1 20 20 20 20
S7 1 20 20 20 20 20 20 20 20 20
S8 20 20 20 20 1 20 20 20 20 20
S9 20 20 20 20 20 20 20 20 1 20
S10 20 20 20 20 20 20 1 20 20 20 ;
VARIABLES
X(S, T) transfer of teachers
Z objective function variable ;
INTEGER VARIABLE X ;
EQUATIONS
COST define objective function
DEMAND(S) define demand of schools
SUPPLY(T) define supply of teachers
DEMAND2(T) define demand of teachers
SUPPLY2(S) define supply of schools ;
DEMAND(S) .. SUM(T, X(S, T)) =E= 1;
SUPPLY(T) .. SUM(S, X(S, T)) =E= 1;
DEMAND2(T) .. SUM(S, X(S, T)) =E= 1;
SUPPLY2(S) .. SUM(T, X(S, T)) =E= 1;
COST .. Z =E= SUM((S, T), (TP(T,S)*X(S, T))+(SP(S,T)*X(S, T)));
MODEL SCHEDULE / ALL /;
SOLVE SCHEDULE USING MIP MINIMIZING Z ;
DISPLAY X.L, X.M, Z.L;
See Solutions
* Final Project for C&O 370 By: Eoin Brady,
* Julia Rhee, and
* Kevin Williams.
* Core Problem Plus Extension 1
* -----------------------------
* Extension: teachers and schools get 3 preferences
* of equal rank.
SETS
T teachers / T1*T10 /
S schools / S1*S10 / ;
TABLE TP(T, S) preferences of teachers
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
T1 1 20 20 20 20 1 20 1 20 20
T2 20 20 1 20 1 20 20 20 1 20
T3 20 1 1 20 20 20 1 20 20 20
T4 20 20 20 1 20 1 20 1 20 20
T5 1 20 20 20 1 20 20 20 20 1
T6 20 20 1 20 20 20 20 1 1 20
T7 20 1 20 1 20 1 20 20 20 20
T8 1 20 20 1 20 20 20 1 20 20
T9 20 1 20 1 20 1 20 20 20 20
T10 20 20 1 20 20 1 20 1 20 20 ;
TABLE SP(S, T) preferences of schools
T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
S1 20 1 20 20 1 20 20 20 1 20
S2 1 20 20 20 20 1 20 20 20 1
S3 20 20 1 20 1 20 20 1 20 20
S4 1 20 20 1 20 20 20 20 20 1
S5 20 1 20 20 1 20 1 20 20 20
S6 20 20 1 20 20 1 20 1 20 20
S7 1 20 20 1 20 20 20 20 1 20
S8 20 1 20 20 1 20 20 1 20 20
S9 20 20 1 20 20 1 20 20 1 20
S10 20 1 20 1 20 20 1 20 20 20 ;
VARIABLES
X(S, T) transfer of teachers
Z objective function variable ;
INTEGER VARIABLE X ;
EQUATIONS
COST define objective function
DEMAND(S) define demand of schools and teachers
SUPPLY(T) define supply of teachers and schools;
DEMAND(S) .. SUM(T, X(S, T)) =E= 1;
SUPPLY(T) .. SUM(S, X(S, T)) =E= 1;
COST .. Z =E= SUM((S, T), (TP(T,S)*X(S, T))+(SP(S,T)*X(S, T)));
MODEL SCHEDULE / ALL /;
SOLVE SCHEDULE USING MIP MINIMIZING Z ;
DISPLAY X.L, Z.L;
See Solutions
* Final Project for C&O 370 By: Eoin Brady,
* Julia Rhee, and
* Kevin Williams.
* Core Problem Plus Extension 2
* -----------------------------
* Extension: teachers and schools get 3 preferences
* ranked 1,2 or 3.
SETS
T teachers / T1*T10 /
S schools / S1*S10 / ;
TABLE TP(T, S) preferences of teachers
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
T1 1 20 2 20 3 20 20 20 20 20
T2 20 20 1 20 20 2 20 20 3 20
T3 20 1 20 20 2 20 20 3 20 20
T4 1 20 20 2 20 3 20 20 20 20
T5 20 20 20 20 1 20 2 20 20 3
T6 20 20 20 3 20 20 20 1 20 2
T7 2 3 20 1 20 20 20 20 20 20
T8 20 20 3 2 20 20 1 20 20 20
T9 20 2 20 20 20 1 20 20 3 20
T10 3 20 20 20 20 20 20 2 20 1 ;
TABLE SP(S, T) preferences of schools
T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
S1 20 20 2 20 1 20 20 3 20 20
S2 1 20 20 20 20 2 20 20 3 20
S3 20 20 1 20 2 20 3 20 20 20
S4 2 20 20 1 20 20 20 20 20 3
S5 20 3 20 20 20 20 1 20 2 20
S6 20 20 3 20 20 1 20 2 20 20
S7 1 20 20 3 20 20 20 20 20 2
S8 20 2 20 20 1 20 20 3 20 20
S9 3 20 20 20 20 20 2 20 1 20
S10 20 20 2 20 3 20 20 20 20 1 ;
VARIABLES
X(S, T) transfer of teachers
Z objective function variable ;
INTEGER VARIABLE X ;
EQUATIONS
COST define objective function
DEMAND2(S) define demand of schools
DEMAND1(T) define demand of teachers
SUPPLY2(S) define supply of schools
SUPPLY1(T) define supply of teachers ;
DEMAND2(S) .. SUM(T, X(S, T)) =E= 1;
DEMAND1(T).. SUM(S, X(S, T)) =E= 1;
SUPPLY2(S) .. SUM(T, X(S, T)) =E= 1;
SUPPLY1(T) .. SUM(S, X(S, T)) =E= 1;
COST .. Z =E= SUM((S, T), (TP(T,S)*X(S, T))+(SP(S,T)*X(S, T)));
MODEL SCHEDULE / ALL /;
SOLVE SCHEDULE USING MIP MINIMIZING Z ;
DISPLAY X.L, Z.L;
See Solutions
* Final Project for C&O 370 By: Eoin Brady,
* Julia Rhee, and
* Kevin Williams.
* Core Problem Plus Extension 3
* -----------------------------
* Extension: teachers and schools get 3 preferences
* ranked 1,2 or 3, and 4 schools automatically
* get their 1st preference due to political
* issues.
SETS
T teachers / T1*T10 /
S schools / S1*S10 / ;
TABLE TP(T, S) preferences of teachers
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
T1 1 20 2 20 3 20 20 20 20 20
T2 20 20 1 20 20 2 20 20 3 20
T3 20 1 20 20 2 20 20 3 20 20
T4 1 20 20 2 20 3 20 20 20 20
T5 20 20 20 20 1 20 2 20 20 3
T6 20 20 20 3 20 20 20 1 20 2
T7 2 3 20 1 20 20 20 20 20 20
T8 20 20 3 2 20 20 1 20 20 20
T9 20 2 20 20 20 1 20 20 3 20
T10 3 20 20 20 20 20 20 2 20 1 ;
TABLE SP(S, T) preferences of schools
T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
S1 20 20 2 20 1 20 20 3 20 20
S2 1 20 20 20 20 2 20 20 3 20
S3 20 20 1 20 2 20 3 20 20 20
S4 2 20 20 1 20 20 20 20 20 3
S5 20 3 20 20 20 20 1 20 2 20
S6 20 20 3 20 20 1 20 2 20 20
S7 1 20 20 3 20 20 20 20 20 2
S8 20 2 20 20 1 20 20 3 20 20
S9 3 20 20 20 20 20 2 20 1 20
S10 20 20 2 20 3 20 20 20 20 1 ;
VARIABLES
X(S, T) transfer of teachers
Z objective function variable ;
INTEGER VARIABLE X ;
EQUATIONS
COST define objective function
DEMAND2(S) define demand of schools
DEMAND1(T) define demand of teachers
SUPPLY2(S) define supply of schools
SUPPLY1(T) define supply of teachers
FORCE(S, T) force teachers to go to a certain school
FORCE2(S, T)
FORCE3(S, T)
FORCE4(S, T) ;
DEMAND2(S) .. SUM(T, X(S, T)) =E= 1;
DEMAND1(T).. SUM(S, X(S, T)) =E= 1;
SUPPLY2(S) .. SUM(T, X(S, T)) =E= 1;
SUPPLY1(T) .. SUM(S, X(S, T)) =E= 1;
FORCE(S, T) .. X('S2','T1')=E=1;
FORCE2(S, T) .. X('S5','T7')=E=1;
FORCE3(S, T) .. X('S6','T6')=E=1;
FORCE4(S, T) .. X('S9','T9')=E=1;
COST .. Z =E= SUM((S, T), (TP(T,S)*X(S, T))+(SP(S,T)*X(S, T)));
MODEL SCHEDULE / ALL /;
SOLVE SCHEDULE USING MIP MINIMIZING Z ;
DISPLAY X.L, Z.L;
See Solutions
* Final Project for C&O 370 By: Eoin Brady,
* Julia Rhee, and
* Kevin Williams.
* Core Problem Plus Extension 4
* -----------------------------
* Extension: teachers and schools get 3 preferences
* ranked 1,2 or 3, and conditional constraints
* exist, like if a certain teacher goes to
* a certain school, than another teacher must
* go to a certain school, and if one teacher
* goes to another school, then another teacher
* cannot go to a certain school.
SETS
T teachers / T1*T10 /
S schools / S1*S10 / ;
TABLE TP(T, S) preferences of teachers
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
T1 1 20 2 20 3 20 20 20 20 20
T2 20 20 1 20 20 2 20 20 3 20
T3 20 1 20 20 2 20 20 3 20 20
T4 1 20 20 2 20 3 20 20 20 20
T5 20 20 20 20 1 20 2 20 20 3
T6 20 20 20 3 20 20 20 1 20 2
T7 2 3 20 1 20 20 20 20 20 20
T8 20 20 3 2 20 20 1 20 20 20
T9 20 2 20 20 20 1 20 20 3 20
T10 3 20 20 20 20 20 20 2 20 1 ;
TABLE SP(S, T) preferences of schools
T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
S1 20 20 2 20 1 20 20 3 20 20
S2 1 20 20 20 20 2 20 20 3 20
S3 20 20 1 20 2 20 3 20 20 20
S4 2 20 20 1 20 20 20 20 20 3
S5 20 3 20 20 20 20 1 20 2 20
S6 20 20 3 20 20 1 20 2 20 20
S7 1 20 20 3 20 20 20 20 20 2
S8 20 2 20 20 1 20 20 3 20 20
S9 3 20 20 20 20 20 2 20 1 20
S10 20 20 2 20 3 20 20 20 20 1 ;
VARIABLES
X(S, T) transfer of teachers
Z objective function variable ;
INTEGER VARIABLE X ;
EQUATIONS
COST define objective function
DEMAND2(S) define demand of schools
DEMAND1(T) define demand of teachers
SUPPLY2(S) define supply of schools
SUPPLY1(T) define supply of teachers
COND(S, T) OR conditional constraint
COND2(S, T) AND conditional constraint
FORCE(S, T) force a specific flow to demonstrate
* that the conditional constraint works.
FORCE2(S, T) same as above ;
DEMAND2(S) .. SUM(T, X(S, T)) =E= 1;
DEMAND1(T).. SUM(S, X(S, T)) =E= 1;
SUPPLY2(S) .. SUM(T, X(S, T)) =E= 1;
SUPPLY1(T) .. SUM(S, X(S, T)) =E= 1;
FORCE(S, T) .. X('S2','T1') =E= 1;
FORCE2(S, T) .. X('S5','T4') =E= 1;
COND(S, T) .. X('S2','T1') + X('S7','T2') =L= 1;
COND2(S, T) .. X('S5','T4') =L= X('S10','T10');
COST .. Z =E= SUM((S, T), (TP(T,S)*X(S, T))+(SP(S,T)*X(S, T)));
MODEL SCHEDULE / ALL /;
SOLVE SCHEDULE USING MIP MINIMIZING Z ;
DISPLAY X.L, Z.L;
See Solutions
* Final Project for C&O 370 By: Eoin Brady,
* Julia Rhee, and
* Kevin Williams.
* Final
* Hardcore Problem : Includes teachers and schools ranking
* preferences in order 1, 2 or 3; conditional
* constraints, separate preferences for
* morning or afternoon shift, and teachers
* must be assigned to different schools for
* the afternoon shift.
SETS
T teachers / T1*T10 /
S schools / S1*S10 / ;
TABLE TPM(T, S) preferences of teachers in mornings
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
T1 1 20 2 20 3 20 20 20 20 20
T2 20 20 1 20 20 2 20 20 3 20
T3 20 1 20 20 2 20 20 3 20 20
T4 1 20 20 2 20 3 20 20 20 20
T5 20 20 20 20 1 20 2 20 20 3
T6 20 20 20 3 20 20 20 1 20 2
T7 2 3 20 1 20 20 20 20 20 20
T8 20 20 3 2 20 20 1 20 20 20
T9 20 2 20 20 20 1 20 20 3 20
T10 3 20 20 20 20 20 20 2 20 1 ;
TABLE SPM(S, T) preferences of schools in mornings
T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
S1 20 20 2 20 1 20 20 3 20 20
S2 1 20 20 20 20 2 20 20 3 20
S3 20 20 1 20 2 20 3 20 20 20
S4 2 20 20 1 20 20 20 20 20 3
S5 20 3 20 20 20 20 1 20 2 20
S6 20 20 3 20 20 1 20 2 20 20
S7 1 20 20 3 20 20 20 20 20 2
S8 20 2 20 20 1 20 20 3 20 20
S9 3 20 20 20 20 20 2 20 1 20
S10 20 20 2 20 3 20 20 20 20 1 ;
TABLE TPA(T, S) preferences of teachers in afternoon
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
T1 20 1 20 2 20 3 20 20 20 20
T2 20 20 2 20 1 20 3 20 20 20
T3 3 20 20 20 20 20 20 1 2 20
T4 20 20 20 1 20 3 20 20 20 2
T5 2 3 20 20 20 20 1 20 20 20
T6 20 20 1 20 3 20 20 2 20 20
T7 20 20 20 3 20 2 20 20 20 1
T8 1 20 20 20 20 20 2 20 3 20
T9 20 1 20 20 20 20 20 3 2 20
T10 20 20 3 20 2 1 20 20 20 20 ;
TABLE SPA(S, T) preferences of schools in afternoons
T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
S1 20 20 20 1 20 2 20 20 3 20
S2 20 20 3 20 1 20 20 2 20 20
S3 20 1 20 20 20 20 3 20 20 2
S4 1 20 20 2 20 3 20 20 20 20
S5 2 3 20 20 20 20 20 20 1 20
S6 20 20 1 20 2 20 3 20 20 20
S7 20 20 20 3 30 1 20 20 2 20
S8 20 2 20 20 20 20 1 3 20 20
S9 20 20 2 20 1 20 20 20 20 3
S10 3 20 20 20 20 20 20 1 20 2 ;
TABLE XZERO(S, T) indicator variable
T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
S1
S2
S3
S4
S5
S6
S7
S8
S9
S10 ;
VARIABLES
X(S, T) transfer of teachers
Z objective function variable ;
INTEGER VARIABLE X ;
EQUATIONS
COSTMOR define objective function for morning
COSTAFT define objective function for afternoon
DEMAND2(S) define demand of schools in morning
DEMAND1(T) define demand of teachers in morning
SUPPLY2(S) define supply of schools morning
SUPPLY1(T) define supply of teachers morning
COND(S, T) OR conditional constraint
COND2(S, T) AND conditional constraint
XZEROS(S,T) set morning answers to zero force teachers to ;
* change schools for the afternoon shift.
DEMAND2(S) .. SUM(T, X(S, T)) =E= 1;
DEMAND1(T).. SUM(S, X(S, T)) =E= 1;
SUPPLY2(S) .. SUM(T, X(S, T)) =E= 1;
SUPPLY1(T) .. SUM(S, X(S, T)) =E= 1;
COND(S, T) .. X('S5','T5') + X('S7','T9') =L= 1;
COND2(S, T) .. X('S2','T4') =L= X('S6','T2') ;
XZEROS(S, T)$(XZERO(S, T) eq 1) .. X(S, T) =E= 0;
COSTMOR .. Z =E= SUM((S, T), (TPM(T,S)*X(S, T))+(SPM(S,T)*X(S,T)));
COSTAFT .. Z =E= SUM((S, T), (TPA(T,S)*X(S, T))+(SPA(S,T)*X(S,T)));
MODEL SCHED1 / SUPPLY1, SUPPLY2, DEMAND1, DEMAND2, COND, COND2, COSTMOR/;
SOLVE SCHED1 USING MIP MINIMIZING Z ;
DISPLAY X.L, Z.L;
MODEL SCHED2 / SUPPLY1, SUPPLY2, DEMAND1, DEMAND2, XZEROS, COND, COND2,
COSTAFT /;
XZERO(S, T)$(X.L(S, T) ne 0) = 1;
SOLVE SCHED2 USING MIP MINIMIZING Z;
DISPLAY X.L, Z.L ;
See
Solutions
