remove old glpm files
This commit is contained in:
parent
9699a2a2f7
commit
19d9a9f6e8
22
glpm.py
22
glpm.py
@ -1,22 +0,0 @@
|
||||
def col_all_zeros(ls, i, al=0):
|
||||
return all(x[i] == al for x in ls)
|
||||
def row_all_zeros(ls, i, al=0):
|
||||
return all(x == al for x in ls[i])
|
||||
def matrix(name, ls, default=0):
|
||||
nonzero_cols = [i+1 for i in range(len(ls[0])) if not col_all_zeros(ls, i, default)]
|
||||
nonzero_rows = [i+1 for i in range(len(ls)) if not row_all_zeros(ls, i, default)]
|
||||
res = ""
|
||||
for r in nonzero_rows:
|
||||
res += "\n{:2d}".format(r)
|
||||
for c in nonzero_cols:
|
||||
res += " {:2d}".format(ls[r-1][c-1])
|
||||
return param(name, res, " : " + " ".join("{:2d}".format(x) for x in nonzero_cols))
|
||||
|
||||
def dict(name, thing, default=None):
|
||||
fmt_key = lambda k: " ".join((str(x+1) for x in k)) if type(k) == tuple else k+1
|
||||
return param(name, ", ".join(["{} {}".format(fmt_key(k), v) for k,v in thing.items() if v != default]))
|
||||
def param(name, val, middle=""):
|
||||
val = str(val)
|
||||
if "\n" in val:
|
||||
val = val.replace("\n", "\n" + " " * (len(name) + 6))
|
||||
return "param {}{} := {};".format(name, middle, val)
|
84
model.glpm
84
model.glpm
@ -1,84 +0,0 @@
|
||||
/* 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;
|
||||
param ML, integer, > 0;
|
||||
|
||||
set P := 1..P_count;
|
||||
set J := 1..J_count;
|
||||
set D := 1..D_count;
|
||||
|
||||
/* aanwezigheid x workload for that day */
|
||||
param Costs{p in P}, integer, >= 0;
|
||||
|
||||
/* 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{d in D, j in J}, integer, >= 0;
|
||||
|
||||
/* hardcoded */
|
||||
param Q{p in P, j in J, d in D}, default 0, binary;
|
||||
|
||||
/* workload */
|
||||
param Wl{j in J}, integer, >= 0;
|
||||
|
||||
param max_load{p in P, d in D}, default 1, integer;
|
||||
|
||||
/* Person p is allocated to do job j on day d */
|
||||
var A{p in P, j in J, d in D}, binary;
|
||||
|
||||
var error{p in P}, integer, >= 0;
|
||||
|
||||
s.t. hardcode{p in P, j in J, d in D}: A[p,j,d] >= Q[p,j,d];
|
||||
|
||||
/* 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] <= max_load[p,d];
|
||||
|
||||
/* A person has at least 1 task */
|
||||
s.t. min_load_person{p in P}: sum{j in J, d in D} A[p,j,d] >= 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;
|
||||
|
||||
s.t. max_load_person_total{p in P}: (sum{d in D, j in J} A[p,j,d] * Wl[j]) <= ML;
|
||||
|
||||
/* Each task is allocated */
|
||||
s.t. all_allocated{j in J, d in D}: sum{p in P} A[p,j,d] == R[d, j];
|
||||
|
||||
/* 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];
|
||||
|
||||
s.t. error_lt{p in P}: error[p] >= ((sum{j in J, d in D} A[p,j,d] * Wl[j]) - Costs[p]);
|
||||
s.t. error_gt{p in P}: error[p] >= Costs[p] - (sum{j in J, d in D} A[p,j,d] * Wl[j]);
|
||||
|
||||
/* Maximize enjoyment */
|
||||
# minimize error_diff: sum{p in P} error[p];
|
||||
maximize enjoyment: (sum{p in P, d in D, j in J} A[p,j,d] * (L[p, j] * WL - H[p, j] * WH)) - sum{p in P} error[p];
|
||||
solve;
|
||||
|
||||
printf "Sum %d\n", (sum{p in P, d in D, j in J} A[p,j,d] * (L[p, j] * WL - H[p, j] * WH));
|
||||
printf "p d j W l\n";
|
||||
printf ">>>>\n";
|
||||
printf{p in P, d in D, j in J : A[p,j,d] > 0} "%d %d %d %d %d\n", p, d, j, A[p,j,d] * (L[p, j] * WL - H[p, j] * WH), Wl[j];
|
||||
printf "<<<<\n";
|
||||
printf "workloads\n";
|
||||
printf "p l\n";
|
||||
printf{p in P} "%d %d\n", p, abs((sum{j in J, d in D : A[p,j,d] > 0} Wl[j]) - Costs[p]);
|
||||
printf "workload_dev: %d\n", sum{p in P} abs((sum{j in J, d in D : A[p,j,d] > 0} Wl[j]) - Costs[p])^2;
|
||||
|
||||
|
||||
end;
|
Loading…
Reference in New Issue
Block a user