transport_gdx.py File Reference

Go to the source code of this file.

Variables

 transport_gdx.ws = GamsWorkspace(system_directory = sys.argv[1])
 
list transport_gdx.plants = [ "Seattle", "San-Diego" ]
 
list transport_gdx.markets = [ "New-York", "Chicago", "Topeka" ]
 
dictionary transport_gdx.capacity = { "Seattle": 350.0, "San-Diego": 600.0 }
 
dictionary transport_gdx.demand = { "New-York": 325.0, "Chicago": 300.0, "Topeka": 275.0 }
 
dictionary transport_gdx.distance
 
 transport_gdx.db = ws.add_database()
 
 transport_gdx.i = db.add_set("i", 1, "canning plants")
 
 transport_gdx.j = db.add_set("j", 1, "markets")
 
 transport_gdx.a = db.add_parameter_dc("a", [i], "capacity of plant i in cases")
 
 transport_gdx.value
 
 transport_gdx.b = db.add_parameter_dc("b", [j], "demand at market j in cases")
 
 transport_gdx.d = db.add_parameter_dc("d", [i,j], "distance in thousands of miles")
 
 transport_gdx.f = db.add_parameter("f", 0, "freight in dollars per case per thousand miles")
 
 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.