babylon.engine.event_evaluator
Event Template evaluation engine.
Provides pure functions to evaluate EventTemplates against WorldState graphs. This is NOT a System - it’s a utility module used by Systems or the engine.
Sprint: Event Template System
Functions
|
Aggregate values and compare to threshold. |
|
Calculate a graph-level aggregate metric. |
|
Apply comparison operator. |
|
Evaluate an EdgeCondition against edges. |
|
Evaluate a GraphCondition against graph-level metrics. |
|
Evaluate a NodeCondition against matching nodes. |
|
Evaluate a PreconditionSet against the graph. |
|
Evaluate an EventTemplate against the current graph state. |
|
Filter nodes based on NodeFilter criteria. |
|
Get nodes that match the template's node conditions. |
|
Get a value from nested dict using dot notation. |
- babylon.engine.event_evaluator.evaluate_template(template, graph, current_tick)[source]
Evaluate an EventTemplate against the current graph state.
- Parameters:
template – The EventTemplate to evaluate.
graph – NetworkX graph representing WorldState.
current_tick – Current simulation tick.
- Returns:
The matching Resolution if preconditions met and a resolution matches, None otherwise.
- Return type:
Resolution | None
- babylon.engine.event_evaluator.evaluate_preconditions(preconditions, graph)[source]
Evaluate a PreconditionSet against the graph.
- Parameters:
preconditions – Set of conditions to evaluate.
graph – NetworkX graph to evaluate against.
- Returns:
True if preconditions are satisfied, False otherwise.
- Return type:
- babylon.engine.event_evaluator.evaluate_node_condition(condition, graph)[source]
Evaluate a NodeCondition against matching nodes.
- Parameters:
condition – The node condition to evaluate.
graph – NetworkX graph to evaluate against.
- Returns:
True if condition is satisfied, False otherwise.
- Return type:
- babylon.engine.event_evaluator.evaluate_edge_condition(condition, graph)[source]
Evaluate an EdgeCondition against edges.
- Parameters:
condition – The edge condition to evaluate.
graph – NetworkX graph to evaluate against.
- Returns:
True if condition is satisfied, False otherwise.
- Return type:
- babylon.engine.event_evaluator.evaluate_graph_condition(condition, graph)[source]
Evaluate a GraphCondition against graph-level metrics.
- Parameters:
condition – The graph condition to evaluate.
graph – NetworkX graph to evaluate against.
- Returns:
True if condition is satisfied, False otherwise.
- Return type:
- babylon.engine.event_evaluator.calculate_graph_metric(graph, metric)[source]
Calculate a graph-level aggregate metric.
- Parameters:
graph – NetworkX graph to analyze.
metric – Name of the metric to calculate.
- Returns:
The calculated metric value.
- Return type:
- babylon.engine.event_evaluator.filter_nodes(graph, node_filter)[source]
Filter nodes based on NodeFilter criteria.
- babylon.engine.event_evaluator.get_nested_value(data, path)[source]
Get a value from nested dict using dot notation.
Follows the same pattern as TriggerCondition._get_nested_value.
- babylon.engine.event_evaluator.compare(value, operator, threshold)[source]
Apply comparison operator.
- babylon.engine.event_evaluator.aggregate_and_compare(values, aggregation, operator, threshold)[source]
Aggregate values and compare to threshold.