
Cheat sheet: Diagnostics
Source:vignettes/articles/cheatsheet-diagnostics.Rmd
cheatsheet-diagnostics.RmdA check for each stage: declared model, interpolated scenario, infeasible solve, solved result
PDF, A4, one page · energyRt 0.91.5.9015 (dev) · 2026-11-29Which check, when
| stage | check | finds |
| declared model | check_feasibility() |
forced requirements above ceilings no decision can raise |
| interpolated | validate_scenario_parameters() |
missing, duplicated or out-of-domain rows; storages, lines without their equations |
process_operability() |
processes that cannot run, and why | |
audit_coefficients() |
coefficient range of each equation family | |
| infeasible | balance slack (debug =) |
which balance cannot close, where, when |
multimod::lp_bounds() |
matrix rows that cannot meet their bounds | |
| solved | verify_solution() |
accounting identities recomputed from the results |
compare_solve_settings() |
disagreement between solvers or settings |
Most of them need no solver. A clean check does not prove feasibility: what depends on decisions is left to the solver.
A planted defect
ann <- newCalendar(name = "annual",
timetable = make_timetable(
struct = list(ANNUAL = "ANNUAL")))
ELC <- newCommodity("ELC",
timeframe = "ANNUAL")
SUP_ELC <- newSupply("SUP_ELC", commodity = "ELC",
supply = data.frame(cost = 1,
ava.up = 6))
DEM_ELC <- newDemand("DEM_ELC", commodity = "ELC",
demand = data.frame(demand = 10))
short <- newModel("short", region = "R1",
calendar = ann, discount = 0.05,
horizon = newHorizon(period = 2030),
repo = newRepository("r", ELC, SUP_ELC, DEM_ELC))
check_feasibility(short)
Supply capped at 6 against a demand of 10: found before any solve, with the shortfall and the object that forces it.
After interpolation
EOCGT <- newTechnology("EOCGT",
output = list(comm = "ELC"),
cap2act = 1,
capacity = data.frame(cap.up = 0))
toy <- add(short, EOCGT)
BASE <- interpolate_model(toy,
name = "BASE", ondisk = FALSE)
validate_scenario_parameters(BASE,
action = "silent")
process_operability(BASE)
EOCGT is capped at zero: process_operability() names it and the reason.interpolate_model(short, name = "S",
check = TRUE) # stops, naming SUP_ELC
audit_coefficients(x, …)Writes the scenario, reads the matrix back, summarises coefficient ranges per equation family -- for numerical trouble.
Declared model
interpolate_model(mod, name = "X",
check = TRUE)
The same check inside interpolation: stops instead of building a scenario that cannot solve.
Interpolated scenario
validate_scenario_parameters(object, action, …)action = "silent" returns the findings as a table; interpolation runs it by default (validate = TRUE).process_operability(object)No source for an input, no capacity and no investment window, a bound at zero.
Infeasible
mod <- newModel("demo", repo = repo,
region = "R1", calendar = cal,
horizon = newHorizon(2030),
debug = data.frame(comm = NA,
region = NA, year = NA,
timeslice = NA,
dummyImport = 1e3,
dummyExport = 1e3))
A priced slack on every balance: the model solves, and the slack names the commodity, region, year and slice that cannot close.
getData(scen, name = "vDummyImport",
merge = TRUE)
summary(scen) # includes the slack's cost
- Price it well above every real cost, so it is used only where nothing else closes the balance.
- Still infeasible with the slack on? A user constraint or two contradicting bounds -- the slack does not relax those.
mm <- multimod_from_energyRt(scen)
lp <- multimod::model_to_lp(model = mm)
multimod::lp_bounds(lp = lp)
Rows whose possible activity cannot reach their bounds, found without a solver.
Solved, but suspect
verify_solution(object, checks, tol_rel, …)Recomputes the balance and its sign, source and sink totals, the cost decomposition and the objective from the results.
compare_solve_settings(object, settings, solvers, …)The same scenario on several solvers or settings: objective, time, status, disagreement.
compare_solve_settings(mod,
settings = list(default = list()),
solvers = list(
glpk = solver_options$glpk,
highs = solver_options$mm_highs))A sequence for a failing model
-
check_feasibility(), orinterpolate_model(check = TRUE). -
validate_scenario_parameters()andprocess_operability()on the scenario. - INFEASIBLE: the balance slack; then
multimod::lp_bounds()on the matrix. - OPTIMAL but odd:
verify_solution(), then a second solver. - Slow or numerically stuck:
audit_coefficients(), then units andcap2act.
Runs, logs, environment
scenario_runs(scen)[, c("run",
"status", "objective")]Common causes
| demand with no route to it | a commodity with demand but no supply, process or import in that region |
| a timeframe mismatch | a commodity balanced at a level the calendar does not have |
| units | capacity in GW, activity in PJ: cap2act converts; a wrong one shrinks or inflates every plant |
| a bound at zero |
cap.up = 0, af.up = 0, or a <= constraint whose rhs defaulted to 0 |
| the base year | stock that cannot meet base-year demand when investment is frozen |