message_ix icon indicating copy to clipboard operation
message_ix copied to clipboard

Add modelinstance support

Open Wegatriespython opened this issue 2 months ago • 3 comments

This is an experimental branch connected to IXMP PR adds support for the Gamsmodelinstance APIwhich provides a persistent model object for use.

Right now this is quite experimental, hence the code is not up to quality. The API for allowing user access is also not final. Putting it here for reference and feedback. For most models, model generation times dominate solving times. This means when a sequence of scenarios are to be evaluated in an ensemble a large fraction of the time is spent in the generation of the model matrix. Modelinstance provides a persistent object with an in-memory database for modifiable parameters via sync_db.

In theory this allows for gains = 1 + time_build/time_solving. For the baseline model time_build is ~500s and solve is 200s which yields a gain of 3.5X for large number of runs. Additionally the model instance passes the previous solution's basis to the next solution. In theory then a barrier followed by Simplex methods with advanced basis can approach even higher performance gains. But this requires dynamic solver parametrization maybe ML methods could help here.

How to review

At this point feedback and usage would be appreciated

PR checklist

Experimental so this will not apply till at least an early Alpha stage is reached.

~~- [ ] Continuous integration checks all ✅~~

~~- [ ] Add or expand tests; coverage checks both ✅~~ ~~- [ ] Add, expand, or update documentation.~~ ~~- [ ] Update release notes.~~

Wegatriespython avatar Oct 21 '25 13:10 Wegatriespython