Variables are the solution
A variable is a column of the LP: the solver chooses its values. read_solution() reads them into scen@modOut, one table per variable, on the domain its map allows (mvTechAct, mTechSpan, ...). Names follow the parameters: vTech…, vStorage…, vTrade…, vSup…; …Tot is a total over processes.
getData(scen, name = "vTechCap",
merge = TRUE) |>
select(name, tech, region, year, value)
# A tibble: 6 × 5
name tech region year value
<chr> <chr> <chr> <int> <dbl>
1 vTechCap EGAS R1 2030 0.0000925
2 vTechCap EGAS R1 2035 0.0000925
3 vTechCap EGAS R1 2045 0.0000925
4 vTechCap EWIN R1 2030 0.0153
5 vTechCap EWIN R1 2035 0.0153
6 vTechCap EWIN R1 2045 0.0153
A one-region model with gas (
EGAS) and wind (
EWIN), milestones 2030, 2035, 2045, solved with GLPK. Results are read as on the
Results sheet:
getData(),
get_variable(),
timeframe,
apply_weights.
From costs to the objective
vTotalCost[r,y] = vSupCost + vTechEac + vTechFixom
+ vTechVarom + vTechRetCost + vStorageEac
+ vStorageFixom + vStorageVarom
+ vStorageShortCost + vStorageRetCost
+ vTradeEac + vTradeFixom + vTradeRetCost
+ vImportIrCost + vExportIrCost
+ vImportRowCost + vExportRowCost
+ vTaxCost + vSubsCost + vTotalUserCosts
+ vDummyImportCost + vDummyExportCost
vObjective = Σ(r,y) vTotalCost[r,y] × pPeriodLen[y]
× pDiscountFactor[r,y] × pObjWeight[r,y]
- Each term is the cost of one milestone year, its flows summed over the slices with their weights: annual, undiscounted.
- Revenues enter with a minus:
vExportRowCost (exports to the rest of the world), vSubsCost (subsidies).
-
vTechInv, vStorageInv, vTradeInv (overnight investment) are reported only: investment reaches the objective as …Eac.
Check it
tc <- getData(scen, name = "vTotalCost",
apply_period_length = TRUE, merge = TRUE)
df <- getData(scen, name = "pDiscountFactor",
merge = TRUE)
f <- df$value[match(tc$year, df$year)]
f[is.na(f)] <- 1 # default: the first year
c(sum = sum(tc$value * f),
vObjective = get_variable(scen,
"vObjective")$value)
sum vObjective
19.36555 19.36555
apply_period_length multiplies by pPeriodLen; a missing discount factor is its default, 1. No weight is set, so pObjWeight is 1.
-
Free (may be negative): the cost variables except
vStorageInv, vStorageEac, vTradeInv, and vBalance, vEmsFuelTot, vAggOutTot. All others are >= 0.
- Flows (
vTechOut, vSupOut, ...) are per occurrence of a slice; capacities per milestone year; vStorageLevel is a level, never summed over slices.
Technology
vTechAct |
activity |
ryt |
vTechInp |
input of a commodity |
cryt |
vTechOut |
output of a commodity |
cryt |
vTechAInp |
auxiliary input |
cryt |
vTechAOut |
auxiliary output |
cryt |
vTechNewCap |
new capacity, per year of the period |
ry |
vTechRetiredStock |
stock retired early |
ry |
vTechRetiredNewCap |
new capacity retired early, by vintage |
ryy |
vTechPhaseOut |
capacity reaching the end of its life |
ry |
vTechStockCap |
surviving exogenous capacity (stock) |
ry |
vTechStockPhaseOut |
stock leaving on its schedule |
ry |
vTechCap |
installed capacity |
ry |
Capacity, step by step
vTechCap[y] = vTechStockCap[y]
+ Σ(v alive) pPeriodLen[v]
× vTechNewCap[v] − early retirements
vTechEac[y] = Σ(v paying) pTechEac[v]
× pPeriodLen[v] × vTechNewCap[v] − …
vTechInv[y] = pTechInvcost[y]
× vTechNewCap[y]
v runs over the milestones built so far: alive within olife, paying within payback (else olife). Storage and trade capacities follow the same pattern.
Storage
vStorageAInp |
auxiliary input |
cryt |
vStorageAOut |
auxiliary output |
cryt |
vStorageInp |
charging |
cryt |
vStorageOut |
discharging |
cryt |
vStorageLevel |
stored amount (a level) |
cryt |
vStorageShort |
shortfall below a tier's level target |
tier,c,r,y,t |
vStorageOutStockCap |
surviving discharger stock |
ry |
vStorageInpStockCap |
surviving charger stock |
ry |
vStorageStgStockCap |
surviving reservoir stock |
ry |
vStorageStockPhaseOut |
stock leaving on its schedule |
ry |
vStoragePhaseOut |
capacity reaching the end of its life |
ry |
vStorageOutRetiredStock |
discharger stock retired early |
ry |
vStorageOutRetiredNewCap |
new discharger capacity retired early |
ryy |
vStorageInpRetiredStock |
charger stock retired early |
ry |
vStorageInpRetiredNewCap |
new charger capacity retired early |
ryy |
vStorageStgRetiredStock |
reservoir stock retired early |
ry |
vStorageStgRetiredNewCap |
new reservoir capacity retired early |
ryy |
vStorageOutCap |
discharger capacity |
ry |
vStorageOutNewCap |
new discharger capacity |
ry |
vStorageStgCap |
reservoir (energy) capacity |
ry |
vStorageInpCap |
charger capacity |
ry |
vStorageInpNewCap |
new charger capacity |
ry |
vStorageStgNewCap |
new reservoir capacity |
ry |
Trade
vTradeRetiredStock |
stock retired early |
y |
vTradeRetiredNewCap |
new capacity retired early |
yy |
vTradeStockCap |
surviving stock |
y |
vTradePhaseOut |
capacity reaching the end of its life |
y |
vTradeStockPhaseOut |
stock leaving on its schedule |
y |
vTradeIr |
flow on a route, at the sender |
crryt |
vTradeIrAInp |
auxiliary input |
cryt |
vTradeIrAOut |
auxiliary output |
cryt |
vTradeCap |
route capacity |
y |
vTradeNewCap |
new route capacity |
y |
vTradeIr is indexed by src and dst; the receiver gets it times pTradeIrEff.
Supply, demand, rest of the world
vSupOut |
supply used |
cryt |
vSupReserve |
cumulative supply over the horizon |
cr |
vDemInp |
demand met (equals pDemand) |
cryt |
vExportRowCum |
cumulative export |
c |
vExportRow |
export to the rest of the world |
cryt |
vImportRowCum |
cumulative import |
c |
vImportRow |
import from the rest of the world |
cryt |
Balances, totals, emissions
vEmsFuelTot |
emissions from fuel burnt |
cryt |
vBalance |
output − input of a commodity |
cryt |
vAggOutTot |
output of an aggregate commodity |
cryt |
vOutTot |
total output, all sources |
cryt |
vInpTot |
total input, all uses |
cryt |
vSupOutTot |
total supply |
cryt |
vTechInpTot |
technology input, main + aux |
cryt |
vTechOutTot |
technology output, main + aux |
cryt |
vStorageInpTot |
input to storages |
cryt |
vStorageOutTot |
output of storages |
cryt |
vDummyImport |
balance slack, import (debug) |
cryt |
vDummyExport |
balance slack, export (debug) |
cryt |
vImportTot |
trade received + ROW import |
cryt |
vExportTot |
trade sent + ROW export |
cryt |
vTradeIrAInpTot |
auxiliary input to trade |
cryt |
vTradeIrAOutTot |
auxiliary output of trade |
cryt |
vBalance = vOutTot − vInpTot, kept >= 0 (commodity limtype "LO", the default), <= 0 ("UP") or = 0 ("FX"). vEmsFuelTot = pEmissionFactor × pTechEmisComm × fuel input.
Costs of processes
vTechInv |
overnight investment (reported) |
ry |
vTechEac |
annualised investment |
ry |
vTechRetCost |
early retirement cost |
ry |
vTechFixom |
fixed O&M |
ry |
vTechVarom |
variable O&M |
ry |
vStorageFixom |
fixed O&M |
ry |
vStorageVarom |
variable O&M |
ry |
vStorageShortCost |
cost of level shortfalls |
ry |
vTradeEac |
annualised investment |
ry |
vTradeFixom |
fixed O&M |
ry |
vTradeRetCost |
early retirement cost |
ry |
vStorageRetCost |
early retirement cost |
ry |
vStorageInv |
overnight investment (reported) |
ry |
vStorageEac |
annualised investment |
ry |
vTradeInv |
overnight investment (reported) |
ry |
Other costs and the objective
vSupCost |
supply cost |
ry |
vTotalCost |
all costs of a region and year |
ry |
vObjective |
the objective, minimised |
|
vTaxCost |
taxes, by levy |
levy,r,y |
vSubsCost |
subsidies, by levy (negative) |
levy,r,y |
vDummyImportCost |
cost of the import slack |
cry |
vDummyExportCost |
cost of the export slack |
cry |
vImportIrCost |
markup paid by the receiver |
ry |
vExportIrCost |
sender: flow cost − markup |
ry |
vImportRowCost |
import bill, rest of the world |
ry |
vExportRowCost |
export revenue (negative) |
ry |
vTotalUserCosts |
newCosts() terms |
ry |
Reading variables
get_variable(scen, "vTechNewCap")
tech region year value
<fctr> <fctr> <int> <num>
1: EGAS R1 2030 9.250009e-05
…
One variable as stored: no filters, no labels.
getData() adds the scenario, names and filters.
parameters = FALSE |
variables only |
name_ = "Cost$" |
by regular expression |
findData(scen, "variables") |
what the solution holds |
Annual totals, weights, aggregation and comparisons: see the Results sheet.
Computed in R
Two more come with a solution, built by read_solution() rather than the solver: vTechEmsFuel (emissions by technology) and vUserCosts (by newCosts() object).
getData(scen, name = "vTechEmsFuel",
year = 2030, merge = TRUE) |>
select(tech, comm, timeslice, value)
# A tibble: 1 × 4
tech comm timeslice value
<chr> <chr> <chr> <dbl>
1 EGAS CO2 WIN 0.0400
Pitfalls
- Costs are per milestone year and undiscounted; only
vObjective is discounted and summed over the horizon.
-
vTechNewCap is a yearly rate: × pPeriodLen for the capacity a period adds.
- Summing a capacity over years, or
vStorageLevel over slices, means nothing.
Dimensions
|
r region |
y year |
t timeslice |
|
c commodity |
rr src, dst |
yy built, retired |
levy, tier
|
spelled out |
process: dropped |