iiasa / ixmp

The ix modeling platform for integrated and cross-cutting scenario analysis
https://docs.messageix.org/ixmp
Apache License 2.0
38 stars 111 forks source link

Support non-GAMS models #119

Open khaeru opened 5 years ago

khaeru commented 5 years ago

Scenario.solve() ends with the following lines: https://github.com/iiasa/ixmp/blob/aa7b2fee69b7c9a5b0c5736abf7dbf5cda55262b/ixmp/core.py#L1234-L1238

In order to support other, non-GAMS models, the following changes could be made:

  1. Extend and generalize the code in ixmp.model_settings, adding:
    • a new ixmp.model.Model abstract class,
    • an ixmp.model.GAMSModel subclass.
  2. Change Scenario.to_gdx(…) to GAMSModel.write_data(scenario, …).
  3. Change run_gams(…) to GAMSModel.run(scenario, …).
  4. Change Scenario.read_sol_from_gdx(…) to GAMSModel.read_solution(scenario, …).

After this, users would be able to run non-GAMS models by subclassing ixmp.Model() and implementing the methods write_data(), run(), and read_sol_from_gdx().

As identified here in the discussion of #108.

khaeru commented 5 years ago

Here's a modified version of Dantzig's cannery/transport problem from the Julia/JuMP optimization examples: cannery.jl.txt

To check that Model has been properly abstracted, a test could be written calling this through a JuliaModel class.

khaeru commented 4 years ago

The branch feature/pyomo-model contains some experimental code using Pyomo.