No Matches
g2np_example1.py File Reference

This example is derived from transport4.py and uses the gams.numpy API. More...

Go to the source code of this file.


str g2np_example1.GAMS_MODEL
sys g2np_example1.sys_dir = sys.argv[1] if len(sys.argv) > 1 else None
GamsWorkspace g2np_example1.ws = GamsWorkspace(system_directory=sys_dir)
np g2np_example1.plants = np.array([["Seattle", ""], ["San-Diego", ""]])
np g2np_example1.markets = np.array([["New-York", ""], ["Chicago", ""], ["Topeka", ""]])
np g2np_example1.capacity = np.array([["Seattle", 350.0], ["San-Diego", 600.0]], dtype=object)
np g2np_example1.demand
np g2np_example1.distance
GamsWorkspace g2np_example1.db = ws.add_database()
gnp g2np_example1.gams2np = gnp.Gams2Numpy(ws.system_directory)
GamsWorkspace g2np_example1.i = db.add_set("i", 1, "canning plants")
GamsWorkspace g2np_example1.j = db.add_set("j", 1, "markets")
GamsWorkspace g2np_example1.a = db.add_parameter_dc("a", [i], "capacity of plant i in cases")
GamsWorkspace g2np_example1.b = db.add_parameter_dc("b", [j], "demand at market j in cases")
GamsWorkspace g2np_example1.d = db.add_parameter_dc("d", [i, j], "distance in thousands of miles")
GamsWorkspace g2np_example1.f = db.add_parameter("f", 0, "freight in dollars per case per thousand miles")
GamsWorkspace g2np_example1.job = ws.add_job_from_string(GAMS_MODEL)
GamsWorkspace g2np_example1.opt = ws.add_options()

Detailed Description

This example is derived from transport4.py and uses the gams.numpy 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.