Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*array[1..5, 1..3] of var 0..1: assignment;
- constraint forall(i in 1..5)(sum(j in 1..3)(assignment[i,j]) = 1);
- constraint forall(j in 1..3)(sum(i in 1..5)(assignment[i,j]) <= 2);
- solve minimize sum(i in 1..5, j in 1..3)(cost[i,j] * assignment[i,j]);*/
- int: cnt_workers = 5;
- int: cnt_tasks = 3;
- set of int: workers = 1..cnt_workers;
- set of int: tasks = 1..cnt_tasks;
- array[workers, tasks] of int: cost;
- array[workers, tasks] of var 0..1: as;
- array[tasks] of var 0..2: w_on_t;
- constraint forall(w in workers)(
- sum(t in tasks)(as[w, t]) = 1
- );
- constraint forall(t in tasks)(
- w_on_t[t] = sum(w in workers)(as[w, t])
- );
- constraint forall(t in tasks)(
- w_on_t[t] <= 2
- );
- var int: ans = sum(w in workers, t in tasks)(cost[w, t] * as[w, t]);
- solve minimize ans;
Advertisement
Add Comment
Please, Sign In to add comment