simulating canada’s oil patch

I built a digital twin of Canada’s oil and gas sector because spreadsheets lie. Traditional models treat the industry as a monolith, smoothing out what matters most: how individual companies make decisions under stress. This simulation represents 880 assets aggregated from 895,000 wells, 47 companies, and regulators as autonomous agents with their own objectives. The result is a living model of an industry generating $180 billion annually, employing hundreds of thousands, and navigating the transition to low-carbon futures.

Why traditional models miss the point

Conventional economic models smooth over the decisions of individual actors. Aggregated equations approximate flows of capital and output, but they miss how debt-laden firms respond to carbon pricing, how infrastructure constraints amplify regional differentials, and how stress cascades through balance sheets. Predicting industry behavior with aggregate equations is like modeling traffic with fluid mechanics: broad patterns emerge, but the traffic jams, accidents, and bottlenecks are invisible. Transitions in oil and gas depend on these emergent effects.

How the model works

The system represents each entity as an autonomous decision-making agent. Assets follow decline curves, companies allocate capital, provinces enforce rules, and the federal government sets pricing. The core loop connects production, finance, capital, and strategy.

graph LR
  subgraph Production
    A[Assets] --> B[Decline Curves] --> C[Drilling]
  end
  subgraph Financial
    D[Volumes] --> E[Revenue and Cost] --> F[Free Cash Flow]
  end
  subgraph Capital
    G[Priority Stack] --> H[Debt and Liquidity] --> I[Growth Capex]
  end
  subgraph Strategy
    J[KPIs] --> K[Reinvest Ratio] --> L[Portfolio Mix]
  end
  Production -->|outputs| Financial
  Financial -->|cash| Capital
  Capital -->|deploys| Strategy
  Strategy -->|directs| Production

Four interconnected modules feed one another in a continuous loop: production, cash flow, capital deployment, and strategic redirection. This architecture keeps the model realistic without losing tractability, letting both micro-level decisions and macro-level outcomes emerge naturally.

Industry structure

The agent hierarchy mirrors the industry itself, from wells to country-level oversight. 880 asset agents aggregated from 895,000 wells, 47 company agents reflecting the corporate landscape, four provincial regulators, and a national orchestrator.

flowchart LR
  Country["Country orchestrator"]

  subgraph Companies["Companies"]
    direction TB
    C1["Large"]
    C2["Medium"]
    C3["Small"]
  end

  subgraph Divisions["Divisions"]
    direction TB
    D1["Oil sands"]
    D2["Conventional"]
    D3["Gas"]
  end

  subgraph Assets["Assets"]
    direction TB
    A1["Asset A"]
    A2["Asset B"]
    A3["Asset C"]
  end

  Country --> C1 & C2 & C3
  C1 & C2 & C3 --> D1 & D2 & D3
  D1 & D2 & D3 --> A1 & A2 & A3

Large companies contain multiple divisions (oil sands, conventional, and gas) while assets carry production rates, emissions intensities, and regulatory allowances. The hierarchical structure captures local decisions and systemic outcomes simultaneously, enabling analysis of both micro-level behavior and macro-level policy impacts.

Asset clustering

Clustering 900,000 wells down to 880 representative assets kept the model computationally tractable without losing realism. A k-nearest neighbor method preserves production curves, financial metrics, geospatial context, and ownership. Alberta accounts for 78% of clustered assets, shale or tight and conventional production dominate counts, and oil sands concentrate into a smaller set of large clusters. This reduces dimensionality roughly 1,000x while maintaining the heterogeneity that matters for policy and capital allocation.

Corporate strategy

A weighted scorecard drives reinvestment choices. Reinvestment gap (40%), debt coverage (30%), production versus peers (20%), and shareholder yield (10%) combine into a composite score that directs firms to grow, hold flat, or decline.

flowchart LR
  R[Reinvestment Gap, 40%] --> Total[Score]
  D[Debt Coverage, 30%] --> Total
  P[Production vs Peers, 20%] --> Total
  S[Shareholder Yield, 10%] --> Total
  Total --> Decline[DECLINE]
  Total --> Hold[HOLD]
  Total --> Grow[GROW]

This generates realistic boom-bust cycles, with firms adjusting capital allocation in response to prices, balance sheet stress, and investor demands. Peer performance pressure and dividend expectations are explicit, so company behavior reflects real-world incentives and constraints.

Carbon economy

Alberta’s TIER system is modeled with full accounting. Every compliance payment, credit purchase, and innovation fund allocation is tracked with conservation of value. Credits expire on an eight-year cycle and retire first-in-first-out. Projects are scored on cost effectiveness, abatement impact, and potential jobs. External carbon markets clear at dynamic prices.

flowchart LR
  Company[Company] -->|Payment| Fund[Carbon Fund]
  Fund -->|Allocate| Proj1[Carbon Capture]
  Fund -->|Allocate| Proj2[Hydrogen]
  Fund -->|Allocate| Proj3[Electrification]
  Fund -->|Allocate| Proj4[Methane Reduction]
  Company -->|Buy| Market[External Credits]
  subgraph Credits
    Mint[Issue] --> Hold[Hold with Expiry] --> Retire[Retire FIFO]
  end
  Market --> Credits
  Fund --> Credits

The simulation shows how policy interacts with firm behavior - how compliance costs, offsets, and reinvestment into innovation cascade through company strategies and asset-level economics. This reveals the effectiveness of different carbon pricing mechanisms and their distributional impacts across the industry.

Data architecture

A hybrid architecture handles data integration with graceful degradation. Assets can run in pure simulation mode using decline curves, in external mode driven by provider APIs, or in a hybrid that blends both with quality scoring.

flowchart LR
  API[External Data] --> Hybrid[Hybrid Mode]
  SIM[Simulated Data] --> Hybrid
  SIM --> SimOnly[Simulation Mode]
  API --> ExtOnly[External Mode]

This design lets the system integrate new industry feeds seamlessly while maintaining accuracy and transparency. Every assumption is documented and traceable, supporting reproducibility and validation against real-world outcomes.

Agent decision framework

Each agent follows a clear observe-decide-act-learn cycle. This makes policies auditable and improves testability of strategic changes.

sequenceDiagram
  participant Agent
  participant Tools
  participant Store
  Agent->>Tools: Request observation
  Tools-->>Agent: Observation
  Agent->>Store: Write state
  Agent->>Tools: Execute action
  Tools-->>Agent: Result
  Agent->>Agent: Policy update and next step

Geospatial clustering and quality scoring ensure data integrity, with graceful degradation to modeled outputs when external data is missing. The mathematical foundation spans 15 core algorithms: time series models for price forecasting, optimization routines for resource allocation, and Monte Carlo methods for risk assessment.

What it does

The implementation covers 880 assets across four provinces and 47 companies, with 20-year forecasts. Scenarios test oil prices, carbon costs, and production assumptions, with outputs delivered in minutes. Built in Python with standard data science libraries, the system is extensible and portable, suited for dashboards and policy briefs.

The system analyzes production, financial, and emissions pathways at both company and national levels. Outputs include charts, maps, and summary data tables that translate complex dynamics into actionable insights for investors, policymakers, and industry stakeholders navigating Canada’s energy transition.

Why this matters

Digital twins let you experiment with scenarios that no real-world system would tolerate. By combining agent-based modeling, clustering techniques, and rigorous mathematics, you can simulate Canada’s oil and gas sector in detail that supports evidence-based decision making. The tool highlights pathways, risks, and opportunities in a sector under transformation.