
Round an interpolated scenario's numbers, and strip the ones too small to mean
Source:R/round.R
round-scenario.RdCleans the value columns of a scenario's interpolated parameters: values
whose magnitude is below tol become exactly 0, and digits, when given,
rounds the rest.
Arguments
- x
a scenario (interpolated).
- digits
integer, decimal places for the value columns;
NULL(default) leaves precision alone.- tol
numeric, values with
0 < |value| < tolbecome0. Defaults to theenergyRt.tiny_value_toloption (1e-12);NULLor0strips nothing.- verbose
reporting level; see
isVerbose().- ...
unused, for the generic.
Details
A tiny non-zero value is harder for a solver than the zero it stands for: an
exact zero bound lets presolve fix a variable, 1e-20 does not. The case
this exists for is a constraint built by an older energyRt with
newConstraint(replace_zerros = 1e-20), whose zero right-hand sides – and
whose written parameter default – carry that value. interpolate_model()
reports such values through validate_scenario_parameters()'s tiny_value
check; this acts on them, on a scenario already built, with no rebuild.
Rounding is not free: it changes the model. Both arguments are therefore
explicit, and what changed is reported and recorded in @misc$rounded.
See also
Other interpolation:
interpolate_model(),
recast_model_calendar(),
subset_model_regions()
Examples
if (FALSE) { # \dontrun{
scen <- interpolate_model(mod, name = "BASE")
scen <- round(scen) # strip values below 1e-12
scen <- round(scen, digits = 6) # ... and round the rest
} # }