14 i canning plants / seattle, san-diego /
15 j markets / new-york, chicago, topeka / ;
19 a(i) capacity of plant i in cases
23 b(j) demand at market j in cases
28 Table d(i,j) distance in thousands of miles
29 new-york chicago topeka
31 san-diego 2.5 1.8 1.4 ;
33 Scalar f freight in dollars per case per thousand miles /90/ ;
34 Scalar bmult demand multiplier /1/;
36 Parameter c(i,j) transport cost in thousands of dollars per case ;
38 c(i,j) = f * d(i,j) / 1000 ;
41 x(i,j) shipment quantities in cases
42 z total transportation costs in thousands of dollars ;
47 cost define objective function
48 supply(i) observe supply limit at plant i
49 demand(j) satisfy demand at market j ;
51 cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ;
53 supply(i) .. sum(j, x(i,j)) =l= a(i) ;
55 demand(j) .. sum(i, x(i,j)) =g= bmult*b(j) ;
57 Model transport /all/ ;
58 Scalar ms 'model status', ss 'solve status'; '''
62 t6 = workspace.add_job_from_string(
"bmult=" + str(b) +
"; solve transport min z use lp; ms=transport.modelstat; ss=transport.solvestat;", checkpoint)
66 print(
"Scenario bmult=" + str(b) +
":")
67 print(
" Modelstatus: " + str(t6.out_db[
"ms"][()].value))
68 print(
" Solvestatus: " + str(t6.out_db[
"ss"][()].value))
69 print(
" Obj: " + str(t6.out_db[
"z"][()].level))
73 if __name__ ==
"__main__":
75 ws = GamsWorkspace(system_directory = sys.argv[1])
79 cp = ws.add_checkpoint()
84 bmultlist = [ 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3 ]
87 io_lock = threading.Lock()
90 threads[b] = threading.Thread(target=run_scenario, args=(ws, cp, io_lock, b))