g2np_example2.py File Reference

Go to the source code of this file.


def g2np_example2.get_model_text ()


 g2np_example2.ws = GamsWorkspace(system_directory = sys.argv[1])
 g2np_example2.plants = np.array([["Seattle", ""], ["San-Diego", ""]])
 g2np_example2.markets = np.array([["New-York", ""], ["Chicago", ""], ["Topeka", ""]])
 g2np_example2.capacity = np.array([["Seattle", 350.0], ["San-Diego", 600.0]], dtype=object)
 g2np_example2.demand = np.array([["New-York", 325.0], ["Chicago", 300.0], ["Topeka", 275.0]], dtype=object)
 g2np_example2.gdx = new_gdxHandle_tp()
 g2np_example2.g2np = gams2numpy.Gams2Numpy(ws.system_directory)
 g2np_example2.opt = ws.add_options()
 g2np_example2.job = ws.add_job_from_string(get_model_text())

Detailed Description

This example uses the gams2numpy API in order to demonstrate...

  • How to prepare a GDX file from numpy arrays
  • How to run a job using data from GDX
  • How to export the results of a GamsJob to GDX and read them into numpy arrays

Definition in file g2np_example2.py.