Adaptive Tau¶
adaptive_tau
¶
Bounded adaptive tau-leaping for stochastic reaction networks.
AdaptiveTauLeapingConfig(leap_tolerance=0.03, critical_threshold=10, exact_fallback_multiplier=10.0, max_steps=1000000, max_retries=20, forcing_breakpoints=())
dataclass
¶
Controls for bounded adaptive tau-leaping.
Attributes:
| Name | Type | Description |
|---|---|---|
leap_tolerance |
float
|
Relative leap-condition tolerance. |
critical_threshold |
int
|
A reaction is critical when fewer than this many firings would exhaust one of its reactants. Zero disables critical classification. |
exact_fallback_multiplier |
float
|
Use exact SSA when the proposed leap is less than this multiple of the mean time to the next event. Zero disables this fallback. |
max_steps |
int
|
Maximum accepted leaps or exact events per output interval. |
max_retries |
int
|
Maximum post-leap rejections before failing. |
forcing_breakpoints |
tuple[float, ...]
|
Strictly increasing finite forcing-change times. Leaps end at these boundaries; exact events at or beyond a boundary are discarded. Rates must be right-continuous and constant in time between boundaries for exact fallback. |
__post_init__()
¶
Validate adaptive controls.
Raises:
| Type | Description |
|---|---|
ValueError
|
If a control is outside its valid range. |
Source code in src/op_engine/adaptive_tau.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
AdaptiveTauLeapingSolver(core, stoichiometry, reactant_stoichiometry, *, reaction_axis='state', dependency_incidence=None, propensity_orders=None)
¶
Adaptive non-negative Poisson tau-leaping with exact critical events.
The implementation follows the Cao-Gillespie-Petzold species-based pre-leap selector. Reactions near exhaustion are bounded to at most one collective exact event. A negative post-leap proposal is rejected and retried at half the attempted tau; populations and firing counts are never clipped.
Initialize the reaction and reactant structures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core
|
ModelCore
|
Model state and output-time container. |
required |
stoichiometry
|
Array
|
Net integer state changes by reaction. |
required |
reactant_stoichiometry
|
Array
|
Non-negative integer reactant counts by
species and reaction. This cannot be inferred safely from net
stoichiometry for catalytic reactions. For a reaction with a
positive |
required |
reaction_axis
|
str | int
|
State axis changed by reaction firings. |
'state'
|
dependency_incidence
|
Array | None
|
Optional |
None
|
propensity_orders
|
Array | None
|
Optional |
None
|
Source code in src/op_engine/adaptive_tau.py
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | |
n_reactions
property
¶
Return the number of reaction channels.
run(propensity_func, poisson_sampler, ssa_sampler, *, config=None)
¶
Advance a bounded adaptive trajectory through the output grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
propensity_func
|
PropensityFunction
|
Reaction-channel propensities. |
required |
poisson_sampler
|
PoissonSampler
|
Backend-specific noncritical Poisson sampler. |
required |
ssa_sampler
|
SSASampler
|
Backend-specific exact-event sampler. |
required |
config
|
AdaptiveTauLeapingConfig | None
|
Optional adaptive, retry, and forcing controls. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If a step guard, retry guard, or non-negativity invariant fails. |
Source code in src/op_engine/adaptive_tau.py
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 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 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 | |