Skip to content

Add modelinstance support #983

Draft
Wegatriespython wants to merge 3 commits intomainfrom
feat/gamsmodelinstance
Draft

Add modelinstance support #983
Wegatriespython wants to merge 3 commits intomainfrom
feat/gamsmodelinstance

Conversation

@Wegatriespython
Copy link
Copy Markdown

@Wegatriespython Wegatriespython commented Oct 21, 2025

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 Wegatriespython marked this pull request as draft October 21, 2025 13:41
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Wegatriespython Wegatriespython self-assigned this Oct 21, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.4%. Comparing base (12cf19e) to head (42fe0ae).
⚠️ Report is 56 commits behind head on main.

Files with missing lines Patch % Lines
message_ix/core.py 40.0% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #983     +/-   ##
=======================================
- Coverage   96.4%   96.4%   -0.1%     
=======================================
  Files         60      60             
  Lines       5135    5140      +5     
=======================================
+ Hits        4954    4955      +1     
- Misses       181     185      +4     
Files with missing lines Coverage Δ
message_ix/core.py 96.0% <40.0%> (-1.5%) ⬇️

... and 1 file with indirect coverage changes

@glatterf42
Copy link
Copy Markdown
Member

Same as iiasa/ixmp#605 (comment), I'd like to make sure that we don't create incompatibilities in our stack by having one official main version and an outdated version that we direct people to use (such as this branch). Do you know when you'll be able to continue here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants