Skip to contents

The solver's input: every value parameter, the slot column it is read from, its default and dimensions -- and how defaults, interpolation and derived values work

PDF, A4, 2 pages · energyRt 0.91.5.9015 (dev) · 2026-11-29
From a slot to a parameter
EWIN <- newTechnology("EWIN",
  output = list(comm = "ELC"), cap2act = 8760,
  af = data.frame(year = c(2030, 2050),
                  af.up = c(0.30, 0.40)),
  invcost = list(invcost = 1300), olife = 25)
mod <- add(mod0, EWIN)  # milestones 2030/35/45
scen <- interpolate_model(mod, name = "P",
                          ondisk = FALSE)
getData(scen, name = "pTechAf", tech = "EWIN",
        timeslice = "WIN", merge = TRUE) |>
  select(name, year, timeslice, type, value)
# A tibble: 3 × 5
  name     year timeslice type  value
  <chr>   <int> <chr>     <chr> <dbl>
1 pTechAf  2030 WIN       up    0.3  
2 pTechAf  2035 WIN       up    0.325
3 pTechAf  2045 WIN       up    0.375
af.up is given for 2030 and 2050; 2035 and 2045 are interpolated. Both sides of a bound live in one table, told apart by type.

A parameter is the solver-facing form of slot data. interpolate_model() reads every object's slots, fills the milestone years and the sets, and keeps one table per parameter in scen@modInp; the solver files are written from these tables, never from the slots.

Naming
pTech… technology; pStorage…, pTrade…, pSup…, pDemand, pImportRow…, pExportRow…, pTax…, pSub… likewise
…Lo, …Up the sides of a bound column x.lo, x.up; x.fx fills both
X2Y a ratio: pTechCinp2use turns commodity input into use
…AInp, …AOut auxiliary input, output: pTechAct2AInp per unit of activity
Inp, Stg, Out a storage's charger, reservoir, discharger
Ir, Row trade between regions; the rest of the world
Eac, Wacc annualised investment; cost of capital
m… a map: membership, no value (below)

The tables use the solver's names. In the scenario a bound is one parameter, pTechAf, with a type column; the solver files split it into pTechAfLo and pTechAfUp. Where the two sides meet, one equality row is written (fx_equ = TRUE, the default).

from -- the slot and column the values are written in (af$af.up); blank: computed at interpolation (see Derived). def -- the default; ∞ is no bound. dims -- the index after the process:

r region y year t timeslice c commodity
g group cc two commodities rr source, destination ytt year, parent, child
Defaults and interpolation

Every parameter has a default (defVal) and a rule over the years (interpolation), declared once in the catalogue (data-raw/parameters.yml). A rule joins three directions:

back before the first given year: the first value
inter between given years: linear
forth after the last given year: the last value
"" none: the given years stand, the rest take the default
  • Most parameters: back.inter.forth. Capacity, new-capacity and retirement bounds, inp2out, inp2stg and duration: inter.forth, so a bound first given for 2040 does not bind 2030. pTechStock: inter.
  • A cell no row reaches takes defVal. With sparse = TRUE (the default) rows equal to it are dropped: an absent row reads as the default.
  • Overrides, last one wins: the catalogue, then config@defVal / config@interpolation for the model (keyed by parameter: pTechAf.up), then an object's own @defVal / @interpolation (keyed by column: af.up).
get_default_value(pname = "pTechAf",
                  global = TRUE)
$pTechAf
[1] 0 1
…
A bound has two defaults: lo, up.
Technology: conversion and auxiliary flows
name from def dims
pTechCinp2ginp ceff$cinp2ginp 1 cryt
pTechGinp2use geff$ginp2use 1 gryt
pTechCinp2use ceff$cinp2use 1 cryt
pTechUse2cact ceff$use2cact 1 cryt
pTechCact2cout ceff$cact2cout 1 cryt
pTechEmisComm input$combustion 1 c
pTechAct2AInp aeff$act2ainp 0 cryt
pTechCap2AInp aeff$cap2ainp 0 cryt
pTechNCap2AInp aeff$ncap2ainp 0 cryt
pTechPho2AInp aeff$pho2ainp 0 cryt
pTechPho2AOut aeff$pho2aout 0 cryt
pTechRet2AInp aeff$ret2ainp 0 cryt
pTechRet2AOut aeff$ret2aout 0 cryt
pTechCinp2AInp aeff$cinp2ainp 0 ccryt
pTechCout2AInp aeff$cout2ainp 0 ccryt
pTechAct2AOut aeff$act2aout 0 cryt
pTechCap2AOut aeff$cap2aout 0 cryt
pTechNCap2AOut aeff$ncap2aout 0 cryt
pTechCinp2AOut aeff$cinp2aout 0 ccryt
pTechCout2AOut aeff$cout2aout 0 ccryt
pTechShareLo ceff$grp.share.lo 0 cryt
pTechShareUp ceff$grp.share.up 1 cryt
Technology: capacity, availability, costs
name from def dims
pTechOlife vintage$olife 1 r
pTechFixom fixom$fixom 0 ry
pTechVarom varom$varom 0 ryt
pTechInvcost invcost$invcost 0 ry
pTechEac invcost$eac 0 ry
pTechRetCost invcost$retcost 0 ry
pTechAfLo af$af.lo 0 ryt
pTechAfUp af$af.up 1 ryt
pTechRampUp af$rampup ∞ ryt
pTechRampDown af$rampdown ∞ ryt
pTechAfsLo afs$afs.lo 0 ryt
pTechAfsUp afs$afs.up ∞ ryt
pTechAfcLo ceff$afc.lo 0 cryt
pTechAfcUp ceff$afc.up ∞ cryt
pTechStock capacity$stock 0 ry
pTechCapUp capacity$cap.up ∞ ry
pTechCapLo capacity$cap.lo 0 ry
pTechNewCapUp capacity$ncap.up ∞ ry
pTechNewCapLo capacity$ncap.lo 0 ry
pTechRetUp capacity$ret.up ∞ ry
pTechRetLo capacity$ret.lo 0 ry
pTechCap2act cap2act 1
pTechCvarom varom$cvarom 0 cryt
pTechAvarom varom$avarom 0 cryt
pTechWacc invcost$wacc 0 ry
pTechPayback invcost$payback 0 ry

pTechEac is computed when invcost$eac is not given: invcost annuitised at wacc (else the model's pWacc) over payback (else olife).

Weather factors
name from def dims
pWeather weather$wval 0 ryt
pSupWeatherUp weather$wava.up 1
pSupWeatherLo weather$wava.lo 1
pTechWeatherAfLo weather$waf.lo 1
pTechWeatherAfUp weather$waf.up 1
pTechWeatherAfsLo weather$wafs.lo 1
pTechWeatherAfsUp weather$wafs.up 1
pTechWeatherAfcLo weather$wafc.lo 1 c
pTechWeatherAfcUp weather$wafc.up 1 c
pStorageWeatherAfLo weather$stg.waf.lo 1
pStorageWeatherAfUp weather$stg.waf.up 1
pStorageWeatherInpAfUp weather$inp.waf.up 1
pStorageWeatherInpAfLo weather$inp.waf.lo 1
pStorageWeatherOutAfUp weather$out.waf.up 1
pStorageWeatherOutAfLo weather$out.waf.lo 1

A bound with a weather factor is multiplied by factor × pWeather of the weather series (in its region and slice).

Where parameters meet
eqTechAfUp:
vTechAct[t,r,y,s] <= pTechAfUp
  × pTechCap2act × vTechCap[t,r,y]
  × pTimesliceShare[s]
  × Π (pTechWeatherAfUp × pWeather)

eqObjective:
vObjective = Σ(r,y) vTotalCost[r,y]
  × pPeriodLen[y] × pDiscountFactor[r,y]
  × pObjWeight[r,y]

Parameters are coefficients and right-hand sides. pDiscountFactor and pObjWeight enter the objective only; pPeriodLen also turns yearly new capacity into installed capacity.

Storage: parts, capacity, costs
name from def dims
pStorageOutWacc invcost$out.wacc 0 ry
pStorageOutPayback invcost$out.payback 0 ry
pStorageOutStock capacity$out.stock 0 ry
pStorageInpStock capacity$inp.stock 0 ry
pStorageInpInvcost invcost$inp.invcost 0 ry
pStorageInpFixom fixom$inp.fixom 0 ry
pStorageInpEac invcost$inp.eac 0 ry
pStorageInpCapLo capacity$inp.cap.lo 0 ry
pStorageInpCapUp capacity$inp.cap.up ∞ ry
pStorageInpNewCapLo capacity$inp.ncap.lo 0 ry
pStorageInpNewCapUp capacity$inp.ncap.up ∞ ry
pStorageStgStock capacity$stg.stock 0 ry
pStorageStgInvcost invcost$stg.invcost 0 ry
pStorageStgFixom fixom$stg.fixom 0 ry
pStorageStgEac invcost$stg.eac 0 ry
pStorageStgCapLo capacity$stg.cap.lo 0 ry
pStorageStgCapUp capacity$stg.cap.up ∞ ry
pStorageStgNewCapLo capacity$stg.ncap.lo 0 ry
pStorageStgNewCapUp capacity$stg.ncap.up ∞ ry
pStorageOutCapUp capacity$out.cap.up ∞ ry
pStorageOutCapLo capacity$out.cap.lo 0 ry
pStorageOutNewCapUp capacity$out.ncap.up ∞ ry
pStorageOutNewCapLo capacity$out.ncap.lo 0 ry
pStorageOutRetUp capacity$out.ret.up ∞ ry
pStorageOutRetLo capacity$out.ret.lo 0 ry
pStorageOutFixom fixom$out.fixom 0 ry
pStorageOutInvcost invcost$out.invcost 0 ry
pStorageOutEac invcost$out.eac 0 ry
pStorageOutRetCost invcost$out.retcost 0 ry
pStorageInpRetUp capacity$inp.ret.up ∞ ry
pStorageInpRetLo capacity$inp.ret.lo 0 ry
pStorageInpWacc invcost$inp.wacc 0 ry
pStorageInpPayback invcost$inp.payback 0 ry
pStorageInpRetCost invcost$inp.retcost 0 ry
pStorageStgRetUp capacity$stg.ret.up ∞ ry
pStorageStgRetLo capacity$stg.ret.lo 0 ry
pStorageStgWacc invcost$stg.wacc 0 ry
pStorageStgPayback invcost$stg.payback 0 ry
pStorageStgRetCost invcost$stg.retcost 0 ry
Storage: operation
name from def dims
pStorageInpEff seff$inp.eff 1 cryt
pStorageOutEff seff$out.eff 1 cryt
pStorageStgEff seff$stg.eff 1 cryt
pStorageInpCap2act input$cap2act 8760
pStorageOutCap2act output$cap2act 8760
pStorageInp2outLo inp2out$inp2out.lo 0 ry
pStorageInp2outUp inp2out$inp2out.up ∞ ry
pStorageInp2stgLo inp2stg$inp2stg.lo 0 ry
pStorageInp2stgUp inp2stg$inp2stg.up ∞ ry
pStorageOlife vintage$olife 1 r
pStorageCostStore varom$stg.varom 0 ryt
pStorageCostInp varom$inp.varom 0 ryt
pStorageCostOut varom$out.varom 0 ryt
pStorageTargetCost target$stg.af.cost 0 tier,r,y,t
pStorageDurationUp duration$duration.up ∞ ry
pStorageDurationLo duration$duration.lo 0 ry
pStorageAfLo af$stg.af.lo 0 ryt
pStorageAfUp af$stg.af.up 1 ryt
pStorageTarget target$stg.af.target 0 tier,r,y,t
pStorageInpAfUp af$inp.af.up 1 cryt
pStorageInpAfLo af$inp.af.lo 0 cryt
pStorageOutAfUp af$out.af.up 1 cryt
pStorageOutAfLo af$out.af.lo 0 cryt
pStorageNCap2Stg aeff$ncap2stg 0 cryt
pStorageStartLevel startLevel$startLevel 0 cryt
Storage: auxiliary flows
name from def dims
pStorageStg2AInp aeff$stg2ainp 0 cryt
pStorageStg2AOut aeff$stg2aout 0 cryt
pStorageCinp2AInp aeff$cinp2ainp 0 cryt
pStorageCinp2AOut aeff$cinp2aout 0 cryt
pStorageCout2AInp aeff$cout2ainp 0 cryt
pStorageCout2AOut aeff$cout2aout 0 cryt
pStorageInpCap2AInp aeff$inp.cap2ainp 0 cryt
pStorageInpCap2AOut aeff$inp.cap2aout 0 cryt
pStorageInpNCap2AInp aeff$inp.ncap2ainp 0 cryt
pStorageInpNCap2AOut aeff$inp.ncap2aout 0 cryt
pStorageStgCap2AInp aeff$stg.cap2ainp 0 cryt
pStorageStgCap2AOut aeff$stg.cap2aout 0 cryt
pStorageStgNCap2AInp aeff$stg.ncap2ainp 0 cryt
pStorageStgNCap2AOut aeff$stg.ncap2aout 0 cryt
pStorageOutCap2AInp aeff$out.cap2ainp 0 cryt
pStorageOutCap2AOut aeff$out.cap2aout 0 cryt
pStorageOutNCap2AInp aeff$out.ncap2ainp 0 cryt
pStoragePho2AInp aeff$pho2ainp 0 cryt
pStoragePho2AOut aeff$pho2aout 0 cryt
pStorageRet2AInp aeff$ret2ainp 0 cryt
pStorageRet2AOut aeff$ret2aout 0 cryt
pStorageOutNCap2AOut aeff$out.ncap2aout 0 cryt
Trade
name from def dims
pTradeWacc invcost$wacc 0 ry
pTradePayback invcost$payback 0 ry
pTradeIrEff trade$teff 1 rryt
pTradeIrUp trade$ava.up ∞ rryt
pTradeIrLo trade$ava.lo 0 rryt
pTradeIrVarom varom$varom 0 rryt
pTradeIrMarkup varom$markup 0 rryt
pTradeIrCsrc2Ainp aeff$csrc2ainp 0 crryt
pTradeIrCsrc2Aout aeff$csrc2aout 0 crryt
pTradeIrCdst2Ainp aeff$cdst2ainp 0 crryt
pTradeIrCdst2Aout aeff$cdst2aout 0 crryt
pTradeStock capacity$stock 0 y
pTradeCapUp capacity$cap.up ∞ y
pTradeCapLo capacity$cap.lo 0 y
pTradeNewCapUp capacity$ncap.up ∞ y
pTradeNewCapLo capacity$ncap.lo 0 y
pTradeRetUp capacity$ret.up ∞ y
pTradeRetLo capacity$ret.lo 0 y
pTradeOlife vintage$olife 1
pTradeInvcost invcost$invcost 0 ry
pTradeEac invcost$eac 0 ry
pTradeRetCost invcost$retcost 0 ry
pTradeFixom fixom$fixom 0 ry
pTradeCap2Act cap2act 1

Also in the model, not yet listed in model_structure: pTradeIrAfLo/Up (trade$af.lo/.up), pTradeIrAfsLo/Up (afs), pTradeWeatherAfLo/Up, pTradeWeatherAfsLo/Up (weather$waf, wafs).

Supply, demand, rest of the world
name from def dims
pSupCost supply$cost 0 cryt
pSupAvaUp supply$ava.up ∞ cryt
pSupAvaLo supply$ava.lo 0 cryt
pSupReserveUp reserve$res.up ∞ cr
pSupReserveLo reserve$res.lo 0 cr
pDemand demand$demand 0 cryt
pExportRowRes reserve 0
pExportRowUp export$exp.up ∞ ryt
pExportRowLo export$exp.lo 0 ryt
pExportRowPrice export$price 0 ryt
pImportRowRes reserve 0
pImportRowUp import$imp.up ∞ ryt
pImportRowLo import$imp.lo 0 ryt
pImportRowPrice import$price 0 ryt
Commodities, taxes, subsidies
name from def
pEmissionFactor emis$emis 0
pTaxCostInp tax$inp 0
pTaxCostOut tax$out 0
pTaxCostBal tax$bal 0
pSubCostInp subsidy$inp 0
pSubCostOut subsidy$out 0
pSubCostBal subsidy$bal 0
pAggregateFactor agg$agg 0

Dimensions: pEmissionFactor, pAggregateFactor c × c; the levies levy × c r y t. Without process targeting, a levy's inp/out/bal is charged on the commodity totals (above). With it, and always for act, cap, ncap, the rates go to the process route:

name desc
pTaxProcAct tax$act: per unit of activity
pTaxProcInp tax$inp: per unit a process consumes
pTaxProcOut tax$out: per unit a process produces
pTaxProcCap tax$cap, stg.cap: per unit of capacity
pTaxProcNcap tax$ncap, stg.ncap: per unit of new capacity
pTaxProcInpCap tax$inp.cap: storage charger capacity
pTaxProcInpNcap tax$inp.ncap: new charger capacity
pTaxProcOutCap tax$out.cap: storage discharger capacity
pTaxProcOutNcap tax$out.ncap: new discharger capacity
pSubProcAct the same columns of subsidy$…
pSubProcInp …
pSubProcOut …
pSubProcCap …
pSubProcNcap …
pSubProcInpCap …
pSubProcInpNcap …
pSubProcOutCap …
pSubProcOutNcap …

Dimensions: levy × process × r y, with c and t for flows.

Time, discounting, settings
name desc
pYearFraction share sampled; unused
pWacc cost of capital → p…Eac
pSdr social discount rate
pDiscountFactor Π 1/(1+sdr), 1 at start
pObjWeight year × region weight
pDiscountFactorMileStone declared, unused
pDummyImportCost price of vDummyImport
pDummyExportCost price of vDummyExport
pPeriodLen years a milestone covers
pTimesliceShare share of the year
pTimesliceWeight occurrences per year
pTimesliceAgg child weight / parent

From the horizon (pPeriodLen, the year weight), the calendar (pTimeslice…, pYearFraction), discount = (config@discount: pWacc, pSdr), config@objweight (the region weight) and debug = (pDummy…, ∞: no slack). pWacc and pSdr are spent in R, on p…Eac and pDiscountFactor; no equation reads them.

Dimensions: y; t, y t, y t t for slices; r y for the rates, factors and weight; c r y t for pDummy….

Derived at interpolation

Existing capacity (stock) is turned into a commissioning stream and a survival share by compute_stock_parameters(); nothing is declared on a slot.

name desc dims
pTechStockNew stock commissioned at this milestone: the rise in stock (all of it at the first) ry
pTechStockSurv share of the previous milestone's surviving stock kept ry
pStorageOutStockNew the same for the discharger ry
pStorageOutStockSurv … ry
pStorageInpStockNew the charger ry
pStorageInpStockSurv … ry
pStorageStgStockNew the reservoir ry
pStorageStgStockSurv … ry
pTradeStockNew trade capacity y
pTradeStockSurv … y

Also computed: p…Eac (from invcost, unless eac is given), pTaxProc…/pSubProc… (a levy's rates and targeting) and the time parameters.

Overriding a default
mod2 <- mod
mod2@config@defVal$pTechAf.up <- 0.5
scen2 <- interpolate_model(mod2,
  name = "P2", ondisk = FALSE)
compare_inputs(scen, scen2)$summary |>
  filter(status != "identical") |>
  select(parameter, status, meta)
  parameter    status   meta
1   pTechAf meta-diff defVal
The same rows, another default: a meta-diff on defVal.
EWIN@defVal$af.up <- 0.9          # one object
EWIN@interpolation$af.up <- "inter"
On an object the key is the column; the rule inter stops at the last given year.
A fixed bound, a stock
EFIX <- newTechnology("EFIX",
  output = list(comm = "ELC"),
  cap2act = 8760, af = list(af.fx = 0.5),
  capacity = data.frame(year = 2030,
                        stock = 1),
  invcost = list(invcost = 1), olife = 20)
s3 <- interpolate_model(add(mod0, EFIX),
  name = "P3", ondisk = FALSE)
getData(s3, name = "pTechAf", year = 2035,
        timeslice = "WIN", merge = TRUE) |>
  select(tech, year, type, value)
# A tibble: 2 × 4
  tech   year type  value
  <chr> <int> <chr> <dbl>
1 EFIX   2035 lo      0.5
2 EFIX   2035 up      0.5
af.fx is stored as a lo and an up row.
getData(s3, name_ = "^pTechStock",
        merge = TRUE) |>
  select(name, tech, year, value)
# A tibble: 2 × 4
  name           tech   year value
  <chr>          <chr> <int> <dbl>
1 pTechStock     EFIX   2030     1
2 pTechStockSurv EFIX   2035     0
stock interpolates by inter alone: given for 2030 only, it is gone at 2035 (survival 0). Give every year it stands, or year = NA.
Maps and sets

Sets hold the names: tech, stg, trade, sup, dem, imp, expp, comm, region, year, timeslice, group, weather, process, levy, tier. Maps (m…) are membership tables with no value, built at interpolation: what exists where and when.

getData(scen, name = "mTechSpan",
        maps = TRUE, merge = TRUE)
# A tibble: 6 × 5
  scenario name      tech  region  year
  <chr>    <chr>     <chr> <chr>  <int>
1 P        mTechSpan EGAS  R1      2030
2 P        mTechSpan EGAS  R1      2035
…
mTechSpan process × region × year it exists
mTechInpComm which commodity a process takes in
mCommTimeslice the slices of a commodity's balance
mv…, m… the domain of a variable
meq… the rows of an equation (meqTechAfUp)

They decide the size of the problem: a variable exists only on its map.

Reading parameters
getData(scen, name = "pTechEac",
        merge = TRUE) |>
  select(tech, year, value)
# A tibble: 6 × 3
  tech   year value
  <chr> <int> <dbl>
1 EGAS   2030  58.5
…
1300 annuitised at 5% over 25 years.
name_ = "^pTech" by regular expression
sets = TRUE add the sets
maps = TRUE add the maps
variables = FALSE parameters only
findData(object, dataType, …)
What a scenario holds: each parameter's columns and row count.
model_structure |>
  filter(name == "pTechAfUp") |>
  pull(dim)
[1] "tech, region, year, timeslice"
model_structure: every parameter, variable, set and map of the model, with its dimensions.
model_size(object, top_n)
Counts of value parameters, maps, sets and rows; the largest parameters.
How they are stored
sparse = FALSE keep default-valued rows; TRUE (default) drops them
fold = TRUE a uniform region, timeslice, year kept as one NA row
unfold = TRUE a folded parameter comes back expanded
variants = TRUE adds base, vintage, cluster to variant rows

sparse, fold: interpolate_model(); the others: getData().

Pitfalls
  • name = "pTechAfUp" finds nothing in a scenario: ask for pTechAf.
  • Only milestone years reach the solver; other years count through interpolation.
  • A given invcost$eac is used as is: wacc is ignored.