Repository navigation
Release notes for sbmlsim 0.41.0
Four places where the work was there and the result was thrown away: a report drew its figures one at a time, a dataset built masks over frames of a few rows to answer a question its unit column already answered, a plan folded every one of its formulas because one of them read the clock, and a profile halved its way down to the scale of its parameter and discarded a re-optimization at every halving.
The figures of the fit mappings are drawn in a pool
The figure of every fit mapping is the long part of the report of a large fit: on the adopted PK fit of the HCTZ model of pkdb_models, 160 mappings in SVG, plot_mapping was 63.1 s, 394 ms a figure, of which 357 ms is matplotlib writing the SVG. The figures do not depend on each other.
draw_mapping is the body of the loop and what a worker calls; plot_mapping either loops in this process or draws the mappings in chunks on a pool. A worker receives the report through the initializer of the pool and initializes its problem once before it draws, a pickled problem being its definition and not its resolved data. _figure_workers is one worker per 16 figures, so a report of a few mappings stays in the calling process, where the 3.5 s of the initialization would not be earned back, and a report drawn inside a worker of another pool does too. The parent advances the same progress bar as the chunks come back.
A pool of 20 on 12 physical cores: 57.8 s to 28.4 s. (#654)
A column of one unit is answered from its unit column
The setup a command of a model pays before it does anything is DataSet.from_df, and inside it _unify_units, which spent its time in pandas and not in pint: on the HCTZ model of pkdb_models 1.35 s over 2612 calls on 1230 frames, while the _parse_unit of pint inside it was 0.04 s. The frames are a few rows each, so what those calls paid was the per operation overhead of the masks of the values, of the errors and of the rows which carry a unit, and of the | which combines them.
The common case needs none of them: a column whose rows carry one unit has that unit as its target and no row of it is converted, which the full path reaches as well, with scales empty and the frame untouched, after it has built every mask. _column_units reads the distinct units of the column off the numpy array behind it and _unify_units answers from them: no unit is no unit of the column whichever mask selects the rows, and one unit without a numeric factor is the unit of the column. A unit with a factor multiplies the values and takes the full path, and the unit is parsed here as well, so an undefined one still raises where the data is read.
_unify_units 1.346 s -> 0.103 s (2612 calls, 1230 frames)
collections 4.68 s -> 4.02 s
problem 3.36 s -> 2.73 s
(#653)
A form carries the time and a change over the target of a parameter
Two conservative refusals of the same kind as #630: neither was a correctness defect, both cost fits which ran in python for no reason.
A term of the time is the constant of a form. form_of built the terms of a form over the entities of the model and left time out of them, so a change whose formula reads the time was no form at all and the whole plan folded, the forms of its other changes included. The time at a change is known where the request is built, so 0.5 * Aurine + time at the change at 10 is the form 10 + 0.5 * Aurine. _form_terms reads the time as a term and hands its factor back on its own, which form_of folds into the constant at the time it is given, so the time is no part of the key of its cache and the doses of a protocol, one formula at many times, stay the one entry they were. The time is a constant of a change for the gaps as well, so a change whose formula reads the time and constants is no gap even in a plan which folds.
A change formula over the target of a parameter is a form. The gap parameter_value was reported for a change whatever its formula. Where the plan carries its changes as forms, the engine evaluates them from its own state at the change and sets the parameters of the request on the model before the simulation, so a change formula which is linear in the entity a parameter writes follows the optimizer and is no frozen number. The gap stays for the pre-initialization of a steady state, which is no change and is folded, and for a plan which folds; Plan.places carries a PlaceKind so the two walkers of a plan tell them apart. (#650)
A profile starts at the scale of its parameter
The profile likelihood spent most of its re-optimizations on steps it threw away. A scan started at initial_step, one step for every parameter whatever its scale, and a step which raised the cost by more than the walk allows was halved and walked again, so a first step far above the scale of the profile was halved up to four times per point and each halving discarded the re-optimization which measured it.
The step is corrected by the curvature. The rise of a step which is walked again is the curvature of the profile there, which is locally quadratic in the step, so the step whose rise is half of what a step may raise the cost by is step * sqrt(max_rise / (2 rise)) and one correction reaches the scale of the profile. rise > max_rise keeps the factor below 1 / sqrt(2), so the step always shrinks, and a rise which is not finite takes it to min_step at once. step_factor keeps its other half, the enlargement of a step which rises slowly.
The first step is the scale of the parameter. The cost around the optimum rises by d² / (2 s²) over a distance d with s the standard error of the parameter in the space the scans run in, so the step which raises it by what a step may raise it by is sqrt(2 max_rise) s. first_steps computes it for every parameter from the Fisher information of the optimum, one jacobian before the scans, clamped to [min_step, max_step]; a direction the data does not constrain has no standard error and keeps initial_step, and an information which cannot be computed at all leaves every parameter with it, reported and not raised, since a first step is where a scan starts and not a result.
Both run in the engine as well (sbmlsim-core 0.26.0): profile_likelihood computes the steps once and the request carries them as the steps of its identifiability, so python and the engine walk the same points. Bindings older than 0.26.0 deny that field and keep the new gap bindings, which walks the analysis in python.
On the PK subset of the HCTZ example the analysis takes 71 re-optimizations instead of 83 and 1.7 s instead of 2.3 s.
The profiles have other points, and the intervals move in their fourth digit. A profile is walked at the scale of its parameter now, so its points are not the points of a stored analysis: an identifiability.json written before this release does not read back as the analysis of the same fit after it. The confidence interval is the interpolated crossing of the threshold between two points, and the two which bracket it are no longer the same two, so a bound moves a little as well. On the PK subset of the HCTZ example, the same fit walked by both:
| parameter | bound | before | after | relative |
|---|---|---|---|---|
GU__HCTZABS_k |
lower | 0.00395682019293 | 0.0039568293539 | 2.3e-06 |
GU__HCTZABS_k |
upper | 0.0384057181124 | 0.0383929015412 | 3.3e-04 |
KI__HCTZEX_k |
lower | 0.00413174051464 | 0.00413249227623 | 1.8e-04 |
KI__HCTZEX_k |
upper | 0.0069428356851 | 0.00694287951503 | 6.3e-06 |
Ka_dis_hctz |
lower | 0.237422870493 | 0.237369271513 | 2.3e-04 |
Ka_dis_hctz |
upper | 2.30460168322 | 2.30387586124 | 3.2e-04 |
Every parameter keeps its classification, and the classification is the robust part of a profile while the exact bound never was. These six numbers are the best case and no bound on the change: the three parameters have curvature at their crossings and a Fisher information of full rank. The shift of a bound is the shift of the bracketing points divided by the slope of the profile where it crosses, so where that slope is shallow the bound moves by more - and a bound which a shallow crossing produces is one the data pins weakly whichever walk finds it. A profile which is flat to the bound has no crossing at all, so its interval is open and there is nothing to move; it is the shallow crossing in between, not the flat profile, which moves most.
A model whose factory writes the interval of a profile into its SBML as a distrib:uncertainty therefore gets a diff in that tracked file at the next refit. Read it as the interpolation moving, not the fit: compare the classification and the width, not the digits. (#647)
Dependencies
sbmlsim-core>=0.26.0, which reads the first steps of the profiles of a request.