Go to the documentation of this file.
16 if Optimizer.ws ==
None:
18 Optimizer.ws = GamsWorkspace(system_directory = sys.argv[1])
20 Optimizer.ws = GamsWorkspace()
23 db = Optimizer.ws.add_database()
24 f = db.add_parameter(
"f", 0,
"freight in dollars per case per thousand miles")
25 f.add_record().value = 90 * mult
26 job = Optimizer.ws.add_job_from_string(Optimizer.get_model_text())
27 opt = Optimizer.ws.add_options()
28 opt.defines[
"gdxincname"] = db.name
29 job.run(opt,databases=db)
31 return job.out_db.get_variable(
"z").first_record().level
37 i canning plants / seattle, san-diego /
38 j markets / new-york, chicago, topeka / ;
42 a(i) capacity of plant i in cases
46 b(j) demand at market j in cases
51 Table d(i,j) distance in thousands of miles
52 new-york chicago topeka
54 san-diego 2.5 1.8 1.4 ;
56 Scalar f freight in dollars per case per thousand miles;
58 $if not set gdxincname $abort 'no include file name for data file provided'
63 Parameter c(i,j) transport cost in thousands of dollars per case ;
65 c(i,j) = f * d(i,j) / 1000 ;
68 x(i,j) shipment quantities in cases
69 z total transportation costs in thousands of dollars ;
74 cost define objective function
75 supply(i) observe supply limit at plant i
76 demand(j) satisfy demand at market j ;
78 cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ;
80 supply(i) .. sum(j, x(i,j)) =l= a(i) ;
82 demand(j) .. sum(i, x(i,j)) =g= b(j) ;
84 Model transport /all/ ;
86 Solve transport using lp minimizing z ;
88 Display x.l, x.m ; '''
91 if __name__ ==
"__main__":
92 bmultlist = [0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3]
94 lock = threading.Lock()
97 obj = optim.solve(bmult)
99 print(
"Scenario bmult=" + str(bmult) +
", Obj:" + str(obj))
102 for bmult
in bmultlist:
103 t = threading.Thread(target=run_scenario, args=(optim, bmult))
def run_scenario(optim, bmult)