Builds an interpolated scenario from a model via the mapping pipeline:
collects sets from the model objects, builds the membership / calendar /
lifespan / value / constraint / cost mappings, extracts and interpolates the
numeric parameters over the milestone years, and (optionally) folds, prunes
and validates the result. The returned scenario is ready for solve_model() /
solve_scenario().
Usage
interpolate_model(
mod,
name = NULL,
...,
desc = NULL,
ondisk = FALSE,
overwrite = FALSE,
fold = FALSE,
sparse = TRUE,
prune = TRUE,
validate = TRUE,
code = NULL,
kvl = FALSE,
boundary_prices = NULL,
.prefilter = FALSE,
verbose = isVerbose()
)
# S4 method for class 'model'
interpolate(object, ...)Arguments
- mod
a model object, or a scenario (its
@modelis re-interpolated).- name
character scenario name. If
NULL, a defaultscen_<model>is used (with a warning).- ...
additional energyRt objects folded into the model BEFORE the pipeline runs:
settings,config,calendar,horizon, a wholerepository, or individual model "bricks" (technology,commodity,storage, ...). This is how a scenario overrides or extends the model (e.g. pass a sampledcalendarto interpolate on a reduced time resolution).- desc
character scenario description.
- ondisk
logical; store each parameter's data in the on-disk parameter store rather than the in-memory
@dataslot.FALSE(default) keeps data in memory, which the solver writers read directly;TRUEsuits very large models (data is materialised back to memory at solve time).- overwrite
logical; overwrite an existing on-disk scenario of the same name.
- fold
logical or character; whole-column "fold" of trimmable dimensions to NA wildcards to shrink the data.
TRUEfoldsregion+timeslice+year;FALSE(default) folds nothing; a character vector selects dims amongregion,timeslice,year,comm,tech,stg,trade. The wildcards are substituted by an artificial set member in the written model files only; the scenario object keeps them andgetData()expands them.A dimension folds only where the value is uniform across its WHOLE set, so folding never changes the solution — it changes how the same numbers are stored.
yearmatters most in weather-heavy models: one weather series repeated across milestone years is usually the largest parameter, andregion/timeslicealone do not touch it. Measured on a 4-regiond365_h24model over 7 milestones, addingyeartookpWeatherfrom 245,259 to 35,037 rows (-85.7%) with a bit-identical objective on GLPK and Pyomo/HiGHS. A model whose weather genuinely differs by year simply does not fold.- sparse
logical; the storage knob, and the user-facing switch between
drop_default_values()andexpand_default_values().TRUEdropsvalue == defValrows;FALSEmaterialises the default over each parameter's full domain (the form GAMS needs) and then trims rows no map indexes. Folding applies to either.- prune
logical; apply the per-parameter
misc$prune$valuefilter viadrop_default_values()- rows whose interpolated value equals that parameter's flagged value are dropped (lossless: an absent tuple reads as the default, which equals the dropped value). One parameter is flagged today (pWeather). Superseded bysparse'svalue =form; retained for compatibility.- validate
logical; run
validate_scenario_parameters()after interpolation (schema, duplicate keys, map/parameter coverage, missing governing constraints, calendar chronology).- code
optional named list overriding solver source-code blocks (
GLPK,GAMS,JuMP,PYOMOConcrete, ...), each either a script-file path or a character vector of lines. Lets a model-script version be supplied at interpolation time without rebuildingsysdata(handy to A/B templates).- kvl
logical or
NULL; build the Kirchhoff voltage-law cycle constraints for meshed trade networks.NULL(default) engages them when the network has cycles and reactances to use.- boundary_prices
optional
data.framepricing import/export stubs for trade routes dropped by a SPATIAL SAMPLE (ageoscales::filter_geoscale()subset passed via...); seesubset_model_regions()for the columns. Ignored (with a warning) when no sampled geoscale is supplied.- .prefilter
EXPERIMENTAL, default
FALSE. Restrict each model object's data to the timeslices and regions the SCENARIO declares before interpolating it, rather than interpolating everything and discarding the excess afterwards.On the sampled-calendar recipe – a full-year model with a subset calendar handed to this function – the default order expands all 8,760 timeslices in
ob2miand then keeps 96. The parameter filters that follow are cheap (0.05s on a 5-node model); the cost is the interpolation they cannot undo.Off by default because it is not obviously safe: anything deriving a relation from the full declared grid rather than from the calendar would see a narrower input. Compare objectives before relying on it.
- verbose
logical; print per-step progress. This also governs the variant-expansion report – how many process objects were expanded and how many constraints were generated for them. The generated constraints themselves are retrievable with
getObject(scen, class = "constraint"); each carries a readabledescand, inmisc$.variant_source, the object it was derived from.- object
as
mod, for the method dispatched on a scenario.
Value
an interpolated scenario object.
See also
solve_model(), solve_scenario(), the interpolate S4 method.
Other interpolation:
subset_model_regions(),
with_solver_log()
