#Code for Example 3 - Rectinilear multifacility minisum problem param n, default 2; param m, default 3; set New := 1..n; set Old := 1..m; var x{j in New}, >=0; var p{j in New, k in New: j < k}, >=0; var q{j in New, k in New: j < k}, >=0; var r{j in New, i in Old}, >= 0; var s{j in New, i in Old}, >=0; param v{j in New, k in New}; param w{j in New, i in Old}; param a{i in Old}; minimize f: sum{j in New, k in New: j < k} v[j,k] * (p[j,k] + q[j,k]) + sum {j in New, i in Old} w[j,i] * (r[j,i] + s[j,i]); s.t. NewNew {j in New, k in New: j < k}: x[j] - x[k] = p[j,k] - q[j,k]; s.t. NewOld {j in New, i in Old}: x[j] - a[i] = r[j,i] - s[j,i]; s.t. Test{j in New}: x[j]= 20; solve; display f, x; data; param n:= 2; param m:= 3; param a:= 1 10 2 20 3 40; param v:= 110 122 210 2 2 0; param w := 112 121 130 214 220 2 3 5; end;