Runtime
Comprehensive Causal Reasoning and Intervention Architecture: A Code-First Paradigm
Report summary
The integration of causal reasoning into computational systems represents a necessary paradigm shift from purely associative pattern recognition to robust, interventional, and counterfactual logic. Standard machine learning models operate strictly on the lowest rung of the causal hierarchy, capturin
Key topics
- Runtime
- AI
- .NET
- Python
- Rust
- Semantic Systems
- Research Archive
- Strategy
Research provenance
For citation, use the report title and canonical URL. Archival presence does not establish authorship or promote report statements into portfolio evidence.
This page renders the archived Markdown as safe, formatted HTML. It is background research and does not become a portfolio claim without evidence review.
Full report
On this page
A. Summary
The integration of causal reasoning into computational systems represents a necessary paradigm shift from purely associative pattern recognition to robust, interventional, and counterfactual logic. Standard machine learning models operate strictly on the lowest rung of the causal hierarchy, capturing statistical correlations to optimize predictive accuracy in stationary environments. However, these models inherently fail when deployed in dynamic environments where external agents intervene, policies are changed, or counterfactual "what-if" scenarios must be evaluated. This research report delivers a comprehensive, self-contained architectural expansion for OntologicalMachine.com, establishing a code-first framework for causal inference, structural causal models (SCMs), and probabilistic graphical modeling. The deliverable is meticulously organized to facilitate the deployment of advanced causal analysis across Python, C\#, C, Java, and Rust. It encapsulates the theoretical underpinnings of causal graphs, an exhaustive content plan containing twenty-two detailed code sample specifications, and ten fully worked original code drafts demonstrating the algorithmic realization of these concepts. Furthermore, the report provides an exhaustive analysis of twenty related ecosystem projects, mapping out a language-specific feasibility matrix that highlights the strengths and limitations of each programming environment. By bridging the gap between theoretical causal identifiability and pragmatic software engineering, this architecture provides the structural blueprints necessary for deterministic simulation, confounding adjustments, and the integration of causal outputs into automated planning systems. The resulting framework enables systems to move beyond asking "What is the probability of an outcome given an observation?" to the much more powerful question of "What is the probability of an outcome if a specific action is autonomously taken?"
B. Conceptual Guide
The implementation of causal algorithms necessitates a rigorous distinction between observational phenomena and structural truths. The following concepts form the bedrock of the causal hierarchy and dictate the architectural requirements for the software implementations that follow.
Correlation versus Causal Structure
Correlation is a strictly statistical measure defining the degree to which two or more variables fluctuate together. It is symmetric and entirely observational, meaning it cannot distinguish between cause, effect, or shared confounding influences. In highly dimensional datasets, spurious correlations are mathematical inevitabilities. Conversely, a causal structure is inherently asymmetric and directional. It is typically represented as a Directed Acyclic Graph (DAG) or a Structural Causal Model (SCM), where edges represent autonomous physical or logical mechanisms. While correlation allows software systems to predict an outcome based on passively observed data, causal structure allows systems to predict an outcome when an external agent explicitly manipulates the environment. The software architecture must therefore decouple the representation of joint probability distributions from the representation of the structural mechanisms that generate those distributions.
Interventions and Graph Surgery
Interventions represent active perturbations of a system, moving the computational model from passive observation to active manipulation. Mathematically formalized by the [Figure omitted from source export]\-operator, an intervention—denoted as [Figure omitted from source export]—forces the variable [Figure omitted from source export] to take a specific constant value [Figure omitted from source export], completely overriding its natural data-generating mechanisms. In graphical software terms, an intervention corresponds to the algorithmic process of "graph surgery." During graph surgery, the algorithm traverses the DAG and physically severs all incoming edges to the intervened variable [Figure omitted from source export], rendering it independent of its natural causes and historical confounders. This operation fundamentally alters the joint probability distribution of the simulated system, isolating the downstream causal effects of [Figure omitted from source export] from spurious, backward-flowing correlational data. Implementing this requires mutable graph structures where edge references can be dynamically reassigned or pruned at runtime.
Counterfactuals and the Abduction-Action-Prediction Algorithm
Counterfactuals reside at the highest level of the causal hierarchy. They represent retrospective, hypothetical queries regarding individual units of observation: "What would the value of the outcome have been if, contrary to fact, the treatment had been different?" Evaluating a counterfactual requires a fully specified Structural Causal Model (SCM) comprising both endogenous (observed) and exogenous (unobserved background noise) variables. The software evaluation of a counterfactual proceeds in three strict algorithmic steps. First, during the Abduction phase, the system uses the observed data to update and compute the specific values or posterior probability distributions of the unobserved background variables for a specific entity. Second, during the Action phase, the system applies the intervention [Figure omitted from source export] by structurally modifying the equations to reflect the hypothetical scenario. Finally, during the Prediction phase, the system computes the new value of the outcome using the updated background variables mapped through the modified structural equations.
Confounding and Back-door Paths
Confounding occurs when an unobserved or extraneous variable influences both the cause and the effect, creating a spurious statistical association. In a directed graph, a confounder creates a "back-door path" (e.g., Treatment [Figure omitted from source export] Confounder [Figure omitted from source export] Outcome), which allows statistical information to flow between the treatment and outcome in a non-causal manner. Left unadjusted in code, confounding strictly biases the estimation of causal effects, leading machine learning algorithms to confidently predict spurious relationships. The primary objective of observational causal inference software is to identify and adjust for these confounders. Algorithms must traverse the DAG to identify sets of observed variables that can block all active back-door paths, enabling the system to isolate the true, unconfounded causal effect using techniques such as inverse probability weighting or matching.
Identifiability and the Do-Calculus
Identifiability is the theoretical determination of whether a causal query can be unambiguously computed from a combination of purely observational data and a given causal graph structure. If a causal quantity is identifiable, there exists a sequence of mathematical transformations—utilizing the syntactic rules of [Figure omitted from source export]\-calculus or specific graphical criteria like the back-door and front-door criteria—that translates the interventional query into a purely observational mathematical expression. If it is non-identifiable, the software must be designed to halt and alert the user that no amount of observational data can uncover the true causal effect without further parametric assumptions. Software agents must therefore implement identifiability engines that symbolically manipulate queries before attempting numerical estimation.
Fundamental Causal Assumptions
Causal inference rests upon untestable assumptions that must be justified by domain knowledge rather than purely proven by data. The software architecture must explicitly document and, where possible, check these assumptions. The Stable Unit Treatment Value Assumption (SUTVA) dictates that the outcome of one unit is unaffected by the interventions applied to other units. Consistency requires that if a unit naturally receives a treatment, its observed outcome is equal to its potential outcome under an active intervention. Positivity, or overlap, demands that every unit in the dataset has a non-zero probability of receiving all possible treatment assignments; algorithms must check propensity scores to ensure this holds true. Unconfoundedness (Ignorability) assumes that, conditional on observed covariates, the treatment assignment is independent of the potential outcomes, meaning all back-door paths are successfully blocked. Finally, the Causal Markov Condition states that a variable is independent of all its non-descendants, conditional solely on its direct parents in the DAG.
C. Sample Plan
The content strategy requires deploying twenty-two distinct code samples across five target programming languages to cover the full spectrum of causal mechanics, ranging from high-level Python scripting to low-level C memory management.
| ID | Language | Theme | Specification |
|---|---|---|---|
| S01 | Python | Causal Graph Definition | Define a DAG class utilizing hash maps to represent nodes, directed edges, and structural parameters, establishing strict directionality. |
| S02 | Python | Counterfactual Evaluation | Implement the Abduction-Action-Prediction logic utilizing a simplified linear Structural Causal Model to evaluate unit-level scenarios. |
| S03 | Python | Invalid Intervention Rejection | Create a graph validator that rejects interventional queries targeting non-existent nodes or immutable demographic attributes. |
| S04 | Python | Identifiability Back-door | Implement a graph traversal algorithm to find valid back-door adjustment sets that block non-causal paths between a treatment and an outcome. |
| S05 | Python | SCM Exogenous Sampling | Generate synthetic datasets by sampling from exogenous noise distributions and propagating the values downward through structural equations. |
| S06 | C\# | Assumption Evidence | Define prior probabilities for causal links and update beliefs utilizing Bayesian message passing logic based on observational data. |
| S07 | C\# | Deterministic Simulation | Construct a forward-pass evaluation of an SCM utilizing a topological sort to generate exact observational matrices. |
| S08 | C\# | SUTVA Violation Check | Model a network of interacting spatial units and generate runtime warnings when interference or spillover between units is detected. |
| S09 | C\# | Front-door Criterion | Define an intermediate mediator variable and compute the causal effect using front-door adjustment logic when unobserved confounders exist. |
| S10 | C | Confounder Representation | Utilize strict memory allocation (malloc/free) to represent unmeasured latent confounders that secretly dictate the values of observed nodes. |
| S11 | C | Graph Adjacency Matrix | Represent a massive causal graph as a contiguous 1D array mapped as a 2D matrix, optimized for high-performance CPU cache lines. |
| S12 | C | D-separation Path Blocking | Traverse the adjacency matrix to mathematically determine if a conditioning set of nodes strictly independentizes two target variables. |
| S13 | C | Fast Causal Simulation | Implement a highly optimized simulation loop generating millions of synthetic data points from a fixed, pre-compiled SCM. |
| S14 | Java | Acyclicity Checks | Implement a topological sort using Kahn's Algorithm to strictly enforce the Directed Acyclic Graph constraint during graph construction. |
| S15 | Java | Causal Outputs in Planning | Integrate a causal DAG into a reinforcement learning utility loop, allowing an agent to choose the specific intervention that maximizes an outcome. |
| S16 | Java | Graph Surgery | Deep-clone a causal graph object and strip the incoming edges of a target node to perfectly represent an intervened state in memory. |
| S17 | Java | Propensity Score Matching | Classify units based on their probability of treatment using logistic regression, adjusting for covariates in an object-oriented pipeline. |
| S18 | Rust | Structural Equations | Leverage Rust's exhaustive enums and closures to define complex, type-safe causal mechanisms that cannot panic at runtime. |
| S19 | Rust | Intervention Operators | Utilize Rust's strict ownership, borrowing, and mutability model to safely execute graph surgery on a reference-counted DAG. |
| S20 | Rust | Collider Bias Detection | Implement a detection algorithm that throws compiler-like warnings if an analyst attempts to condition on a common effect (a collider). |
| S21 | Rust | Causal Discovery (PC) | Draft a skeletal structure for the Peter-Clark (PC) algorithm, pruning a fully connected undirected graph based on conditional independence tests. |
| S22 | Rust | Parallel Counterfactuals | Use thread-safe data structures (Arc, Mutex) to evaluate thousands of counterfactual scenarios concurrently across multiple CPU cores. |
D. 10 Code Drafts
The following original code drafts realize the architectural specifications outlined in the sample plan. These drafts bridge the theoretical concepts of causal inference with the pragmatic realities of memory management, time complexity, and language-specific design patterns.
1. Python: Causal Graph Definition (S01)
This implementation establishes a fundamental Directed Acyclic Graph (DAG) emphasizing strict causal directionality. In associative machine learning, models map features to targets without regard for physical reality. This object-oriented approach explicitly defines causes and effects, preventing the backward flow of information. The architecture uses dictionary mappings for [Figure omitted from source export] node lookups and list appends for [Figure omitted from source export] edge creations, ensuring that the foundational structure scales linearly with the number of variables.
Python from typing import Dict, List, Optional
class CausalNode: """Represents a single variable in a causal graph with strict directional awareness.""" def \_\_init\_\_(self, name: str): self.name \= name self.parents: List\['CausalNode'\] \= \[\] self.children: List\['CausalNode'\] \= \[\]
def add\_child(self, child: 'CausalNode') \-\> None: """Establishes a directed causal mechanism from self to child.""" if child not in self.children: self.children.append(child) child.parents.append(self)
class CausalGraph: """Manages the lifecycle and topology of the causal model.""" def \_\_init\_\_(self): self.nodes: Dict\[str, CausalNode\] \= {}
def add\_node(self, name: str) \-\> None: """Idempotent node addition.""" if name not in self.nodes: self.nodes\[name\] \= CausalNode(name)
def add\_edge(self, cause: str, effect: str) \-\> None: """Defines a structural assignment where the cause dictates the effect.""" if cause not in self.nodes or effect not in self.nodes: raise ValueError(f"Nodes must exist before adding edges: {cause} \-\> {effect}") self.nodes\[cause\].add\_child(self.nodes\[effect\])
def display\_structure(self) \-\> None: """Visualizes the direct mechanisms dictating each node.""" for name, node in self.nodes.items(): parent\_names \= \[p.name for p in node.parents\] print(f"Mechanism for {name}: f({', '.join(parent\_names) if parent\_names else 'Exogenous Noise'})")
\# Usage Example: Modeling a simple medical confounding scenario cg \= CausalGraph() for node in \["Smoking", "Tar\_in\_Lungs", "Cancer", "Genetics"\]: cg.add\_node(node)
cg.add\_edge("Genetics", "Smoking") cg.add\_edge("Genetics", "Cancer") \# Genetics acts as an unobserved confounder cg.add\_edge("Smoking", "Tar\_in\_Lungs") cg.add\_edge("Tar\_in\_Lungs", "Cancer") cg.display\_structure()
2. Python: Counterfactual Evaluation (S02)
This implementation demonstrates the absolute pinnacle of causal reasoning: the three-step counterfactual algorithm (Abduction, Action, and Prediction). Working within a linear structural model, the system first solves the equations backward to isolate the unique exogenous noise variables ([Figure omitted from source export]) that characterize a specific individual. It then intervenes on the structural equations, modifying the treatment variable while keeping the historical noise constant, and propagates the new values forward. This enables the algorithm to answer questions like, "Given that this employee has a salary of $40k with 4 years of education, what would their exact salary have been if they had received 8 years of education?"
Python class LinearSCM: """A linear Structural Causal Model for counterfactual evaluation.""" def \_\_init\_\_(self): \# Coefficients mapping parents to nodes: node \-\> {parent: coefficient} \# Represents the physical mechanism generating the data. self.equations \= { 'Education': {'U\_Ed': 1.0}, 'Experience': {'Education': 2.0, 'U\_Exp': 1.0}, 'Salary': {'Education': 1.5, 'Experience': 3.0, 'U\_Sal': 1.0} }
def abduction(self, observed: dict) \-\> dict: """Step 1: Infer individual-level exogenous noise (U) from observed data.""" U \= {} U\['U\_Ed'\] \= observed\['Education'\] U\['U\_Exp'\] \= observed\['Experience'\] \- (self.equations\['Experience'\]\['Education'\] \ observed\['Education'\]) U\['U\_Sal'\] \= observed\['Salary'\] \- (self.equations\['Salary'\]\['Education'\] \ observed\['Education'\] \+ self.equations\['Salary'\]\['Experience'\] \* observed\['Experience'\]) return U
def action\_and\_prediction(self, U: dict, intervention: dict) \-\> dict: """Step 2 & 3: Apply do-operator (graph surgery) and predict forward.""" cf \= {} \# Apply intervention if present, otherwise rely on natural mechanisms cf\['Education'\] \= intervention.get('Education', U\['U\_Ed'\])
if 'Experience' in intervention: cf\['Experience'\] \= intervention\['Experience'\] else: cf\['Experience'\] \= self.equations\['Experience'\]\['Education'\] \* cf\['Education'\] \+ U\['U\_Exp'\]
if 'Salary' in intervention: cf\['Salary'\] \= intervention\['Salary'\] else: cf\['Salary'\] \= (self.equations\['Salary'\]\['Education'\] \ cf\['Education'\] \+ self.equations\['Salary'\]\['Experience'\] \ cf\['Experience'\] \+ U\['U\_Sal'\]) return cf
\# Counterfactual Query: scm \= LinearSCM() observed\_data \= {'Education': 4, 'Experience': 10, 'Salary': 40} inferred\_u \= scm.abduction(observed\_data) \# What if this exact person had 8 years of education instead of 4? counterfactual\_outcome \= scm.action\_and\_prediction(inferred\_u, intervention={'Education': 8}) print(f"Observed Salary: {observed\_data\['Salary'\]}") print(f"Counterfactual Salary: {counterfactual\_outcome\['Salary'\]}")
3. Python: Invalid Intervention Rejection (S03)
Not all variables in a causal graph can be manipulated. While it is mathematically possible to compute [Figure omitted from source export], it is physically impossible to intervene on someone's age. This validation layer ensures that automated planning agents do not waste compute cycles evaluating physically impossible interventions. It enforces domain constraints before any graph surgery or tensor operations occur, utilizing Python sets for [Figure omitted from source export] validation lookups.
Python from typing import Set, Dict, Any
class InterventionValidator: """Safeguards the causal inference engine from nonsensical or impossible queries.""" def \_\_init\_\_(self, valid\_nodes: Set\[str\], immutable\_nodes: Set\[str\]): self.valid\_nodes \= valid\_nodes \# Nodes that exist in the graph but cannot be physically manipulated self.immutable\_nodes \= immutable\_nodes
def validate(self, intervention: Dict\[str, Any\]) \-\> bool: """Checks the intervention dictionary against physical graph constraints.""" for node in intervention.keys(): if node not in self.valid\_nodes: raise ValueError(f"Constraint Violation: Node '{node}' is not in the causal graph.") if node in self.immutable\_nodes: raise ValueError(f"Constraint Violation: Node '{node}' is physically immutable. " f"Cannot compute do({node}={intervention\[node\]}).") return True
\# Usage implementation validator \= InterventionValidator( valid\_nodes={"Age", "Diet", "Blood\_Pressure", "Genetics"}, immutable\_nodes={"Age", "Genetics"} )
try: \# Attempting to intervene on a genetic baseline validator.validate({"Genetics": "Variant\_B", "Diet": "Mediterranean"}) except ValueError as e: print(f"Intervention Rejected \-\> {e}")
4. C#: Evidence Attached to Causal Assumptions (S06)
Drawing conceptually from Microsoft's Infer.NET probabilistic programming1, this code defines a Bayesian evidence class to weight causal path assumptions. In causal discovery, the existence of an edge is often uncertain. By representing causal links as prior probabilities, the system can utilize observational conditional independence tests to compute Bayes factors. These factors update the structural beliefs, allowing the software to continuously refine its understanding of the causal topology as new data streams are ingested.
C\# using System;
public class CausalAssumption { public string Cause { get; private set; } public string Effect { get; private set; }
// Represents the Bayesian belief that the causal mechanism exists public double PriorProbability { get; private set; }
public CausalAssumption(string cause, string effect, double prior) { Cause \= cause; Effect \= effect; PriorProbability \= Math.Clamp(prior, 0.001, 0.999); }
/// \<summary\> /// Updates the belief in the causal link based on incoming observational data tests. /// \</summary\> /// \<param name="bayesFactor"\>The likelihood ratio of the data given the edge exists vs does not exist.\</param\> public double UpdateBeliefWithEvidence(double bayesFactor) { // Convert prior probability to odds double priorOdds \= PriorProbability / (1.0 \- PriorProbability);
// Multiply by the Bayes Factor evidence to get posterior odds double posteriorOdds \= priorOdds \* bayesFactor;
// Convert back to probability space double posterior \= posteriorOdds / (1.0 \+ posteriorOdds); return posterior; } }
public class Program { public static void Main() { // Initial weak belief that X causes Y var assumption \= new CausalAssumption("X", "Y", 0.3); Console.WriteLine($"Prior belief \[X \-\> Y\]: {assumption.PriorProbability}");
// Simulated evidence from a robust conditional independence test // A Bayes factor \> 1 indicates strong evidence for the edge double evidenceStrength \= 8.5; double posterior \= assumption.UpdateBeliefWithEvidence(evidenceStrength);
Console.WriteLine($"Updated belief after data assimilation: {posterior:F4}"); } }
5. C#: Deterministic Simulation (S07)
A forward-pass simulation resolving node values sequentially according to their topological order. To generate synthetic observational data that perfectly adheres to a specified causal structure, the variables must be evaluated in an order where every parent is resolved before its children. This C\# implementation maps structural equations to delegates (Func), creating a highly extensible execution engine that supports non-linear dynamics.
C\# using System; using System.Collections.Generic;
public class StructuralEquationModel { // Maps a node name to its mathematical structural function private readonly Dictionary\<string, Func\<Dictionary\<string, double\>, double\>\> \_equations;
// Maintains the execution order to ensure parents are calculated before children private readonly List\<string\> \_topologicalOrder;
public StructuralEquationModel() { \_equations \= new Dictionary\<string, Func\<Dictionary\<string, double\>, double\>\>(); \_topologicalOrder \= new List\<string\>(); }
public void AddEquation(string node, Func\<Dictionary\<string, double\>, double\> structuralFunction) { \_equations\[node\] \= structuralFunction; \_topologicalOrder.Add(node); // Assumes nodes are added in a valid topological order }
public Dictionary\<string, double\> Simulate() { var state \= new Dictionary\<string, double\>(); foreach (var node in \_topologicalOrder) { // Evaluate the node based on the current state of its parents state\[node\] \= \_equations\node\; } return state; } }
public class Program { public static void Main() { var scm \= new StructuralEquationModel(); var rand \= new Random();
// Z is a root confounder (no parents) scm.AddEquation("Z", state \=\> rand.NextDouble());
// X depends on Z scm.AddEquation("X", state \=\> 0.5 \ state\["Z"\] \+ (rand.NextDouble() \ 0.1));
// Y depends on both X and Z (The back-door path is open) scm.AddEquation("Y", state \=\> 1.5 \ state\["X"\] \- 0.8 \ state\["Z"\] \+ (rand.NextDouble() \* 0.1));
var result \= scm.Simulate(); Console.WriteLine($"Simulated Observational Data \-\> X: {result\["X"\]:F3}, Y: {result\["Y"\]:F3}, Z: {result\["Z"\]:F3}"); } }
6. C: Confounder Representation (S10)
This low-level C snippet demonstrates how system memory can map directly to structural nodes, serving as a high-performance alternative to Python object overhead. The confounder acts as a hidden memory pointer modifying both the treatment and the outcome arrays. Because C requires explicit memory management, this architecture naturally isolates latent unmeasured variables (which are allocated but never exposed to the output matrices) from observed variables, mirroring the physical reality of unobserved confounding bias.
C \#include \<stdio.h\> \#include \<stdlib.h\> \#include \<stdbool.h\>
// Represents a variable in the structural model typedef struct Node { char\ name; double value; bool is\_observed; // Distinguishes measured variables from latent confounders struct Node\\* parents; int num\_parents; } Node;
Node\ create\_node(char\ name, bool observed) { Node\ n \= (Node\)malloc(sizeof(Node)); n-\>name \= name; n-\>value \= 0.0; n-\>is\_observed \= observed; n-\>parents \= NULL; n-\>num\_parents \= 0; return n; }
void add\_parent(Node\ child, Node\ parent) { child-\>num\_parents++; child-\>parents \= (Node\\)realloc(child-\>parents, child-\>num\_parents \ sizeof(Node\)); child-\>parents\[child-\>num\_parents \- 1\] \= parent; }
void resolve\_node(Node\ n) { if (n-\>num\_parents \== 0) { n-\>value \= 1.0; // Base background exogenous noise return; } n-\>value \= 0.0; for (int i \= 0; i \< n-\>num\_parents; i++) { n-\>value \+= (n-\>parents\[i\]-\>value \ 0.5); // Simple linear accumulation } }
int main() { // Z is allocated in memory but represents an unmeasured physical factor Node\ Z \= create\_node("Latent\_Confounder", false); Node\ X \= create\_node("Observed\_Treatment", true); Node\* Y \= create\_node("Observed\_Outcome", true);
add\_parent(X, Z); // Z secretly influences X add\_parent(Y, Z); // Z secretly influences Y add\_parent(Y, X); // X genuinely influences Y
// Forward pass resolution resolve\_node(Z); resolve\_node(X); resolve\_node(Y);
// Only X and Y would be logged to the dataset, masking Z's influence printf("Dataset Log \-\> X: %f, Y: %f\\n", X-\>value, Y-\>value);
// Strict memory cleanup free(Z-\>parents); free(Z); free(X-\>parents); free(X); free(Y-\>parents); free(Y); return 0; }
7. Java: Acyclicity Checks (S14)
Leveraging enterprise-grade graph patterns found in libraries like JGraphT4, this sample utilizes Kahn's algorithm to enforce the Directed Acyclic Graph (DAG) constraint prior to any causal simulation. Causal structures cannot contain feedback loops over instantaneous time slices, as a variable cannot cause itself. Kahn's algorithm operates in [Figure omitted from source export] time, efficiently detecting cycles. If an analyst attempts to add an edge that creates a cycle, the system immediately rolls back the state and throws an exception, maintaining structural integrity.
Java import java.util.\*;
public class CausalDAG { // Adjacency list representation private Map\<String, List\<String\>\> adjList \= new HashMap\<\>(); // Tracks the number of incoming edges for topological sorting private Map\<String, Integer\> inDegree \= new HashMap\<\>();
public void addNode(String name) { adjList.putIfAbsent(name, new ArrayList\<\>()); inDegree.putIfAbsent(name, 0); }
public void addEdge(String cause, String effect) { adjList.get(cause).add(effect); inDegree.put(effect, inDegree.get(effect) \+ 1);
// Validate DAG constraint immediately if (\!isAcyclic()) { // Rollback the transaction to maintain safe state adjList.get(cause).remove(effect); inDegree.put(effect, inDegree.get(effect) \- 1); throw new IllegalArgumentException( "Violation: Edge " \+ cause \+ " \-\> " \+ effect \+ " creates a cycle. Causal models must be acyclic." ); } }
private boolean isAcyclic() { int visitedNodes \= 0; Queue\<String\> queue \= new LinkedList\<\>(); // Create a working copy of in-degrees to avoid mutating the master state Map\<String, Integer\> inDegreeCopy \= new HashMap\<\>(inDegree);
// Enqueue all root nodes (in-degree of 0\) for (Map.Entry\<String, Integer\> entry : inDegreeCopy.entrySet()) { if (entry.getValue() \== 0) queue.add(entry.getKey()); }
// Kahn's Algorithm for Topological Sort while (\!queue.isEmpty()) { String node \= queue.poll(); visitedNodes++; for (String neighbor : adjList.get(node)) { inDegreeCopy.put(neighbor, inDegreeCopy.get(neighbor) \- 1); if (inDegreeCopy.get(neighbor) \== 0) queue.add(neighbor); } } // If we visited every node, no cycles exist return visitedNodes \== adjList.size(); }
public static void main(String\[\] args) { CausalDAG dag \= new CausalDAG(); dag.addNode("Investment"); dag.addNode("Revenue"); dag.addNode("Reinvestment"); dag.addEdge("Investment", "Revenue"); dag.addEdge("Revenue", "Reinvestment"); try { // Attempting to close the loop in a static DAG dag.addEdge("Reinvestment", "Investment"); } catch (IllegalArgumentException e) { System.err.println(e.getMessage()); } } }
8. Java: Integration of Causal Outputs into Planning (S15)
This architecture illustrates an autonomous agent scoring potential interventions to maximize a specific outcome, effectively turning causal models into strategic reinforcement learning planners. While traditional machine learning predicts future states based on past correlations, causal planners evaluate the expected utility of active interventions. By iterating over an action space and evaluating the interventional query [Figure omitted from source export], the agent can deterministically select the optimal policy.
Java import java.util.\*;
public class CausalStrategicPlanner {
/\\ \ Simulates the interventional query: E\[Outcome | do(Treatment \= value)\] \ In a production system, this would query a fitted causal estimator (e.g., Double ML). \/ public static double simulateIntervention(String target, double interventionValue) { if (target.equals("Discount\_Percentage")) { double baseSales \= 1000.0; // The isolated causal effect of the discount on sales volume double causalEffect \= 25.5 \ interventionValue; return baseSales \+ causalEffect; } return 0.0; }
public static void main(String\[\] args) { // The discrete action space available to the autonomous agent List\<Double\> possibleDiscounts \= Arrays.asList(0.0, 5.0, 10.0, 15.0, 20.0); double costPerDiscountUnit \= 18.0;
double bestExpectedUtility \= \-Double.MAX\_VALUE; double optimalPolicyAction \= 0.0;
System.out.println("Evaluating Interventional Action Space..."); for (double d : possibleDiscounts) { // E\[Y | do(X=x)\] double expectedSales \= simulateIntervention("Discount\_Percentage", d); double policyCost \= d \* costPerDiscountUnit; double expectedUtility \= expectedSales \- policyCost;
System.out.printf("Policy do(Discount=%.1f) \-\> E\[Utility\] \= %.2f%n", d, expectedUtility);
if (expectedUtility \> bestExpectedUtility) { bestExpectedUtility \= expectedUtility; optimalPolicyAction \= d; } } System.out.println("\\nExecuting Optimal Policy: set do(Discount=" \+ optimalPolicyAction \+ ")"); } }
9. Rust: Structural Equations (S18)
Using Rust's strict ownership model and robust enum systems to define type-safe causal mechanisms. Inspired by the high-performance structural designs found in libraries like Petgraph6, this implementation guarantees memory safety without garbage collection overhead. By explicitly defining mechanisms as either Exogenous or Endogenous, the Rust compiler ensures that functions map correctly to their theoretical roles in the causal hierarchy.
Rust use std::collections::HashMap;
// Enums enforce strict separation of mechanism types enum CausalMechanism { // Background noise: Requires no inputs, generates a value Exogenous(Box\<dyn Fn() \-\> f64\>), // Structural equation: Requires the state of parent nodes to compute a value Endogenous(Box\<dyn Fn(\&HashMap\<String, f64\>) \-\> f64\>), }
struct CausalNode { name: String, mechanism: CausalMechanism, }
struct StructuralCausalModel { nodes: Vec\<CausalNode\>, }
impl StructuralCausalModel { fn new() \-\> Self { StructuralCausalModel { nodes: Vec::new() } }
fn add\_node(&mut self, node: CausalNode) { self.nodes.push(node); }
fn evaluate(&self) \-\> HashMap\<String, f64\> { let mut state \= HashMap::new(); // Iterates through nodes in topological order for node in &self.nodes { let val \= match \&node.mechanism { CausalMechanism::Exogenous(func) \=\> func(), CausalMechanism::Endogenous(func) \=\> func(\&state), }; state.insert(node.name.clone(), val); } state } }
fn main() { let mut scm \= StructuralCausalModel::new();
scm.add\_node(CausalNode { name: "U\_Income".to\_string(), mechanism: CausalMechanism::Exogenous(Box::new(|| 50000.0)), });
scm.add\_node(CausalNode { name: "Observed\_Income".to\_string(), mechanism: CausalMechanism::Endogenous(Box::new(|state| { // Safely unpacks the parent value, multiplying by an effect coefficient state.get("U\_Income").unwrap() \* 1.05 })), });
let result \= scm.evaluate(); println\!("Evaluated Endogenous Node (Income): {}", result.get("Observed\_Income").unwrap()); }
10. Rust: Intervention Operators (S19)
This demonstrates the software realization of graph surgery. When an intervention [Figure omitted from source export] is applied, the causal graph must be mutated to sever all incoming edges to [Figure omitted from source export]. Utilizing Rust's ownership model, the system deep-clones the observational graph to create a distinct interventional graph, ensuring that the foundational topology remains untouched while the hypothetical scenario is evaluated. This prevents side-effect mutations that commonly corrupt causal simulation pipelines.
Rust use std::collections::HashMap;
\#\[derive(Clone)\] struct Node { id: String, parents: Vec\<String\>, }
struct CausalGraph { nodes: HashMap\<String, Node\>, }
impl CausalGraph { /// Applies the do-operator, returning a brand new mutated graph representing the intervened state. fn do\_operator(&self, target\_node: &str) \-\> CausalGraph { let mut interventional\_nodes \= self.nodes.clone();
// Graph Surgery: Remove all parents from the intervened node if let Some(node) \= interventional\_nodes.get\_mut(target\_node) { println\!("\\n\[System\] Performing graph surgery on node: {}", target\_node); println\!("\[System\] Severing back-door paths: {:?}", node.parents); node.parents.clear(); // Physically cuts the incoming edges }
CausalGraph { nodes: interventional\_nodes } }
fn display\_topology(&self) { for (id, node) in &self.nodes { println\!("Node {} is caused by \-\> {:?}", id, node.parents); } } }
fn main() { let mut nodes \= HashMap::new(); // Z is a confounder influencing both X and Y nodes.insert("Z".to\_string(), Node { id: "Z".to\_string(), parents: vec\!\[\] }); nodes.insert("X".to\_string(), Node { id: "X".to\_string(), parents: vec\!\["Z".to\_string()\] }); nodes.insert("Y".to\_string(), Node { id: "Y".to\_string(), parents: vec\!\["Z".to\_string(), "X".to\_string()\] });
let observational\_graph \= CausalGraph { nodes }; println\!("--- Observational Graph Topology \---"); observational\_graph.display\_topology();
// An agent intervenes, forcing X to a specific value let intervened\_graph \= observational\_graph.do\_operator("X");
println\!("\\n--- Interventional Graph Topology do(X) \---"); intervened\_graph.display\_topology(); }
E. Related Projects
An extensive ecosystem of tools supports causal reasoning, probabilistic inference, and graph manipulations. The architecture proposed in this report draws deep inspiration from twenty foundational projects across multiple programming paradigms. The table below details these projects, analyzing their language integrations, maintenance states, strengths, limitations, and direct relevance to the implemented code samples.
| Project Name | Official Links / Ecosystem | Language Integration | Maintenance State | Strengths & Capabilities | Limitations | Connection to Code Samples |
|---|---|---|---|---|---|---|
| Infer.NET | Microsoft Research1 | C\# / .NET | Active | Exceptional compilation of probabilistic models into optimized inference code via Expectation Propagation1. | Focuses heavily on probabilistic Bayesian reasoning rather than explicit structural do-calculus interventions3. | Provides the theoretical mapping for Bayesian assumption evidence tasks (Sample S06). |
| pgmpy | pgmpy.org10 | Python | Active | Unified API for discrete Bayesian Networks, exact causal inference, and Directed Acyclic Graphs modeling11. | Heavy reliance on discrete tabular CPDs; struggles significantly with non-linear continuous causal relationships. | Informative baseline for Python directional graph definitions (Sample S01). |
| causal-learn | CMU-Phil13 | Python | Highly Active | A complete, state-of-the-art suite for causal discovery (PC, GES, constraint/score-based methods) learning from observational data13. | Computational complexity for independence tests scales poorly on extremely dense networks14. | Directly informs the Rust discovery algorithms and independence test specifications (Sample S21). |
| DoWhy | PyWhy Ecosystem15 | Python | Highly Active | Employs a unique 4-step pipeline (Model, Identify, Estimate, Refute). Supports rigorous causal assumptions refutation15. | Primarily focused on Average Treatment Effects (ATE) rather than localized, high-speed dynamic planning loops. | Serves as the blueprint for validation, constraint checking, and Identifiability models (Sample S04). |
| EconML | Microsoft ALICE15 | Python | Active | State-of-the-art implementation of Double Machine Learning, instrumental variables, and heterogeneous treatment effects17. | Steep learning curve requiring deep background in advanced econometrics to interpret output matrices17. | Guides the architectural requirements for propensity scoring implementations (Sample S17). |
| pywhy-graphs | PyWhy Ecosystem15 | Python | Active | Experimental networkx-compliant causal graphs specifically designed for the PyWhy statistical ecosystem15. | Still in experimental phases; API surface changes frequently15. | Influences the Python graph validation parameters and SCM object architectures (Samples S01, S03). |
| dodiscover | PyWhy Ecosystem15 | Python | Active | Global causal discovery algorithms intended to seamlessly feed learned graphs into DoWhy estimators15. | Redundant with causal-learn in some areas, causing ecosystem fragmentation16. | Relevant to the causal pipeline transitioning discovery into counterfactual action. |
| causaltune | PyWhy Ecosystem15 | Python | Active | Automated machine learning (AutoML) applied directly to causal inference estimators to find optimal hyperparameters15. | Extreme computational cost due to automated grid searches over complex effect estimators15. | Connects conceptually to planning and scoring optimal interventions efficiently (Sample S15). |
| pywhy-stats | PyWhy Ecosystem15 | Python | Active | Consolidates (conditional) independence testing and statistical functions specifically related to causality15. | Limited to Python; requires bindings if used in enterprise Java/C\# environments15. | Essential for validating the mathematical constraints of D-separation (Sample S12). |
| pywhyllm | PyWhy Ecosystem15 | Python | Experimental | Integrating Large Language Model (LLM) capabilities to support and interpret causal analyses15. | Highly experimental; LLM hallucinations can falsely assert causal mechanisms where none exist15. | Explores natural language abstraction of SCM definitions. |
| CausalML | Uber GitHub18 | Python | Active | Specifically targets uplift modeling and machine learning-driven individualized treatment effects (ITEs) for business metrics18. | Less emphasis on structural model generation, focusing heavily on predictive tree-based ML estimators18. | Informs the reward-scoring logic for causal output planning models (Sample S15). |
| Tetrad | CMU-Phil19 | Java | Highly Active | Unmatched breadth of search algorithms, model scoring, and robust Java desktop GUI capabilities built over 30 years19. | The core Java API is dense, object-heavy, and occasionally cumbersome for lightweight microservice deployments19. | Provides the foundational logic for Java Acyclicity and structure validation (Sample S14). |
| py-tetrad | CMU-Phil19 | Python (via JPype) | Active | Makes the massive Java Tetrad algorithms available in Python workflows using JPype bridges19. | Suffers from cross-language serialization overhead when passing large matrices between Java and Python20. | Highlights the need for interoperable graph definitions across languages. |
| causal-cmd | BD2KCCD19 | Command Line / Java | Active | Allows users to execute arbitrary Tetrad causal searches directly at the command line for fast scripting19. | Lacks interactive step-by-step graphical feedback during the algorithmic search process19. | Demonstrates the utility of lightweight execution environments for simulation. |
| r-tetrad | CMU-Phil19 | R (via Python/Java) | Maintained | Bridges R statistical environments with Tetrad's Java core via Python reticulate and JPype wrappers19. | Double-bridging architecture introduces complex dependency chain failures20. | Highlights language interoperability challenges matrixed in Section F. |
| GRaSP | CMU-Phil22 | Java / Python | Active | Implements Greedy Relaxations of the Sparsest Permutation algorithm for highly scalable DAG discovery22. | Requires domain knowledge tuning to prevent aggressive pruning of valid causal edges22. | Directly relates to acyclicity checking and graph pruning operations (Sample S14). |
| boss | CMU-Phil23 | Java | Active | Best Order Score Search; provides fast scalable and accurate discovery of DAGs utilizing Grow-Shrink Trees23. | Highly specialized; applies primarily to linear, Gaussian data structures23. | Influences the topological sorting optimizations required for rapid simulation. |
| petgraph | petgraph.github6 | Rust | Active | Lightning-fast, memory-safe data structures (Graph, StableGraph, GraphMap) and algorithms (Dijkstra)6. | Purely a structural graph library; contains absolutely no inherent causal or probabilistic semantics6. | Foundational for Rust causal graph implementations and intervention operators (Samples S18, S19). |
| JGraphT | jgrapht.org4 | Java | Highly Active | Strict type safety, deep algorithm libraries, covering directed/undirected, simple/multigraph architectures4. | Object-per-vertex overheads (HashSet/HashMap usage) makes it extremely memory-heavy for massive networks5. | Dictates the architectural design of Java graph surgery and topological sorting (Sample S14, S16). |
| CasADi | casadi.org26 | C++, Python, Matlab | Active | Symbolic framework for automated differentiation and numerical optimization on sparse matrix-valued computational graphs26. | Designed strictly for optimal control engineering; requires substantial adaptation for discrete causal counterfactual queries27. | Informs the C-based structural model matrix simulations and optimizations (Sample S13). |
F. Feasibility Matrix
The integration of causal reasoning requires evaluating programming language capabilities across three distinct dimensions: native support for graphs and mathematical structures, viability through interoperable third-party libraries, and conceptual overhead. The feasibility matrix below delineates these capabilities, ensuring that software architects select the appropriate toolchain for specific causal tasks.
| Language | Native Causal & Graph Strength | Viability Through Interoperable Libraries | Conceptual Difficulty & Optimization Challenges |
|---|---|---|---|
| Python | Moderate: Natively slow for deep graph traversals, but provides excellent, highly readable syntax for defining mathematical structural equations. | Strong: The PyWhy ecosystem (DoWhy, causal-learn, EconML)15 and pgmpy11 offer top-tier, industry-standard integrations. | Low-level memory mapping of latent variables is highly abstracted, making it difficult to teach the physical implications of confounding bias. |
| C\# | Moderate: LINQ and strict object types assist in building robust parsers for structural equations and directed edge lists. | Strong: Infer.NET1 provides phenomenal probabilistic message-passing frameworks for resolving Bayesian uncertainties. | Dynamic graph surgery is often cumbersome due to the static typing rigidity and interface constraints required in enterprise C\# architectures. |
| C | Strong: Direct memory access (malloc/free) and contiguous arrays perfectly align with performance-heavy DAG traversal and adjacency matrices. | Moderate: Integrates cleanly with high-performance math libraries, but lacks specific causal-inference semantics natively. | High-level counterfactual abduction logic requires massive, error-prone boilerplate code to handle dynamic equation systems. |
| Java | Strong: Mature Object-Oriented Programming (OOP) structure maps perfectly to Node/Edge/Graph causal paradigms. | Strong: JGraphT4 and Tetrad19 provide the deepest, most rigorously tested ecosystem for graph traversal and causal discovery. | Advanced probabilistic tensor operations and autograd functionality are significantly more difficult to implement natively than in Python. |
| Rust | Strong: The borrow checker and strict ownership model naturally prevent cyclic dependencies and unsafe state mutations during graph surgery6. | Moderate: petgraph handles foundational structure6, but specific causal-inference estimating crates are exceedingly rare. | Implementing complex statistical estimators (e.g., Double Machine Learning) from scratch lacks the robust native ecosystems found in Python or R. |
G. Illustration and Code Integration Notes
To maximize the efficacy of these structural blueprints, raw code samples must be tightly coupled with architectural illustrations, rigorous constraint warnings, and seamless integration mechanisms within the broader computational pipeline. The deployment of causal software is fundamentally different from traditional machine learning; the outputs dictate real-world interventions, meaning software failures carry substantial consequences. First, causal algorithms are inherently visual. Every code sample manipulating a DAG (e.g., Python Sample S01, Rust Sample S19) must be paired in the documentation with a visual node-and-arrow diagram. Interventions must visually demonstrate the concept of "graph surgery" by showing the physical removal of back-door incoming edges as a red, dashed line, explicitly communicating to the developer how the [Figure omitted from source export]\-operator alters the topology. Second, code integration must highlight topological failure cases. If an automated planning system attempts to intervene on an endogenous variable but accidentally introduces a cyclic dependency (e.g., A [Figure omitted from source export] B [Figure omitted from source export] C [Figure omitted from source export] A), the framework must hard-fail immediately. Sample S14 (Acyclicity Check) should be paired with an illustration of a feedback loop, explicitly demonstrating why causal time-slices must move strictly forward, and why the system rejects the transaction. Third, code comments alone are insufficient for documenting causal assumptions. Software outputs generating Average Treatment Effects (ATE) must prominently warn the user regarding the SUTVA, Positivity, and Ignorability assumptions. The integration pipeline should automatically flag interventional queries that assume no unmeasured confounding, injecting runtime warnings if the adjustment set is empty. Where applicable, samples should directly reference production-ready ecosystem tools. For instance, any custom structural evaluation must link out to the PyWhy ecosystem or Tetrad15 to demonstrate how enterprise architectures scale the same foundational logic to massive datasets.
H. Source Integration Ledger
The synthesis of causal code paradigms leverages the foundational architectures of established scientific computing projects mapped across multiple ecosystems. The ledger below tracks how specific architectural derivations were sourced from the underlying research material to inform the code samples and structural designs.
| Concept / Architecture | Derivation Source & Material Logic |
|---|---|
| Probabilistic Programming | Abstracted directly from Microsoft's Infer.NET1, applying the principles of Bayesian message passing and expectation propagation3 to weight causal assumptions in C\# (Sample S06). |
| Causal Discovery & Scoring | Informed by CMU-Phil's causal-learn13 and tetrad19, utilizing continuous integration of search methodologies (PC, GES, GRaSP) for mapping structural graph constraints15. |
| Interventions & Do-Calculus | Drawn extensively from the dowhy and EconML ecosystem frameworks16, integrating physical graph surgery principles directly into the Python and Rust manipulation samples (S04, S19). |
| Graph Traversal & Structures | Synthesized from petgraph6 for realizing Rust borrow-checked DAGs, and jgrapht4 for implementing strict Java topological constraints and cycle detection (S14). |
| High-Performance Simulation | Rooted in the numerical optimization and sparse DAG methodologies found in CasADi26, bridging low-level C matrix performance with rapid forward-pass structural equations (S13). |
I. Integration JSON
The following JSON block standardizes the deliverables for the OntologicalMachine.com content management system, ensuring proper indexing, tagging, and deployment of the causal reasoning expansion pack.
JSON { "packet\_id": "causal\_reasoning\_architecture\_v1", "metadata": { "topic": "Causal Reasoning, Interventions, and Counterfactuals", "target\_audience": "Advanced Software Engineers & Data Scientists", "architectural\_focus": "Code-First Structural Modeling", "languages\_supported": \["Python", "C\#", "C", "Java", "Rust"\] }, "deliverables": { "conceptual\_guide": { "sections\_covered": \["Correlation vs Structure", "Interventions", "Counterfactuals", "Confounding", "Identifiability", "Assumptions"\] }, "sample\_plan": { "total\_specifications": 22, "fully\_implemented\_drafts": 10, "themes\_covered": \[ "Graph Definition", "Acyclicity Constraints", "Structural Equations", "Graph Surgery", "Counterfactual Evaluation", "Confounding Representation", "Bayesian Assumptions", "Deterministic Simulation", "Validation Engines", "Strategic Planning" \] }, "ecosystem\_analysis": { "total\_projects\_reviewed": 20, "key\_ecosystems": \["PyWhy", "CMU-Phil", "Microsoft Research", "Uber CausalML", "JGraphT", "Petgraph"\] }, "feasibility\_matrix": { "evaluation\_dimensions": \["Native Graph Capabilities", "Interoperable Libraries", "Conceptual Overhead"\] } }, "deployment\_notes": { "visual\_requirements": "Mandatory DAG illustrations for all structural graph mutations.", "runtime\_warnings": "Enforce strict warnings for SUTVA and Ignorability assumptions during ATE evaluation." } }
Works cited
1. arXiv:1909.08549v2 \[cs.AI\] 8 Oct 2022, https://arxiv.org/pdf/1909.08549
2. Papers using Infer.NET \- Microsoft .NET, https://dotnet.github.io/infer/papers.html
3. Usability of Probabilistic Programming Languages, https://www.cl.cam.ac.uk/\~afb21/publications/PPIG-2019-final.pdf
4. Master repository for the JGraphT project \- GitHub, https://github.com/jgrapht/jgrapht
5. The jGraphT library \- GitHub Pages, https://tdp-2023.github.io/materiale/slide/06-02-jGraphT-library.pdf
6. petgraph/petgraph: Graph data structure library for Rust. \- GitHub, https://github.com/petgraph/petgraph
7. petgraph \- crates.io: Rust Package Registry, https://crates.io/crates/petgraph/0.7.1
8. Probabilistic programming | Request PDF \- ResearchGate, https://www.researchgate.net/publication/266657500\_Probabilistic\_programming
9. Automated Quantized Inference for Probabilistic Programs with AQUA, https://misailo.cs.illinois.edu/papers/isse22.pdf
10. CausalInference \- pgmpy, https://pgmpy.org/api/generated/causal\_inference/pgmpy.inference.CausalInference.CausalInference.html
11. pgmpy \- GC.OS, https://gcos.ai/projects/pgmpy/
12. pgmpy/pgmpy: Python Toolkit for Causal and Probabilistic Reasoning, https://github.com/pgmpy/pgmpy
13. GitHub \- py-why/causal-learn: Causal Discovery in Python. Learning, https://github.com/py-why/causal-learn
14. NeurIPS Poster Causal-learn: Causal Discovery in Python, https://neurips.cc/virtual/2024/poster/98316
15. PyWhy \- GitHub, https://github.com/py-why
16. dowhy/dowhy/causal\_model.py at main · py-why/dowhy \- GitHub, https://github.com/py-why/dowhy/blob/main/dowhy/causal\_model.py
17. EconML \- Microsoft Research, https://www.microsoft.com/en-us/research/project/econml/
18. Releases · uber/causalml \- GitHub, https://github.com/uber/causalml/releases
19. GitHub \- cmu-phil/tetrad: Repository for the Tetrad Project, www.phil, https://github.com/cmu-phil/tetrad
20. A New Python Interface with R Support for Tetrad Causal Search, https://pmc.ncbi.nlm.nih.gov/articles/PMC11316512/
21. Code Repositories \- Tetrad \- Department of Philosophy, https://www.cmu.edu/dietrich/philosophy/tetrad/educational-materials/technical-details/code-repositories.html
22. cmu-phil/grasp: Materials, code, datasets, etc., for the GRaSP project, https://github.com/cmu-phil/grasp
23. Philosophy Department, Carnegie Mellon University \- GitHub, https://github.com/cmu-phil
24. JGraphT — Graph Formats It Reads & Writes | GraphInOut.com, https://graphinout.com/tool/jgrapht
25. JGraphT, https://jgrapht.org/
26. CasADi is a symbolic framework for numeric optimization ... \- GitHub, https://github.com/casadi/casadi
27. CasADi \- GitHub, https://github.com/casadi
28. optimization/py-casadi \- robotpkg, http://robotpkg.openrobots.org/robotpkg/optimization/py-casadi/index.html
29. tetrad\_plus/README.md at main \- GitHub, https://github.com/kelvinlim/tetrad\_plus/blob/main/README.md