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

Scaler #667

Merged
merged 16 commits into from
Apr 3, 2024
Merged

Scaler #667

merged 16 commits into from
Apr 3, 2024

Conversation

Betristor
Copy link
Contributor

Description

Sometimes the model will be built into an ill form if some objective terms are quite large or small. To alleviate this problem, we could add a scaling factor to scale the objective function during solving while leaving all other expressions untouched. In example_systems/1_three_zones case, an example ObjScale of 10 could help to change the objective range from [1e-4, 6e+02] to [1e-3, 6e+03].

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

Add the setting key ObjScale with an appropriate value to genx_settings.yml in any test cases. The objective function will be scaled accordingly.

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

Copy link
Collaborator

@sambuddhac sambuddhac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please mention a concrete example in which the ObjScale is something other than 1? I am failing to understand where exactly the current code-base is having problem? We already have a ParameterScale as @JesseJenkins mentioned in his response to the associated issue. In this PR you have kept the scaling factor to 1 and yet you mentioned in the description that the objective needs to be scaled. So, I am unable to understand. Have you tried using the ParameterScale that's already there in GenX?

@sambuddhac sambuddhac linked an issue Mar 27, 2024 that may be closed by this pull request
@Betristor
Copy link
Contributor Author

@sambuddhac Yes, I have considered ParameterScale setting but this option will scale nearly all the data and parameters we use during the model construction and sequentially influence the outputs since the physical meaning (units) of outputs are scaled. Indeed this ParameterScale setting could help alleviate possible numerical issues in the model, but we still need to face the inconvenience of additional loading burden and output interpretation. While ObjScale operates at a higher level by scaling the objective expression directly, avoiding manipulating inputs and outputs.
As for an example, example_systems/2_three_zones_w_electrolyzer case with a ObjScale value of 100 could help to change the objective range from [6e-07, 7e+02] to [6e-03, 7e+04] (similar to example_systems/1_three_zones case mentioned above). But I left the key default as 1 to have examples unchanged.

@sambuddhac
Copy link
Collaborator

@nspatank I am assigning this to in order to respond.

With modified scaler definition, mentioning that it addresses problem ill-conditioning
@sambuddhac sambuddhac changed the base branch from main to release/0.4.0 April 3, 2024 15:49
@sambuddhac sambuddhac merged commit 8d9b7ef into GenXProject:release/0.4.0 Apr 3, 2024
6 checks passed
@Betristor Betristor deleted the Scaler branch April 17, 2024 12:52
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.

Add objective scale to improve numeric efficiency
4 participants