pub struct InterventionOverlay {
pub hard_set: Vec<Option<f64>>,
pub shifts: Vec<f64>,
pub stochastic: Vec<Option<StochasticPolicy>>,
pub soft: Vec<Option<MechanismOverride>>,
pub active: Vec<bool>,
}Expand description
Compact overlay describing how sampling differs from the observational plan.
The underlying CompiledCausalModel is never cloned; overlays are applied
during ancestral sampling.
Fields§
§hard_set: Vec<Option<f64>>Per-node hard sets (dense index → value), None = not hard-set.
shifts: Vec<f64>Per-node additive shifts.
stochastic: Vec<Option<StochasticPolicy>>Per-node stochastic policies.
soft: Vec<Option<MechanismOverride>>Per-node soft mechanism overrides.
active: Vec<bool>Optional temporal activation mask per node (true = active at current step).
Implementations§
Source§impl InterventionOverlay
impl InterventionOverlay
Sourcepub fn observational(n_nodes: usize) -> Self
pub fn observational(n_nodes: usize) -> Self
Empty overlay (observational) for n_nodes.
Sourcepub fn validate(&self) -> Result<(), ModelError>
pub fn validate(&self) -> Result<(), ModelError>
Reject a node carrying both a hard set and an additive shift.
A hard set replaces a node’s assignment outright, so an additive shift on the same node has nothing well-defined to add to: the mechanism it would shift is exactly the one the set discarded. Rather than pick a winner silently, both overlay construction and the overlay-accepting samplers refuse the pair and make the caller say which they meant.
Called for you by Self::from_interventions and Self::from_sequence_at;
call it yourself if you populate the public fields directly.
§Errors
ModelError::Unsupported naming the first offending dense node index.
Sourcepub fn from_interventions(
model: &CompiledCausalModel,
interventions: &[Intervention],
) -> Result<Self, ModelError>
pub fn from_interventions( model: &CompiledCausalModel, interventions: &[Intervention], ) -> Result<Self, ModelError>
Compile interventions against a model (simultaneous / single-step).
§Errors
Unknown variables, invalid interventions, or a node both set and shifted
(see Self::validate).
Sourcepub fn from_sequence_at(
model: &CompiledCausalModel,
seq: &InterventionSequence,
t: i32,
) -> Result<Self, ModelError>
pub fn from_sequence_at( model: &CompiledCausalModel, seq: &InterventionSequence, t: i32, ) -> Result<Self, ModelError>
Overlay for a temporal sequence at discrete step t.
§Errors
Invalid sequence, unknown variables, or a node both set and shifted at t
(see Self::validate).
Trait Implementations§
Source§impl Clone for InterventionOverlay
impl Clone for InterventionOverlay
Source§fn clone(&self) -> InterventionOverlay
fn clone(&self) -> InterventionOverlay
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InterventionOverlay
impl Debug for InterventionOverlay
Source§impl Default for InterventionOverlay
impl Default for InterventionOverlay
Source§fn default() -> InterventionOverlay
fn default() -> InterventionOverlay
Auto Trait Implementations§
impl Freeze for InterventionOverlay
impl RefUnwindSafe for InterventionOverlay
impl Send for InterventionOverlay
impl Sync for InterventionOverlay
impl Unpin for InterventionOverlay
impl UnsafeUnpin for InterventionOverlay
impl UnwindSafe for InterventionOverlay
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> ForeignBufferOwner for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more