sdbuildR 2.0.0
Breaking changes
-
stockflow()is now the constructor for stock-and-flow models. Code that
usedxmile()or the development-onlysdbuildR()constructor should call
stockflow()instead. -
update()now replaces the oldbuild()workflow for general model edits.
For clearer model-building code, usestock(),flow(),constant(),
aux()/auxiliary(),lookup(), andcustom_func(). -
stockflowis now the primary model class. Code that checked for
sdbuildR_xmileorsdbuildRshould check forstockflowinstead. -
simulate()now returnssimulate_stockflowobjects,ensemble()returns
ensemble_stockflowobjects,verify()returnsverify_stockflowobjects,
summary()returnssummary_stockflowobjects, andcompare_models()
returnscompare_stockflowobjects. -
sim_settings()now replacessim_specs(), andmeta()now replaces
header(). -
summary()now runs model diagnostics. Code that useddebugger()should
callsummary()instead. -
dependencies()now replacesfind_dependencies(). -
export_model(format = "sdbuildR")now replacesget_build_code(). -
sim_methods()now replacessolvers(). -
custom_func()now replacesmacro()for user-defined model functions. -
import_insightmaker()now replacesinsightmaker_to_sfm(), and
url_to_insightmaker()now replacesurl_to_IM(). -
ensemble()now usesconditionsinstead ofrange. To retain individual
simulations, usesave_sims = TRUEinstead ofreturn_sims = TRUE. -
plot()methods now useshow_constantsinstead ofadd_constants. For
ensemble plots, usewhich,sim,condition, andlabel_subplotsinstead
oftype,i,j, andj_labels. -
use_julia(nthreads = )now controls Julia threading. Code that used
use_threads()should set the thread count withuse_julia()instead. -
Units are no longer supported. This means that unit-specific helpers from 1.x,
includingu(),convert_u(),drop_u(),
model_units(),unit_prefixes(),get_units(),get_regex_units(), and
get_regex_time_units(), are no longer available.
New features
-
stockflow()creates an empty model or loads a built-in template using a
case-insensitivetemplatename. -
stock(),flow(),constant(),aux()/auxiliary(),lookup(), and
custom_func()provide typed model-building helpers aroundupdate(). -
update()now supports bare variable names and R expressions inname,
type,eqn,to,from, andsource. Strings and programmatic injection
with!!remain supported. -
change_name(),change_type(), anddiscard()provide focused helpers for
renaming, changing, and removing model variables. -
sim_settings()gains flexible output controls withsave_at,save_n,
vars, andsave_sims. -
simulate()accepts temporary simulation-setting overrides through...,
using the same arguments assim_settings(). -
ensemble()can run ensembles in R and Julia, vary stocks and constants with
conditions, and retain individual simulations withsave_sims = TRUE. -
unit_test(),unit_tests(), andverify()add model-level unit tests for
expected simulation behavior, including tests under alternativeconditions. -
compare_models()compares model structure, equations, simulation settings,
and nonlinearity scores across twostockflowmodels. -
import_desolve()converts deSolve-style ODE models intostockflowmodels. -
import_insightmaker()imports Insight Maker models from public URLs,
.InsightMakerfiles, and ModelJSON.jsonfiles. -
export_model()exports models as sdbuildR reconstruction code, standalone
deSolve scripts, or Psychomodels JSON records.
Improvements and fixes
-
as.data.frame()methods now support thestockflow,simulate_stockflow,
ensemble_stockflow, andverify_stockflowclasses. -
dependencies()can now filter dependencies by variable name and type. -
export_plot()now supports the current plot classes and additional graph
export options. -
simulate()and Julia code generation now use a faster AST-based R-to-Julia
equation translator. Namespaced calls such asbase::sum()translate
correctly, and unsupported constructs fall back to the previous translator. -
simulate(), compilation, andsummary()now use a content-hashed assembly
cache. Repeated calls on unchanged models can skip reassembly, and editing one
equation only retranslates that equation. -
simulate()now keeps Julia stock derivative positions aligned with the state
vector when stocks are added, removed, renamed, or created by changing a
variable's type. -
summary()and code generation now use an internal structural validator to
catch inconsistent model layouts before simulation. -
simulate()now removes temporary CSV files created by single Julia
simulations. -
textutilsis now a required dependency.