g2np_example1.py File Reference

Go to the source code of this file.

Functions

def g2np_example1.get_model_text ()
 

Variables

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

Detailed Description

This example is derived from transport4.py and uses the gams2numpy API. The example demonstrates...

  • How to prepare a GamsDatabase from numpy arrays
  • How to retrieve the results of a GamsJob as numpy array

Definition in file g2np_example1.py.