-
Notifications
You must be signed in to change notification settings - Fork 2
#611: Implement all update formulae and make them optionally usable #612
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
Draft
ppebay
wants to merge
10
commits into
develop
Choose a base branch
from
611-implement-all-update-formulae-and-make-them-optionally-usable
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a52a6c3
#611: added the WIP tempered with updates criterion not added so far
ppebay 6e2f8b2
#611: pushing the part that now works (still incomplete)
ppebay 3755001
#611: WS cleanup
ppebay e99780d
#611: pushed part of the update formulae that work prior to meeting
ppebay b0e61aa
#611: added documentation for update code that is complex
ppebay 79ace7a
#611: finally resolved the hidden bug in the off rank communication u…
ppebay 32306e0
#611: WS cleanup
ppebay b577200
#611: values of alpha/beta/delta that exercise load+off-rank comm+homing
ppebay ee43344
#611: restored synthetic block default config as per PR review
ppebay fb8426a
#613: cherry picked changes where the memory error was serendipitousl…
ppebay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # | ||
| #@HEADER | ||
| ############################################################################### | ||
| # | ||
| # lbsTemperedWithUpdatesCriterion.py | ||
| # DARMA/LB-analysis-framework => LB Analysis Framework | ||
| # | ||
| # Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC | ||
| # (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. | ||
| # Government retains certain rights in this software. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # | ||
| # * Redistributions of source code must retain the above copyright notice, | ||
| # this list of conditions and the following disclaimer. | ||
| # | ||
| # * Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # | ||
| # * Neither the name of the copyright holder nor the names of its | ||
| # contributors may be used to endorse or promote products derived from this | ||
| # software without specific prior written permission. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
| # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| # POSSIBILITY OF SUCH DAMAGE. | ||
| # | ||
| # Questions? Contact [email protected] | ||
| # | ||
| ############################################################################### | ||
| #@HEADER | ||
| # | ||
| from logging import Logger | ||
| from typing import Optional | ||
|
|
||
| from .lbsCriterionBase import CriterionBase | ||
| from ..Model.lbsRank import Rank | ||
|
|
||
|
|
||
| class TemperedWithUpdatesCriterion(CriterionBase): | ||
| """A concrete class for the Grapevine criterion with update formulae.""" | ||
|
|
||
| def __init__(self, work_model, lgr: Logger): | ||
| """Class constructor.""" | ||
| # Call superclass init | ||
| super().__init__(work_model, lgr) | ||
| self._logger.info(f"Instantiated {type(self).__name__} concrete criterion") | ||
|
|
||
| def compute(self, r_src: Rank, o_src: list, r_dst: Rank, o_dst: Optional[list]=None) -> float: | ||
| """Tempered work criterion based on L1 norm of works using update formulae.""" | ||
| if o_dst is None: | ||
| o_dst = [] | ||
|
|
||
| # Compute maximum work of original arrangement | ||
| w_max_0 = max( | ||
| self._work_model.compute(r_src), | ||
| self._work_model.compute(r_dst)) | ||
|
|
||
| # Compute update formulae | ||
| w_max_up = max( | ||
| w1 := self._work_model.update(r_src, o_src, o_dst), | ||
| w2 := self._work_model.update(r_dst, o_dst, o_src)) | ||
|
|
||
| # Move objects into proposed new arrangement | ||
| self._phase.transfer_objects(r_src, o_src, r_dst, o_dst) | ||
|
|
||
| # Compute maximum work of proposed new arrangement | ||
| w_max_new = max( | ||
| w3 := self._work_model.compute(r_src), | ||
| w4 := self._work_model.compute(r_dst)) | ||
|
|
||
| # Move objects back into original arrangement | ||
| self._phase.transfer_objects(r_dst, o_src, r_src, o_dst) | ||
|
|
||
| # Sanity check | ||
| if w_max_new != w_max_up: | ||
| self._logger.error(f"Discrepancy in post update works: {w_max_new} <> {w_max_up}") | ||
| print(w1, w3) | ||
| print(w2, w4) | ||
| raise SystemExit(1) | ||
|
|
||
| # Return criterion value | ||
| return w_max_0 - w_max_new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.