Created
January 24, 2016 10:33
-
-
Save Wassasin/1598e92f361792dc245d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Number of people */ | |
param P_count, integer, > 0; | |
/* Number of jobs */ | |
param J_count, integer, > 0; | |
/* Number of days */ | |
param D_count, integer, > 0; | |
param WL, integer, > 0; | |
param WH, integer, > 0; | |
set P := 1..P_count; | |
set J := 1..J_count; | |
set D := 1..D_count; | |
/* Person p likes to solve jobs j */ | |
param L{p in P, j in J} default 0, binary; | |
/* Person p hates to solve jobs j */ | |
param H{p in P, j in J} default 0, binary; | |
/* Person p is capable to perform job j */ | |
param C{p in P, j in J} default 1, binary; | |
/* How many jobs need to be done on what day */ | |
param R{j in J, d in D}, integer, >= 0; | |
/* Person p is allocated to do job j on day d */ | |
var A{p in P, j in J, d in D}, binary; | |
/* A person only has one task per day, at most */ | |
s.t. max_load_person{p in P, d in D}: sum{j in J} A[p,j,d] <= 1; | |
/* A person has at least D-1 tasks */ | |
s.t. min_load_person{p in P}: sum{j in J, d in D} A[p,j,d] >= D_count-1; | |
/* A person does not perform the same job on all days */ | |
s.t. duplicate_jobs{p in P, j in J}: sum{d in D} A[p,j,d] <= D_count-1; | |
/* Each task is allocated */ | |
s.t. all_allocated{j in J, d in D}: sum{p in P} A[p,j,d] == R[j, d]; | |
/* A person only performs what (s)he is capable of */ | |
s.t. capability_person{p in P, j in J, d in D}: A[p,j,d] <= C[p,j]; | |
/* Maximize enjoyment */ | |
maximize enjoyment: sum{p in P, d in D, j in J} A[p,j,d] * (L[p, j] * WL - H[p, j] * WH); | |
solve; | |
printf "Sum %d\n", enjoyment; | |
printf{p in P, d in D, j in J : A[p,j,d] > 0} "%d %d %d %d\n", p, d, j, A[p,j,d] * (L[p, j] * WL - H[p, j] * WH); | |
data; | |
/* Test example */ | |
param P_count := 3; | |
param J_count := 2; | |
param D_count := 2; | |
param WL := 3; | |
param WH := 9; | |
param L : 1 2 := | |
1 0 1 | |
2 1 0 | |
3 0 0; | |
param H : 1 2 := | |
1 1 0 | |
2 0 1 | |
3 0 1; | |
param R : 1 2 := | |
1 1 2 | |
2 2 1; | |
param C[3,2] := 0; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment