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

reconciling #71 and #73 for #69 #74

Merged
merged 2 commits into from
Aug 1, 2023
Merged

reconciling #71 and #73 for #69 #74

merged 2 commits into from
Aug 1, 2023

Conversation

jcrozum
Copy link
Owner

@jcrozum jcrozum commented Jul 25, 2023

This supersedes #73; we should merge this PR and close #73 when we are ready.

@jcrozum
Copy link
Owner Author

jcrozum commented Jul 25, 2023

Note that most of the changes in this PR are cosmetic (type-checking & linting stuff). The functional changes are in the two new files (control.py and control_test.py).

@github-actions
Copy link

github-actions bot commented Jul 25, 2023

Coverage

Coverage Report
FileStmtsMissCoverMissing
nfvsmotifs
   SuccessionDiagram.py154497%6–7, 208, 452
   control.py1201389%47, 56, 60, 66, 80, 89–105, 319, 334
   interaction_graph_utils.py142894%6–9, 57, 70, 95–96
   motif_avoidant.py163696%23–24, 130, 147, 184, 309
   petri_net_translation.py84693%23–24, 52, 63–64, 94
   pyeda_utils.py953464%12, 56–66, 90, 95, 98–112, 140–144
   space_utils.py118596%15–16, 198, 213, 270
   state_utils.py681282%15, 55–66, 98, 105, 114
   terminal_restriction_space.py44393%6–7, 80
   trappist_core.py1862089%10–11, 39, 41, 81, 127, 192, 194, 196, 231–233, 259, 317, 319, 349, 389, 391, 422, 451
nfvsmotifs/FVSpython3
   FVS.py481079%90–91, 97, 133, 183–189
   FVS_localsearch_10_python.py90199%179
nfvsmotifs/_sd_algorithms
   compute_attractor_seeds.py29197%6
   expand_attractor_seeds.py51492%6, 95–100
   expand_bfs.py28196%6
   expand_dfs.py30197%6
   expand_minimal_spaces.py37197%6
   expand_to_target.py30390%6, 37, 42
TOTAL161413392% 

Tests Skipped Failures Errors Time
360 0 💤 0 ❌ 0 🔥 2m 42s ⏱️

@jcrozum
Copy link
Owner Author

jcrozum commented Jul 25, 2023

@daemontus I'm requesting your review just to make sure I didn't break anything you added in #71.
@troonmel Please double check that the logic in the control tests (control_test.py) makes sense.

target=target,
)

for s in cast(list[int], succession_diagram.G.nodes()):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could be succession_diagram.node_ids() and succession_diagram.node_space(s). It's not faster, but it ensures the casts are limited to the SuccessionDiagram class (it should make it easier to refactor SuccessionDiagram if we need to do that at some point).

)
is_last_needed = set(target) <= set(fixed_vars)

if not is_consistent or not is_last_needed:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not quite sure, but wouldn't this be equivalent to not space_utils.is_subspace(fixed_vars, target)?

),
):
succession = [
cast(dict[str, int], succession_diagram.G.edges[x, y]["motif"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe SuccessionDiagram.edge_stable_motif(x,y)?

@daemontus
Copy link
Collaborator

I think everything looks good, I just made a few comments in places where I believe we can make a better use of the existing utility functions :) Feel free to merge once these are fixed or if you believe these are not justified.

@jcrozum
Copy link
Owner Author

jcrozum commented Jul 26, 2023

These are good changes. I'll implement them and make sure it all still works.
Edit: this is done now.

Copy link
Collaborator

@kyuhyongpark kyuhyongpark left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. I was travelling back to the US.

I'm a little confused about how the successions should look like in case of external drivers with/out constant nodes. I put a possible example that could clarify this.

assert all([controls_are_equal(a, b) for a, b in zip(cs, drivers)])

target_succession = [
{"E": 1},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you elaborate a bit on why E=1 should be a separate succession? Should it always be a separate succession if a constant node has to be fixed into its opposite state?

Copy link
Owner Author

Choose a reason for hiding this comment

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

In this test, target_succession is the sequence of nested trap spaces that I want to drive the system toward. In other words, it can be arbitrary. This part of the test is highlighting that it still works even when the succession you're trying to reach is not part of the natural dynamics.

A, S | B
B, A
C, A | D
D, C
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about changing this to "D, C | E" so that there is a possible external control? What I'm not sure about is how the successions should look like in this case.

Copy link
Owner Author

Choose a reason for hiding this comment

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

This one already has an external control: {"A": 1} and {"B": 1} are external controls for {"C": 1, "D": 1}

Copy link
Owner Author

Choose a reason for hiding this comment

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

Although, now that I think about it, I'm not sure how the code would handle the possibility of overriding constant nodes. I suspect it would not find these cases.

@jcrozum jcrozum merged commit 835e19d into main Aug 1, 2023
6 checks passed
@jcrozum jcrozum deleted the control-with-lazy-diagram branch August 2, 2023 18:15
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.

None yet

3 participants