API Reference¶
This section provides auto-generated documentation for the nhra_gt Python package.
If you want comprehensive coverage, start with the Full API Index which is generated from the package module tree.
Core Modules¶
Engine¶
nhra_gt.engine.Params
¶
Bases: BaseModel
Pydantic Params wrapper for validation and tooling.
Source code in src/nhra_gt/domain/params.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
Functions¶
from_flat_dict(data)
classmethod
¶
Creates a Params object from a potentially flat dictionary.
Source code in src/nhra_gt/domain/params.py
flatten()
¶
Returns a flat dictionary representation of all parameters.
Source code in src/nhra_gt/domain/params.py
to_params_jax()
¶
Converts Pydantic Params to JAX-native ParamsJax.
Source code in src/nhra_gt/domain/params.py
nhra_gt.engine.run_simulation(*, years=10, n_samples=1, params=None, seed=0, start_year=2025, strategies=None)
¶
Run a baseline simulation with optional Monte Carlo sampling.
This is a convenience wrapper around the JAX core (run_simulation_jax) for
documentation examples and quick interactive use.
Returns a dict of numpy arrays. For n_samples == 1, arrays are shaped
[num_steps]. For n_samples > 1, arrays are shaped [n_samples, num_steps].
Source code in src/nhra_gt/engine.py
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 | |
Agents¶
nhra_gt.agents.base.HeuristicAgent
¶
Subgames¶
nhra_gt.subgames.games.GameParams
dataclass
¶
Inputs used to parameterise stage games (dimensionless indices).
Source code in src/nhra_gt/subgames/games.py
nhra_gt.subgames.games.definition_game(gp)
¶
Definition game: 'R' realism vs 'E' strict efficient-price framing.
Source code in src/nhra_gt/subgames/games.py
nhra_gt.subgames.games.bargaining_game(gp)
¶
Bargaining game: 'A' agree to converge vs 'D' defer/escalate.
Source code in src/nhra_gt/subgames/games.py
nhra_gt.subgames.games.cost_shifting_game(gp)
¶
Cost shifting game: invest upstream 'I' vs shift downstream 'S'.
Source code in src/nhra_gt/subgames/games.py
nhra_gt.subgames.games.discharge_coordination_game(gp)
¶
Discharge coordination: coordinate 'C' vs fragment 'F'.
Source code in src/nhra_gt/subgames/games.py
Nash Solver¶
nhra_gt.subgames.nash.TwoPlayerGame
dataclass
¶
Represents a 2-player normal-form game.
Includes payoff matrices and action labels for both players.
Source code in src/nhra_gt/subgames/nash.py
nhra_gt.subgames.nash.solve_all_equilibria(game)
¶
Interfaces & Protocols¶
nhra_gt.interfaces.protocols.Strategy
¶
Bases: Protocol
Protocol for a game-theory strategy (e.g., mixed or pure).
Source code in src/nhra_gt/interfaces/protocols.py
nhra_gt.interfaces.protocols.NormalFormGame
¶
Bases: Protocol
Protocol for a normal-form game container.
Source code in src/nhra_gt/interfaces/protocols.py
Attributes¶
num_players
property
¶
Number of players in the game.
Functions¶
payoffs(actions)
¶
Calculate payoffs for all players given an action profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
actions
|
IntArray
|
An array of actions, one for each player. |
required |
Returns:
| Type | Description |
|---|---|
FloatArray
|
An array of payoffs, one for each player. |
Source code in src/nhra_gt/interfaces/protocols.py
nhra_gt.interfaces.protocols.ExtensiveFormGame
¶
Bases: Protocol
Protocol for an extensive-form (tree) game.
Source code in src/nhra_gt/interfaces/protocols.py
See Also¶
- Game Theory Models Guide for conceptual documentation
- Design Documentation for architecture overview