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

fix: avoid error when scaling from scenario with slightly negative generation #128

Merged
merged 1 commit into from
Apr 3, 2020

Conversation

danielolsen
Copy link
Contributor

Purpose

Avoid an AssertionError when calling AbstractStrategyManager.populate_targets_with_resources() using a ScenarioInfo object based on a Scenario where prev_generation for a state/gentype evaluates to a slightly negative number. This can be seen when trying this on Scenario 409.

What is the code doing

Adding a small tolerance range to the negativity check in set_generation(), where if the value being passed is negative but within this tolerance, it is set to 0. Also adding more description to the error message on the assert.

Time to review

Extremely short, it's 5 lines of changes. It can be tested using Scenario 409: it should fail using develop but pass using this branch.

@danielolsen danielolsen added the bug Something isn't working label Apr 3, 2020
@BainanXia
Copy link
Collaborator

This implies that we may have some negative values in pg within the tolerance range (-1e-3~0) from the optimization results?

@danielolsen
Copy link
Contributor Author

Yes! The joy of the barrier method, it's fast but it returns a solution that is not actually at a vertex, merely within a given tolerance range of a vertex. For Scenario 409, the assertion complains about a value on the order of -3e-5.

@danielolsen danielolsen force-pushed the fix_gen_scaling_set_generation_tolerance branch from 07872d6 to 0096f39 Compare April 3, 2020 22:38
@danielolsen danielolsen merged commit 2c3254d into develop Apr 3, 2020
@danielolsen danielolsen deleted the fix_gen_scaling_set_generation_tolerance branch April 3, 2020 22:39
@ahurli ahurli mentioned this pull request Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants