Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MacroEnergySystemsScaling.jl #792

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

RuaridhMacd
Copy link
Collaborator

Description

This PR adds automatic problem scaling using MacroEnergySystemsScaling.jl package. This allows the ParameterScale features to be removed.

While full reformulation of a model is preferable to using scaling, this is not feasible in the workflow that most users go through in building and running GenX models. By calling scale_constraints!(EP), MacroEnergySystemsScaling.jl will re-scale all constraints so that the variable coefficients and right-hand side constants are within user-specified bounds. This usually improves the numerical stability, and occasionally runtime, of a model.

This PR:

  • Adds MacroEnergySystemsScaling.jl
  • Creates a new binary setting, AutoScaling, to activate model scaling
  • If AutoScaling == 1, single stage models will be scaled. I'm not sure how this will work with multi-stage models so have left that for now.
  • Optional additional settings can be passed using the setting names and types described in the MacroEnergySystemsScaling.jl documentation.
  • I've updated the GenX documentation to describe the AutoScaling feature
  • I set AutoScaling to 1 in the 1_three_zones example. It is not present in the others.
  • I've removed all use of ParameterScale and scale_factor, and updated the documentation correspondingly.

Note, MacroEnergySystemsScaling.jl does not appear to work well with JuMP direct_model(). It only works well with JuMP Model(), which is currently what GenX uses to create models.

What type of PR is this? (check all applicable)

  • Feature
  • Bug Fix
  • Documentation Update
  • Code Refactor
  • Performance Improvements

Related Tickets & Documents

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and .md files under /docs/src have been updated if necessary.
  • The latest changes on the target branch have been incorporated, so that any conflicts are taken care of before merging. This can be accomplished either by merging in the target branch (e.g. 'git merge develop') or by rebasing on top of the target branch (e.g. 'git rebase develop'). Please do not hesitate to reach out to the GenX development team if you need help with this.
  • Code has been tested to ensure all functionality works as intended.
  • CHANGELOG.md has been updated (if this is a 'notable' change).
  • I consent to the release of this PR's code under the GNU General Public license.

How this can be tested

To test this, I recommend

  • Run an example with and without the AutoScaling setting and compare the results.
  • Add additional settings to check that the coefficient matrix is altered correctly, as reported by HiGHs or Gurobi
  • Add additional settings which will lead to the coefficient matrix not being scaled, i.e. setting very large or small coefficient bounds.

Post-approval checklist for GenX core developers

After the PR is approved

  • Check that the latest changes on the target branch are incorporated, either via merge or rebase
  • Remember to squash and merge if incorporating into develop

@lbonaldo lbonaldo added the enhancement New feature or request label Dec 3, 2024
@RuaridhMacd
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants