Skip to content

Conversation

@willGraham01
Copy link
Collaborator

@willGraham01 willGraham01 commented Aug 19, 2025

Resolves #90 | Depends on #93 (merge conflicts are resolved).

Adds the infrastructure that we need to handle CasualProblems where (subsets of) the constraints and causal estimand require changes to the Graph structure (either through conditioning or the do operator, for example) whilst others do not.

For components (component = a constraint or the causal estimand) that require effect handlers to be overlaid on top of the _underlying_graph.model, we will need to create a separate Predictive instance that these components can sample from, which is separate from the Predictive instance corresponding to the un-edited _underlying_graph.model. We have to do this each time we encounter a component that requires application of a new combination of handlers.

As such, the best way for us to do this is to build all the Predictive instances we need before we create the Lagrangian function. When we do this, we can also create a cheap mapping from the components of the problem to the (index of the) predictive model that they use. Then, evaluating the Lagrangian consists of sampling from each of the predictive models, and passing the appropriate samples (which we can index in the same way as the predictive models) into the appropriate components.

  • The HandlerToApply is a convenience class, just to ease the means of determining if two handlers that are being applied are "the same".
  • Likewise, the _CPComponent.can_use_same_model method is introduced to determine if two components can use the same model (determined by whether the effects they require are identical).
  • CausalProblem._associate_models_to_components now handles the pre-building Lagrangian association discussed above.

@willGraham01 willGraham01 changed the title Wgraham/handle handlers Lagrangian respects effect handlers Aug 19, 2025
@willGraham01 willGraham01 force-pushed the wgraham/handle-handlers branch from 0f98c3c to 8a4483e Compare August 20, 2025 10:13
@willGraham01 willGraham01 marked this pull request as ready for review August 20, 2025 10:31
@willGraham01 willGraham01 requested a review from mscroggs August 20, 2025 10:37
@willGraham01 willGraham01 changed the base branch from main to wgraham/constraint-creation-ease August 27, 2025 09:17
Base automatically changed from wgraham/constraint-creation-ease to main September 3, 2025 08:26
@willGraham01 willGraham01 enabled auto-merge (squash) September 3, 2025 08:35
@willGraham01 willGraham01 merged commit f159427 into main Sep 3, 2025
5 checks passed
@willGraham01 willGraham01 deleted the wgraham/handle-handlers branch September 3, 2025 08:39
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.

Handle effect handlers from _CPComponents

3 participants