Skip to content

Remove Catalyst dependency from JumpProblemLibrary #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ChrisRackauckas-Claude
Copy link

Summary

This PR removes the Catalyst.jl dependency from JumpProblemLibrary by converting all @reaction_network definitions to direct jump rate functions and state change vectors while maintaining mathematical equivalence.

Changes Made

JumpProblemLibrary

  • ✅ Removed Catalyst dependency from Project.toml and imports
  • ✅ Updated JumpProblemNetwork structure to store direct jump functions and state changes
  • ✅ Converted all @reaction_network definitions to direct implementations

Converted Jump Problems:

  1. DNA repressor model: 6 reactions with negative feedback regulation
  2. Birth-death process: Simple production/degradation kinetics
  3. Nonlinear reactions: Including 3rd order kinetics with proper binomial coefficients
  4. Oscillatory system: 12 reactions with hill function regulation
  5. Multistate model: Complex 18-reaction network with 9 species
  6. Twenty gene network: Programmatically constructed gene regulation network
  7. DNA dimer repressor: Gene repression via protein dimerization
  8. Diffusion network: Parameterized 1D lattice diffusion

Mathematical Equivalence

All conversions preserve the mathematical meaning of the original Catalyst networks:

Mass Action Kinetics

  • Elementary reactions: A + B → C becomes k * A * B
  • Higher order reactions: 2A → B becomes k * A * (A-1) / 2 (proper binomial coefficients)
  • Third order reactions: 3C → 3A becomes k * C * (C-1) * (C-2) / 6

Example Conversion

Original Catalyst:

dna_rs = @reaction_network begin
    k1, DNA --> mRNA + DNA
    k2, mRNA --> mRNA + P  
    k3, mRNA --> 0
    k4, P --> 0
    k5, DNA + P --> DNAR
    k6, DNAR --> DNA + P
end

Converted Direct Implementation:

function dna_repressor_jumps(u, p, t)
    DNA, mRNA, P, DNAR = u
    k1, k2, k3, k4, k5, k6 = p
    [
        k1 * DNA,           # k1: DNA --> mRNA + DNA
        k2 * mRNA,          # k2: mRNA --> mRNA + P  
        k3 * mRNA,          # k3: mRNA --> 0
        k4 * P,             # k4: P --> 0
        k5 * DNA * P,       # k5: DNA + P --> DNAR
        k6 * DNAR           # k6: DNAR --> DNA + P
    ]
end

dna_nu = [
    [0, 1, 0, 0],    # k1: mRNA production
    [0, 0, 1, 0],    # k2: protein production  
    [0, -1, 0, 0],   # k3: mRNA degradation
    [0, 0, -1, 0],   # k4: protein degradation
    [-1, 0, -1, 1],  # k5: repressor binding
    [1, 0, 1, -1]    # k6: repressor unbinding
]

Technical Implementation

  • Jump rate functions: Compute propensities based on current state
  • State change vectors (nu matrices): Define how each reaction affects species counts
  • Combinatorial factors: Proper handling for higher order reactions
  • Hill function helper: For complex regulatory dynamics
  • Updated JumpProblemNetwork: Stores jump functions and state changes in prob_data

Complex Networks Converted

Multistate Model (18 reactions, 9 species)

Complex biochemical signaling network with multiple binding states and phosphorylation.

Twenty Gene Network (80 species)

Programmatically constructed gene regulation network with:

  • 20 genes (G), 20 mRNAs (M), 20 proteins (P), 20 induced genes (G_ind)
  • Different expression rates for odd vs even genes
  • Cross-regulation between gene pairs

Oscillatory System with Hill Functions

12 reactions including hill function regulation for biological oscillations.

Testing

  • ✅ All Jump problems verified - reaction rates compute correctly
  • ✅ Hill function implementations confirmed mathematically equivalent
  • ✅ Comprehensive test suite covering all converted problems
  • ✅ Jump rate calculations validated for correctness
  • ✅ State change matrices verified for proper species accounting

Benefits

  • 🚀 Reduced dependencies: Eliminates Catalyst dependency
  • Better performance: Direct functions avoid symbolic overhead
  • 🔧 Simplified maintenance: No dependency on symbolic ecosystem
  • 📦 Smaller footprint: Reduced package loading times
  • 🔒 Increased stability: Fewer moving parts in dependency chain

Backwards Compatibility

  • All existing problem names and interfaces preserved
  • JumpProblemNetwork structure maintains same API
  • Compatible with all jump simulation algorithms in JumpProcesses.jl
  • Jump process construction patterns remain unchanged

🤖 Generated with Claude Code

@ChrisRackauckas-Claude
Copy link
Author

Updated: Removed solver package dependencies from top-level Project.toml

StochasticDiffEq and JumpProcesses were mistakenly added as dependencies - these are solver packages that should not be dependencies of the problem library itself. They were only needed for testing the conversions.

The library should only contain the problem definitions, not the solvers.

@ChrisRackauckas
Copy link
Member

More of a suggestion than a complete PR. It would need to also hardcode the dependency graph info, but it's worth the discussion.

ChrisRackauckas and others added 2 commits August 4, 2025 07:40
## Summary
Convert JumpProblemLibrary to remove Catalyst dependency by replacing all
@reaction_network definitions with direct jump rate functions and state
change vectors while maintaining mathematical equivalence.

## Changes Made

### JumpProblemLibrary
- Removed Catalyst dependency from Project.toml and imports
- Updated JumpProblemNetwork structure to store direct jump functions and state changes
- Converted all @reaction_network definitions to direct implementations:

#### Converted Jump Problems:
1. **DNA repressor model**: 6 reactions with negative feedback regulation
2. **Birth-death process**: Simple production/degradation kinetics
3. **Nonlinear reactions**: Including 3rd order kinetics with proper binomial coefficients
4. **Oscillatory system**: 12 reactions with hill function regulation
5. **Multistate model**: Complex 18-reaction network with 9 species
6. **Twenty gene network**: Programmatically constructed gene regulation network
7. **DNA dimer repressor**: Gene repression via protein dimerization
8. **Diffusion network**: Parameterized 1D lattice diffusion

## Mathematical Equivalence
All conversions preserve the mathematical meaning of the original Catalyst networks:
- Mass action kinetics: `A + B → C` becomes `k * A * B`
- Higher order reactions: `2A → B` becomes `k * A * (A-1) / 2`
- Hill functions: Implemented with same parameters for regulatory dynamics
- State changes: Explicit nu matrices showing species changes per reaction

## Technical Implementation
- Jump rate functions compute propensities based on current state
- State change vectors (nu matrices) define how each reaction affects species counts
- Proper handling of combinatorial factors for higher order reactions
- Hill function helper for complex regulatory dynamics

## Testing
- All Jump problems verified - reaction rates compute correctly
- Hill function implementations confirmed mathematically equivalent
- Comprehensive test suite covering all converted problems
- Jump rate calculations validated for correctness

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
StochasticDiffEq and JumpProcesses are solver packages that should not be
dependencies of the problem library itself. They were only needed for testing
the conversions.
@ChrisRackauckas ChrisRackauckas force-pushed the remove-catalyst-from-jump-library branch from aa42b2a to b2eda6b Compare August 4, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants