Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Implement do #42

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

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Implement do #42

wants to merge 21 commits into from

Conversation

mscroggs
Copy link
Collaborator

@mscroggs mscroggs commented May 1, 2025

Implement a do algorithms that takes a graph and replaces a node with a constant ParameterNode and removes any edges going into that node.

As expectation and other algorithms already only iterate over ancestors of output nodes, there's no need to trim the graph further when applying a do.

Builds on #39, so is currently set to merge into that branch.

@mscroggs mscroggs changed the base branch from main to mscroggs/parameter-node May 1, 2025 06:45
Base automatically changed from mscroggs/parameter-node to main May 1, 2025 08:35
@willGraham01
Copy link
Collaborator

Pre-emptive note here: in #40 the ParameterNodes are always assumed to have values that will vary (see how parameter nodes are gathered here).

To avoid the solver accidentally picking up these constant parameters as values that should vary we could either:

  • ParameterNodes have another internal is_constant flag, that defaults to False but can be set to True. Then the aforementioned line checks if node.is_parameter and not node.is_constant.
  • ConstantNode class like was suggested before (but I think that's overkill since it would be almost identical to ParameterNode).
  • Have the do operator edit the DistributionNode's that now depend on the constant node, by moving the now-fixed value from parameters to constant_parameters for each affected node.

@mscroggs
Copy link
Collaborator Author

mscroggs commented May 1, 2025

  • Have the do operator edit the DistributionNode's that now depend on the constant node, by moving the now-fixed value from parameters to constant_parameters for each affected node.

Ooh, we could just remove the node that the do is setting the value of and do this move without needing to add a new node. This feels very neat so I'll do this

@mscroggs mscroggs closed this May 1, 2025
@mscroggs mscroggs reopened this May 1, 2025
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.

2 participants