Skip to main content

MonadicCausableGraphReasoning

Trait MonadicCausableGraphReasoning 

Source
pub trait MonadicCausableGraphReasoning<V, PS, C>: CausableGraph<Causaloid<V, V, PS, C>>
where V: Default + Clone + Send + Sync + 'static + Debug, PS: Default + Clone + Send + Sync + 'static, C: Clone + Send + Sync + 'static, Causaloid<V, V, PS, C>: MonadicCausable<V, V>,
{ // Provided methods fn evaluate_single_cause( &self, index: usize, effect: &PropagatingEffect<V>, ) -> PropagatingEffect<V> { ... } fn evaluate_subgraph_from_cause( &self, start_index: usize, initial_effect: &PropagatingEffect<V>, ) -> PropagatingEffect<V> { ... } fn evaluate_shortest_path_between_causes( &self, start_index: usize, stop_index: usize, initial_effect: &PropagatingEffect<V>, ) -> PropagatingEffect<V> { ... } }
Expand description

Provides default implementations for monadic reasoning over CausableGraph items.

Any graph type that implements CausableGraph<T> where T is MonadicCausable<CausalMonad> will automatically gain a suite of useful default methods for monadic evaluation. Provides default implementations for monadic reasoning over CausableGraph items.

Any graph type that implements CausableGraph<T> where T is MonadicCausable<V, V> will automatically gain a suite of useful default methods for monadic evaluation.

Provided Methods§

Source

fn evaluate_single_cause( &self, index: usize, effect: &PropagatingEffect<V>, ) -> PropagatingEffect<V>

Evaluates a single, specific causaloid within the graph by its index using a monadic approach.

This is a convenience method that locates the causaloid and calls its evaluate method.

§Arguments
  • index - The index of the causaloid to evaluate.
  • effect - The runtime effect to be passed to the node’s evaluation function.
§Returns

The PropagatingEffect from the evaluated causaloid, or a PropagatingEffect containing a CausalityError if the node is not found or the evaluation fails.

Source

fn evaluate_subgraph_from_cause( &self, start_index: usize, initial_effect: &PropagatingEffect<V>, ) -> PropagatingEffect<V>

Reasons over a subgraph by traversing all nodes reachable from a given start index, using a monadic approach.

This method performs a Breadth-First Search (BFS) traversal of all descendants of the start_index. The PropagatingEffect is passed sequentially: the output effect of a parent node becomes the input effect for its child node. The traversal continues as long as no CausalityError is returned within the PropagatingEffect.

§Adaptive Reasoning

If a Causaloid returns a PropagatingEffect::RelayTo(target_index, inner_effect), the BFS traversal dynamically jumps to target_index, and inner_effect becomes the new input for the relayed path. This enables adaptive reasoning conditional to the deciding causaloid.

§Arguments
  • start_index - The index of the node to start the traversal from.
  • initial_effect - The initial runtime effect to be passed to the starting node’s evaluation function.
§Returns

A PropagatingEffect representing the final aggregated monadic effect of the traversal. If an error occurs during evaluation, the returned PropagatingEffect will contain the error.

Source

fn evaluate_shortest_path_between_causes( &self, start_index: usize, stop_index: usize, initial_effect: &PropagatingEffect<V>, ) -> PropagatingEffect<V>

Reasons over the shortest path between a start and stop cause using a monadic approach.

It evaluates each node sequentially along the path. The PropagatingEffect returned by one causaloid becomes the input for the next causaloid in the path. If any node fails evaluation (i.e., returns a PropagatingEffect containing an error) or returns a RelayTo effect, the reasoning stops.

§Arguments
  • start_index - The index of the start cause.
  • stop_index - The index of the stop cause.
  • initial_effect - The runtime effect to be passed as input to the first node’s evaluation function.
§Returns

A PropagatingEffect representing the final aggregated monadic effect of the path traversal. If an error occurs or a RelayTo effect is encountered, that PropagatingEffect is returned immediately.

Implementors§

Source§

impl<V, PS, C> MonadicCausableGraphReasoning<V, PS, C> for CausaloidGraph<Causaloid<V, V, PS, C>>
where V: Default + Clone + Send + Sync + 'static + Debug, PS: Default + Clone + Send + Sync + 'static, C: Clone + Send + Sync + 'static, Causaloid<V, V, PS, C>: MonadicCausable<V, V>,