Loading...
Searching...
No Matches
transport_gdx.py File Reference

This example shows the use of the GamsDatabase class for reading and writing GDX files. More...

Go to the source code of this file.

Variables

sys transport_gdx.sys_dir = sys.argv[1] if len(sys.argv) > 1 else None
 
GamsWorkspace transport_gdx.ws = GamsWorkspace(system_directory=sys_dir)
 
list transport_gdx.plants = ["Seattle", "San-Diego"]
 
list transport_gdx.markets = ["New-York", "Chicago", "Topeka"]
 
dict transport_gdx.capacity = {"Seattle": 350.0, "San-Diego": 600.0}
 
dict transport_gdx.demand = {"New-York": 325.0, "Chicago": 300.0, "Topeka": 275.0}
 
dict transport_gdx.distance
 
GamsWorkspace transport_gdx.db = ws.add_database()
 
GamsWorkspace transport_gdx.i = db.add_set("i", 1, "canning plants")
 
GamsWorkspace transport_gdx.j = db.add_set("j", 1, "markets")
 
GamsWorkspace transport_gdx.a = db.add_parameter_dc("a", [i], "capacity of plant i in cases")
 
 transport_gdx.value
 
GamsWorkspace transport_gdx.b = db.add_parameter_dc("b", [j], "demand at market j in cases")
 
GamsWorkspace transport_gdx.d = db.add_parameter_dc("d", [i, j], "distance in thousands of miles")
 
GamsWorkspace transport_gdx.f = db.add_parameter("f", 0, "freight in dollars per case per thousand miles")
 
GamsWorkspace transport_gdx.db2 = ws.add_database_from_gdx("data.gdx")
 

Detailed Description

This example shows the use of the GamsDatabase class for reading and writing GDX files.

In particular this example shows:

  • How to fill a GamsDatabase from Python data structures and export it to a GDX file
  • How to import a GDX file as a GamsDatabase

Definition in file transport_gdx.py.