NetModel silently ignores a condition/mutant perturbation of a parameter that the .net file stores as an expression (ConstantExpression)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
The bug is in pybnf/pset.py line 1325 where NetModel.copy_with_param_set uses a regex that only matches numeric literals, ignoring expression-based parameters like 'Btot Atot*2'. Start by examining the regex and the substitution logic. Look at _get_mutant_model (lines 1015-1016) and _override_param_block_values to understand the correct perturbation flow. Run the provided reproduction steps with fit_bionetgen.conf to see the silent failure. The fix must handle ConstantExpression parameters and ensure mutations apply, with a warning if a parameter is not found.
Written by the indexing model from the issue text.
Description
NetModel.copy_with_param_set substitutes a parameter only when its .net line matches the regex at 1325, which requires a numeric literal value. BNG2.pl writes a derived parameter as its expression ('4 Btot Atot*2 # ConstantExpression'), so a mutant pset entry for Btot matches nothing and is dropped without a message. _get_mutant_model (1015-1016) explicitly allows '=' on a fixed parameter (ADR-0027). The BNGL-emit path (_override_param_block_values) and the bngsim backend both apply the same perturbation.
Failure scenario
BNGL with 'Btot = Atot*2' seeding B(a), and a condition or mutant 'KO: Btot = 0', with bngl_backend = bionetgen. The KO simulation is identical to wild type (AB(t=10)=99.90, Bfree(0)=200), and the KO data is scored against the WT trajectory. On bngsim the same mutant gives AB=0 and Bfree(0)=0.
Reproduction (independent re-run)
I ran .venv/bin/pybnf -c fit_bionetgen.conf -o and fit_bngsim.conf, which are identical except for the backend. pybnf was imported from pybnf/init.py.
- bionetgen: best objective 39184.97. The KO mutant net Simulations/gen1ind2/ab2_gen1ind2ko.net still reads
2 Btot Atot*2 # ConstantExpression. The scored KO trajectory ab2_gen1ind2ko_ko.gdat has AB(0)=0, Bfree(0)=200, AB(1)=72.33 and AB(10)=90.94, byte-identical to the WT gdat. - Correct KO values: with Btot=0 there is no B, so AB(t)=0 and Bfree=0 for all t (worked out by hand, and matched by the bngsim run).
- bngsim: best objective 0.0047 on the same conf.
- Where 39185 comes from: it is almost exactly half the sum of the squared WT AB values, i.e. the KO data (AB=0) scored against the WT trajectory.
- No warning: the run log has none about Btot. The exported Results/ab2_gen1ind2ko.bngl nonetheless says
Btot 0.0.
Reachability
An edition-2 .conf using documented keys: model: ab2.bngl, bngl_backend = bionetgen, condition: ko, perturbations: Btot = 0, experiment: wt, data: wt.exp, experiment: ko, condition: ko, data: ko.exp, uniform_var = kf 0.009 0.011, job_type = de. The BNGL parameters block has Btot Atot*2, and B(a) is seeded with Btot. The legacy mutant = model KO Btot=0 : ko.exp goes through the same _get_mutant_model and copy_with_param_set path. bngl_backend = auto also reaches it whenever bngsim is unavailable or its bridge fails (base.py:698/702).
Where
pybnf/pset.py:1325
Found in a whole-codebase audit for silently wrong results (2026-09-23); the reproduction above was re-run independently of the original finding.
- Dominant language
- Python
- Stars
- 25
- Forks
- 25
- Avg merge
- 2h 24m
- Merged PRs (30d)
- 85
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lanl/PyBNF
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
A transient error from the BioNetGen download turns a whole test matrix leg red before any test runs Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 65/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 65/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
huggingface/Repo2RLEnv#163 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
NousResearch/hermes-agent#121143 ·