Skip to content

Commit

Permalink
nested if Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfaeder committed Jun 27, 2024
1 parent 5f56b95 commit dde4439
Show file tree
Hide file tree
Showing 20 changed files with 862 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ testing
Issues/test.py
Issues/Caroline
Issues/273/action_parameter/
Issues/omer*
Examples/Polymer_branch/polymer_adele
Examples/Polymer_branch/polymer_v2
release
Issues/.DS_Store
.DS_Store
bng2/libsource/muparser_v2_2_4
Binary file modified Issues/.DS_Store
Binary file not shown.
39 changes: 39 additions & 0 deletions Issues/nestedIF/BillsTest.bngl

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions Issues/nestedIF/BillsTest/2024_05_09__17_36_20/BillsTest.bngl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
begin model
# example of NFsim error caused by too deep nesting of if-then-else
statements in function definition

begin molecule types
V()
counter()
end molecule types

begin seed species
V() 0
counter() 0
end seed species

begin observables
Molecules t counter()
Molecules V V()
end observables

begin functions
# CASE 1: constant rate
#v_rate()=1e-6
# CASE 2: variable rate defined in terms of nested if-then-else statements
v_rate() 1e4*if(t<=297,1e-6,if(t<=298,1.12314383e-05,if(t<=299,9.94451901e-06,if(t<=300,4.74735912e-05,if(t<=301,2.11759573e-05,0)))))
#v_rate() 1e4*if(t<=297,1e-6,if(t<=298,1.12314383e-05,if(t<=299,9.94451901e-06,if(t<=300,4.74735912e-05,if(t<=301,2.11759573e-05,if(t<=302,0,if(t<=303,8.68001985e-05,if(t<=304,3.62421529e-05,if(t<=305,8.93918412e-05,if(t<=306,0.000146015146,if(t<=307,0.00010497702,if(t<=308,7.94473222e-05,if(t<=309,6.05025646e-05,if(t<=310,0.000364352105,if(t<=311,0.000201739564,if(t<=312,0.000357759509,if(t<=313,0.000269842203,if(t<=314,0.000257166618,if(t<=315,0.000470011593,if(t<=316,0.000451941228,if(t<=317,0.000253944211,if(t<=318,0.0006239742879999999,if(t<=319,0.00066809744,if(t<=320,0.000499101616,if(t<=321,0.000321104073,if(t<=322,0.000519506807,if(t<=323,0.000424076528,if(t<=324,0.000449397629,if(t<=325,0.000884025501,if(t<=326,0.000654416186,if(t<=327,0.00064374717,if(t<=328,0.000789273122,if(t<=329,0.000803543557,if(t<=330,0.000638530434,if(t<=331,0.00100160898,if(t<=332,0.000993807258,if(t<=333,0.00124114925,if(t<=334,0.00123426412,if(t<=335,0.00141321826,if(t<=336,0.00118332628,if(t<=337,0.00109470055,if(t<=338,0.00125019427,if(t<=339,0.00135455371,if(t<=340,0.0019431852,if(t<=341,0.00205543168,if(t<=342,0.00197207562,if(t<=343,0.0022614449,if(t<=344,0.00211490243,if(t<=345,0.00210695833,if(t<=346,0.00249495193,if(t<=347,0.00234941068,if(t<=348,0.00226462926,if(t<=349,0.00192793935,if(t<=350,0.002307822,if(t<=351,0.00177314607,if(t<=352,0.00204756246,if(t<=353,0.00223537455,if(t<=354,0.00265125171,if(t<=355,0.00215845046,if(t<=356,0.00219770402,if(t<=357,0.00178428238,if(t<=358,0.00184590186,if(t<=359,0.0018605743,if(t<=360,0.00184659497,if(t<=361,0.00229017668,if(t<=362,0.00253196493,if(t<=363,0.00239098899,if(t<=364,0.00211185421,if(t<=365,0.00219407719,if(t<=366,0.00212246707,if(t<=367,0.00269861999,if(t<=368,0.00266277044,if(t<=369,0.0022864101,if(t<=370,0.00238106143,if(t<=371,0.00288706782,if(t<=372,0.00241887213,if(t<=373,0.00264944029,if(t<=374,0.00283053906,if(t<=375,0.00324595184,if(t<=376,0.00288717874,if(t<=377,0.00276439946,if(t<=378,0.00244384282,if(t<=379,0.00233597338,if(t<=380,0.00279352064,if(t<=381,0.00286037951,if(t<=382,0.00328170603,if(t<=383,0.002822949,if(t<=384,0.00278954494,if(t<=385,0.00312619711,if(t<=386,0.00324124337,if(t<=387,0.00365400495,if(t<=388,0.00402022148,if(t<=389,0.00451327855,if(t<=390,0.00463343495,if(t<=391,0.00361972256,if(t<=392,0.00421404306,if(t<=393,0.00450737728,if(t<=394,0.00385689985,if(t<=395,0.00706347035,if(t<=396,0.00548992622,if(t<=397,0.00561269851,if(t<=398,0.00565157042,if(t<=399,0.00465943143,if(t<=400,0.00360607661,if(t<=401,0.00424833829,if(t<=402,0.00506165543,if(t<=403,0.00554584679,if(t<=404,0.00567074572,if(t<=405,0.00521791533,if(t<=406,0.00511027778,if(t<=407,0.00463445002,if(t<=408,0.0048334687,if(t<=409,0.00495195688,if(t<=410,0.00549367799,if(t<=411,0.00563900702,if(t<=412,0.00467717288,if(t<=413,0.00464379518,if(t<=414,0.00459904476,if(t<=415,0.00454237307,if(t<=416,0.00500574242,if(t<=417,0.00531713904,if(t<=418,0.00561133477,if(t<=419,0.00533865191,if(t<=420,0.00495078846,if(t<=421,0.00463678844,if(t<=422,0.00473844747,if(t<=423,0.0054393895,if(t<=424,0.00545525246,if(t<=425,0.00541193326,if(t<=426,0.00509452208,if(t<=427,0.00660187229,if(t<=428,0.00417453135,if(t<=429,0.00467057068,if(t<=430,0.00516133914,if(t<=431,0.00579060434,if(t<=432,0.00527368183,if(t<=433,0.0046510559,if(t<=434,0.00430932033,if(t<=435,0.00469632041,if(t<=436,0.00451319727,if(t<=437,0.00525834823,if(t<=438,0.00514407899,if(t<=439,0.00424489032,if(t<=440,0.00338261955,if(t<=441,0.0038480963,if(t<=442,0.00292950561,if(t<=443,0.00356221514,if(t<=444,0.00426978001,if(t<=445,0.00498272013,if(t<=446,0.00406037155,if(t<=447,0.00385850101,if(t<=448,0.00311324383,if(t<=449,0.00287080426,if(t<=450,0.00249969302,if(t<=451,0.00303688666,if(t<=452,0.00373753143,if(t<=453,0.00334610566,if(t<=454,0.00271933283,if(t<=455,0.00249564984,if(t<=456,0.00211065932,if(t<=457,0.0026296495,if(t<=458,0.002927413,if(t<=459,0.00348787669,if(t<=460,0.00360563614,if(t<=461,0.00305593177,if(t<=462,0.0029747901,if(t<=463,0.00313546965,if(t<=464,0.00427331421,if(t<=465,0.00367859101,if(t<=466,0.0038757078,if(t<=467,0.00345077,if(t<=468,0.00294496232,if(t<=469,0.00280944761,if(t<=470,0.00320988109,if(t<=471,0.00327554366,if(t<=472,0.00291552997,if(t<=473,0.00379463693,if(t<=474,0.00296006542,if(t<=475,0.00296144959,if(t<=476,0.00226444315,if(t<=477,0.00222587449,if(t<=478,0.00208900522,if(t<=479,0.00235789914,if(t<=480,0.0023527227,if(t<=481,0.00225757636,if(t<=482,0.00156006694,if(t<=483,0.00200007592,if(t<=484,0.00177305229,if(t<=485,0.00132721137,if(t<=486,0.0016157386,if(t<=487,0.00160173321,if(t<=488,0.00161771581,if(t<=489,0.00120030271,if(t<=490,0.00106073605,if(t<=491,0.00109226802,if(t<=492,0.0009426437350000001,if(t<=493,0.00129775163,if(t<=494,0.00148914411,if(t<=495,0.00126664783,if(t<=496,0.00111729785,if(t<=497,0.000928262283,if(t<=498,0.00100128739,if(t<=499,0.000862123754,if(t<=500,0.00143578505,if(t<=501,0.00159369446,if(t<=502,0.001236268,if(t<=503,0.0010974177,if(t<=504,0.00116777929,if(t<=505,0.00129901145,if(t<=506,0.00143993669,if(t<=507,0.00137057727,if(t<=508,0.00129378217,if(t<=509,0.00105560763,if(t<=510,0.00076959134,if(t<=511,0.00100224246,if(t<=512,0.00126489835,if(t<=513,0.000839568459,if(t<=514,0.00104061086,if(t<=515,0.0012489978,if(t<=516,0.000909710251,if(t<=517,0.00106807397,if(t<=518,0.00092042926,if(t<=519,0.000568671374,if(t<=520,0.00107534612,if(t<=521,0.000977098888,if(t<=522,0.0011913604,if(t<=523,0.0020660573,if(t<=524,0.000776079056,if(t<=525,0.0009384054229999999,if(t<=526,0.0007691787249999999,if(t<=527,0.0008221690370000001,if(t<=528,0.000977691101,if(t<=529,0.00120703073,if(t<=530,0.00115212883,if(t<=531,0.0009606733930000001,if(t<=532,0.00093316483,if(t<=533,0.0007720669550000001,if(t<=534,0.00120225262,if(t<=535,0.0011870245,if(t<=536,0.00108866938,if(t<=537,0.0009816442539999999,if(t<=538,0.0013641676,if(t<=539,0.000946980045,if(t<=540,0.0009865161470000001,if(t<=541,0.00106015651,if(t<=542,0.0011457813,if(t<=543,0.00126624345,if(t<=544,0.00136449029,if(t<=545,0.00102888928,if(t<=546,0.000864759508,if(t<=547,0.0011350614,if(t<=548,0.00094079968,if(t<=549,0.00106408062,if(t<=550,0.00155375609,if(t<=551,0.000838952779,if(t<=552,0.00106263742,if(t<=553,0.00118428894,if(t<=554,0.000855891218,if(t<=555,0.000815682206,if(t<=556,0.00102089848,if(t<=557,0.00110255282,if(t<=558,0.00113035448,if(t<=559,0.00102012975,if(t<=560,0.00110705653,if(t<=561,0.000705581016,if(t<=562,0.000993763855,if(t<=563,0.00118845612,if(t<=564,0.00117255526,if(t<=565,0.000896920008,if(t<=566,0.00116252977,if(t<=567,0.0009774145669999999,if(t<=568,0.000774332103,if(t<=569,0.00102867561,if(t<=570,0.000824192259,if(t<=571,0.000945787156,if(t<=572,0.000867970103,if(t<=573,0.000975609124,if(t<=574,0.0009400845809999999,if(t<=575,0.000798736412,if(t<=576,0.000715158278,if(t<=577,0.000796893693,if(t<=578,0.000646695582,if(t<=579,0.000983652225,if(t<=580,0.000844168204,if(t<=581,0.000706883968,if(t<=582,0.00075490277,if(t<=583,0.000968707132,if(t<=584,0.000823652744,if(t<=585,0.000913533955,if(t<=586,0.000758321971,if(t<=587,0.000722756758,if(t<=588,0.000708912186,if(t<=589,0.000814718917,if(t<=590,0.000692181581,if(t<=591,0.000874866316,if(t<=592,0.000687077945,if(t<=593,0.00101249691,if(t<=594,0.000789045455,if(t<=595,0.000773614795,if(t<=596,0.000526705332,if(t<=597,0.000706965066,if(t<=598,0.000903633251,if(t<=599,0.000590024411,if(t<=600,0.000936203932,if(t<=601,0.000607883075,if(t<=602,0.000564723531,if(t<=603,0.000724888451,if(t<=604,0.00068726425,if(t<=605,0.000555183276,if(t<=606,0.000856091978,if(t<=607,0.000576251369,if(t<=608,0.0009014603059999999,if(t<=609,0.000536780404,if(t<=610,0.0006876480990000001,if(t<=611,0.000371006631,if(t<=612,0.000692669203,if(t<=613,0.00083516197,if(t<=614,0.00038463401,if(t<=615,0.000800101713,if(t<=616,0.000375803641,if(t<=617,0.0006264554589999999,if(t<=618,0.000526031526,if(t<=619,0.000499368607,if(t<=620,0.000428305584,if(t<=621,0.000909464485,if(t<=622,0.000351236661,if(t<=623,0.000566571376,if(t<=624,0.000429427975,if(t<=625,0.000499533864,if(t<=626,0.000526757148,if(t<=627,0.000225809721,if(t<=628,0.0005403013610000001,if(t<=629,0.000240458659,if(t<=630,0.000516079477,if(t<=631,0.000660882077,if(t<=632,0.000566899036,if(t<=633,0.00115467547,if(t<=634,0.000633427116,if(t<=635,0.000518385602,if(t<=636,0.000749428245,if(t<=637,0.000913122119,if(t<=638,0.000786391348,if(t<=639,0.0012730781,if(t<=640,0.00129256234,if(t<=641,0.00115637457,if(t<=642,0.00102572807,if(t<=643,0.00105539285,if(t<=644,0.00119078863,if(t<=645,0.000732476407,if(t<=646,0.0011368034,if(t<=647,0.00143053847,if(t<=648,0.000947157648,if(t<=649,0.00133587678,0)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
end functions
begin reaction rules
# timer
0->counter() 1
0->V() v_rate()
end reaction rules
end model

#generate_network({overwrite=>1})
#simulate({suffix=>"ODE",method=>"ode",t_start=>0,t_end=>1000,n_steps=>1000,print_functions=>1}) # works for cases 1 and 2
#simulate({suffix=>"SSA",method=>"ssa",t_start=>0,t_end=>1000,n_steps=>1000,print_functions=>1}) # works for cases 1 and 2

simulate({suffix=>"NF",method=>"nf",t_start=>0,t_end=>1000,n_steps=>1000,seed=>1,print_functions=>1}) # works for case 1, fails for case 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# nfsim generated species list for system: 'BillsTest'
# warning! this feature is not yet fully tested!
V() 2
counter() 973
98 changes: 98 additions & 0 deletions Issues/nestedIF/BillsTest/2024_05_09__17_36_20/BillsTest_NF.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by BioNetGen 2.9.1 -->
<sbml xmlns="http://www.sbml.org/sbml/level3" level="3" version="1">
<model id="BillsTest">
<ListOfParameters>
<Parameter id="_rateLaw1" type="Constant" value="1" expr="1"/>
</ListOfParameters>
<ListOfMoleculeTypes>
<MoleculeType id="V"/>
<MoleculeType id="counter"/>
</ListOfMoleculeTypes>
<ListOfCompartments>
</ListOfCompartments>
<ListOfSpecies>
<Species id="S1" concentration="0" name="V()">
<ListOfMolecules>
<Molecule id="S1_M1" name="V"/>
</ListOfMolecules>
</Species>
<Species id="S2" concentration="0" name="counter()">
<ListOfMolecules>
<Molecule id="S2_M1" name="counter"/>
</ListOfMolecules>
</Species>
</ListOfSpecies>
<ListOfReactionRules>
<ReactionRule id="RR1" name="_R1" symmetry_factor="1">
<ListOfReactantPatterns>
</ListOfReactantPatterns>
<ListOfProductPatterns>
<ProductPattern id="RR1_PP1">
<ListOfMolecules>
<Molecule id="RR1_PP1_M1" name="counter"/>
</ListOfMolecules>
</ProductPattern>
</ListOfProductPatterns>
<RateLaw id="RR1_RateLaw" type="Ele" totalrate="0">
<ListOfRateConstants>
<RateConstant value="_rateLaw1"/>
</ListOfRateConstants>
</RateLaw>
<Map>
</Map>
<ListOfOperations>
<Add id="RR1_PP1_M1"/>
</ListOfOperations>
</ReactionRule>
<ReactionRule id="RR2" name="_R2" symmetry_factor="1">
<ListOfReactantPatterns>
</ListOfReactantPatterns>
<ListOfProductPatterns>
<ProductPattern id="RR2_PP1">
<ListOfMolecules>
<Molecule id="RR2_PP1_M1" name="V"/>
</ListOfMolecules>
</ProductPattern>
</ListOfProductPatterns>
<RateLaw id="RR2_RateLaw" type="Function" name="v_rate" totalrate="0">
<ListOfArguments>
</ListOfArguments>
</RateLaw>
<Map>
</Map>
<ListOfOperations>
<Add id="RR2_PP1_M1"/>
</ListOfOperations>
</ReactionRule>
</ListOfReactionRules>
<ListOfObservables>
<Observable id="O1" name="t" type="Molecules">
<ListOfPatterns>
<Pattern id="O1_P1">
<ListOfMolecules>
<Molecule id="O1_P1_M1" name="counter"/>
</ListOfMolecules>
</Pattern>
</ListOfPatterns>
</Observable>
<Observable id="O2" name="V" type="Molecules">
<ListOfPatterns>
<Pattern id="O2_P1">
<ListOfMolecules>
<Molecule id="O2_P1_M1" name="V"/>
</ListOfMolecules>
</Pattern>
</ListOfPatterns>
</Observable>
</ListOfObservables>
<ListOfFunctions>
<Function id="v_rate">
<ListOfReferences>
<Reference name="t" type="Observable"/>
</ListOfReferences>
<Expression> 1e4*if((t&lt;297),1e-6,if((t&lt;=298),1.12314383e-05,if((t&lt;=299),9.94451901e-06,if((t&lt;=300),4.74735912e-05,if((t&lt;=301),2.11759573e-05,0))))) </Expression>
</Function>
</ListOfFunctions>
</model>
</sbml>
Loading

0 comments on commit dde4439

Please sign in to comment.