g2np_example1 Namespace Reference

Functions

def get_model_text ()
 

Variables

 ws = GamsWorkspace(system_directory = sys.argv[1])
 
 plants = np.array([["Seattle", ""], ["San-Diego", ""]])
 
 markets = np.array([["New-York", ""], ["Chicago", ""], ["Topeka", ""]])
 
 capacity = np.array([["Seattle", 350.0], ["San-Diego", 600.0]], dtype=object)
 
 demand = np.array([["New-York", 325.0], ["Chicago", 300.0], ["Topeka", 275.0]], dtype=object)
 
 distance
 
 db = ws.add_database()
 
 g2np = gams2numpy.Gams2Numpy(ws.system_directory)
 
 i = db.add_set("i", 1, "canning plants")
 
 j = db.add_set("j", 1, "markets")
 
 a = db.add_parameter_dc("a", [i], "capacity of plant i in cases")
 
 b = db.add_parameter_dc("b", [j], "demand at market j in cases")
 
 d = db.add_parameter_dc("d", [i,j], "distance in thousands of miles")
 
 f = db.add_parameter("f", 0, "freight in dollars per case per thousand miles")
 
 job = ws.add_job_from_string(get_model_text())
 
 opt = ws.add_options()
 
 all_model_types
 
 databases
 

Function Documentation

◆ get_model_text()

def g2np_example1.get_model_text ( )

Definition at line 14 of file g2np_example1.py.

14def get_model_text():
15  return '''
16  Sets
17  i canning plants
18  j markets
19 
20  Parameters
21  a(i) capacity of plant i in cases
22  b(j) demand at market j in cases
23  d(i,j) distance in thousands of miles
24  Scalar f freight in dollars per case per thousand miles;
25 
26 $if not set gdxincname $abort 'no include file name for data file provided'
27 $gdxin %gdxincname%
28 $load i j a b d f
29 $gdxin
30 
31  Parameter c(i,j) transport cost in thousands of dollars per case ;
32 
33  c(i,j) = f * d(i,j) / 1000 ;
34 
35  Variables
36  x(i,j) shipment quantities in cases
37  z total transportation costs in thousands of dollars ;
38 
39  Positive Variable x ;
40 
41  Equations
42  cost define objective function
43  supply(i) observe supply limit at plant i
44  demand(j) satisfy demand at market j ;
45 
46  cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ;
47 
48  supply(i) .. sum(j, x(i,j)) =l= a(i) ;
49 
50  demand(j) .. sum(i, x(i,j)) =g= b(j) ;
51 
52  Model transport /all/ ;
53 
54  Solve transport using lp minimizing z ;
55 
56  Display x.l, x.m ; '''
57 
58 

Variable Documentation

◆ a

g2np_example1.a = db.add_parameter_dc("a", [i], "capacity of plant i in cases")

Definition at line 85 of file g2np_example1.py.

◆ all_model_types

g2np_example1.all_model_types

Definition at line 101 of file g2np_example1.py.

◆ b

g2np_example1.b = db.add_parameter_dc("b", [j], "demand at market j in cases")

Definition at line 88 of file g2np_example1.py.

◆ capacity

g2np_example1.capacity = np.array([["Seattle", 350.0], ["San-Diego", 600.0]], dtype=object)

Definition at line 67 of file g2np_example1.py.

◆ d

g2np_example1.d = db.add_parameter_dc("d", [i,j], "distance in thousands of miles")

Definition at line 91 of file g2np_example1.py.

◆ databases

g2np_example1.databases

Definition at line 103 of file g2np_example1.py.

◆ db

g2np_example1.db = ws.add_database()

Definition at line 76 of file g2np_example1.py.

◆ demand

g2np_example1.demand = np.array([["New-York", 325.0], ["Chicago", 300.0], ["Topeka", 275.0]], dtype=object)

Definition at line 68 of file g2np_example1.py.

◆ distance

g2np_example1.distance
Initial value:
1= np.array([["Seattle", "New-York", 2.5],
2  ["Seattle", "Chicago", 1.7],
3  ["Seattle", "Topeka", 1.8],
4  ["San-Diego", "New-York", 2.5],
5  ["San-Diego", "Chicago", 1.8],
6  ["San-Diego", "Topeka", 1.4]], dtype=object)

Definition at line 69 of file g2np_example1.py.

◆ f

g2np_example1.f = db.add_parameter("f", 0, "freight in dollars per case per thousand miles")

Definition at line 94 of file g2np_example1.py.

◆ g2np

g2np_example1.g2np = gams2numpy.Gams2Numpy(ws.system_directory)

Definition at line 77 of file g2np_example1.py.

◆ i

g2np_example1.i = db.add_set("i", 1, "canning plants")

Definition at line 79 of file g2np_example1.py.

◆ j

g2np_example1.j = db.add_set("j", 1, "markets")

Definition at line 82 of file g2np_example1.py.

◆ job

g2np_example1.job = ws.add_job_from_string(get_model_text())

Definition at line 97 of file g2np_example1.py.

◆ markets

g2np_example1.markets = np.array([["New-York", ""], ["Chicago", ""], ["Topeka", ""]])

Definition at line 66 of file g2np_example1.py.

◆ opt

g2np_example1.opt = ws.add_options()

Definition at line 98 of file g2np_example1.py.

◆ plants

g2np_example1.plants = np.array([["Seattle", ""], ["San-Diego", ""]])

Definition at line 65 of file g2np_example1.py.

◆ ws

g2np_example1.ws = GamsWorkspace(system_directory = sys.argv[1])

Definition at line 61 of file g2np_example1.py.

def get_model_text()
Definition: warehouse.py:16