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 active filter to flattener #2643

Merged
merged 27 commits into from
Feb 15, 2023
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3a9a4e2
apply jsiirolas patch in #2529 to flatten.py
Robbybp Nov 30, 2022
e8343e6
add active flag to flatten_components_along_sets
Robbybp Dec 1, 2022
f63deea
add active flag to flatten_dae_components
Robbybp Dec 1, 2022
d752461
start some documentation for flattener
Robbybp Dec 4, 2022
ee21825
improve docstrings
Robbybp Dec 4, 2022
f73d821
flattener api reference documentation
Robbybp Dec 4, 2022
f031e1d
add doc on motivation for flattener
Robbybp Dec 4, 2022
2224c22
start tests for flattener with deactivated blocks
Robbybp Dec 4, 2022
254da6c
uncomment code testing with active=False
Robbybp Dec 4, 2022
ff1cbd9
only pass active flag to component_objects if ctype is an ActiveCompo…
Robbybp Dec 4, 2022
4d8f911
use common function to build model in tests
Robbybp Dec 7, 2022
6a15bf9
put hashref method on common base class
Robbybp Dec 7, 2022
803872d
make sure slices have at least one active data before yielding
Robbybp Dec 7, 2022
a71f770
tests for partially deactived slices and constraints
Robbybp Dec 7, 2022
4569bb7
clarify how active is handled for slices
Robbybp Dec 7, 2022
c8ba427
Merge branch 'main' of https://github.com/pyomo/pyomo into flatten-ac…
Robbybp Dec 7, 2022
478f836
do not attempt to iterate if no slicing has been performed
Robbybp Dec 7, 2022
5d607e3
make sure we sliced at least one set before attempting to duplicate
Robbybp Dec 8, 2022
9230de7
tests to exercise generating scalar constraints with active flag
Robbybp Dec 8, 2022
4df9b31
Merge branch 'main' into flatten-active-blocks
Robbybp Dec 9, 2022
6d10061
Merge branch 'main' into flatten-active-blocks
Robbybp Jan 17, 2023
242c4cb
Merge branch 'main' into flatten-active-blocks
blnicho Jan 27, 2023
a416b24
Merge branch 'main' into flatten-active-blocks
Robbybp Feb 1, 2023
a3a367a
Merge branch 'main' into flatten-active-blocks
Robbybp Feb 7, 2023
d2fe6e3
Merge branch 'main' into flatten-active-blocks
blnicho Feb 13, 2023
3948155
Merge branch 'main' into flatten-active-blocks
Robbybp Feb 14, 2023
dbfd792
Addressing reviewer comments
blnicho Feb 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions pyomo/dae/flatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,19 @@ def generate_sliced_components(
# slice. If any match, we yield the slice. This is done for
# compatibility with the behavior when slicing blocks, where
# we can only descend into a block that matches our active flag.
if not check_active or any(
data.active == c_active for data in new_slice.duplicate()
#
# Note that new_slice can be a data object. This happens if the
# component doesn't contain any sets we are slicing, i.e. new_sets
# is empty.
if (
# Yield if (a) we're not checking activity
not check_active
# or (b) we have not sliced and data object activity matches
or (not sliced_sets and new_slice.active == c_active)
# or (c) we did slice and *any* data object activity matches
or any(
data.active == c_active for data in new_slice.duplicate()
)
Robbybp marked this conversation as resolved.
Show resolved Hide resolved
):
yield sliced_sets, new_slice

Expand Down