From a question to a grounded, cited, validated decision
The agent turns raw power-system model outputs into decisions in two layers — a pipeline (what the
system does) and a reasoning workflow (how it thinks). One principle governs both: trace before trust.
Part A
The pipeline — seven stages
What happens from the moment the user hits enter to a shareable decision.
STAGE 01
Ask
The user poses a question, sets their role (planner, ministry, finance, regulator, power pool), and optionally pins one scenario. Role and scenario shape everything that follows.
STAGE 02
Secure
The request passes access control, rate limiting, and health checks before any analysis runs.
STAGE 03
Reason & ground
The core stage. The agent reads its governed instructions, calls tools that read the actual EPM workbooks, recalls past insights as advice, and ties every figure to its exact workbook, sheet & row — producing the numbered citations. (The 12 steps below happen here.)
STAGE 04
Assemble
Server-side and deterministic: the answer is routed into the right format and every chart is built directly from source data, so on-screen figures always equal sheet figures.
STAGE 05
Present
The browser renders decision cards, headline figures, cited sources, interactive charts, a Charting Station gallery, and a presentation-ready slide deck (Theater).
STAGE 06
Share
The user exports to PNG, ZIP PNG galleries, Markdown, PowerPoint, branded PDF/Word, or a full Country Report, with scene labels and stronger decision endings preserved.
STAGE 07
Learn
Every question is logged and every answer distilled into an insight. Patterns confirmed by two or more independent cases can be proposed as new knowledge — but a human approves before anything becomes a rule. The model proposes; a human disposes.
Part B
The reasoning workflow — twelve steps
What the agent does inside the “Reason & ground” stage when it analyzes any scenario.
01Frame the question — country, scenario, comparator, the user’s role, study horizon, and the actual policy question.
02Map the data — locate the exact sheets, columns, units, and year axes that hold the answer.
03Restate the result — lead with headline figures: system cost, energy generated, capacity added, unserved energy, emissions.
04Trace it back — assumptions → constraints → optimization → dispatch → postprocessing → chart.
05Separate the explanations — economics, reliability, carbon policy, imports, transmission, renewable integration, fleet assumptions, data & reporting errors.
06Classify the result — a credible insight, a fragile conclusion, or a model / reporting artifact.
07Explore alternatives — using if/then, what-if, if-only, and why-not logic.
08Generate decision options.
09Compare the trade-offs — cost, reliability, emissions, tariffs, market signals, affordability, implementation, energy security, political feasibility.
10Recommend validation — the sensitivity runs or checks that would confirm or falsify the conclusion.
11Produce decision-ready output — with action-led headings, not passive chart descriptions.
12End with a clear action.
The rule
Trace before trust
The discipline that governs every stage above.
The agent never trusts a chart until it has checked the whole chain behind it:
country context→input assumptions→scenario configuration→model constraints→optimization result→dispatch behavior→postprocessing→chart mapping→decision insight→recommended action
If any link is weak, the result is flagged provisional. And throughout, the agent keeps four things strictly separate:
Sector factswhat is true of the country
Model assumptionswhat was fed in
Model resultswhat the run computed
Policy recommendationswhat the agent advises
Part C
How it uses the ESMAP EPM source
The model behind every number is the World Bank–ESMAP Electricity Planning Model (EPM), an open-source,
least-cost capacity-expansion and dispatch model. The agent doesn’t just know about EPM — it grounds
each result in the model’s actual GAMS source and published docs, then names the specific object that produced the figure.
01Anchors to one authoritative model. EPM is the fixed reference: a GAMS optimization core (Model PA, a MILP minimizing net-present-value system cost) with a Python orchestration layer. Every claim about “what the model does” traces to it, not to general knowledge.
02Reads the GAMS as ground truth. A working clone of the repo sits in the workspace. The agent inspects the real files — base.gms (sets, variables, equations, objective), main.gms (orchestration & solve loop), the input readers and report generators — before making claims about how a result was produced.
03Names the object behind a number. When it cites model behavior it points to the actual GAMS object: the equation (e.g. energy balance eDemSupply), the variable (e.g. unserved energy vUSE, new build vBuild), or the scenario flag (e.g. fDispatchMode, fApplyCountryCo2Constraint) — so a modeler can find it in the source.
04Maps decision language to constraints. A policy question is translated into the constraint family that governs it — adequacy → energy balance & reserves, a carbon target → the emissions cap and its CO₂ backstop, regional trade → the external-exchange limits and trade price.
05Identifies the scenario by its switches. Scenarios differ mainly by which flags are on. The agent pins down the active switches before comparing runs, so a difference is attributed to the policy lever that actually changed — not guessed.
06Distinguishes result from artifact. Tracing to the source lets it tell a real optimization outcome from a loading bug or reporting error — a priced penalty/slack (unserved energy, curtailment, CO₂ backstop) reads differently from a binding constraint, and a mis-loaded cost trajectory reads differently again.
07Verifies against published docs. It grounds behavior in the official EPM documentation — model overview, objective, constraints, the equation reference, and representative-day time resolution — and refers users there for the detailed formulation rather than reproducing equations from memory.
08Keeps the model reference human-governed. The EPM GAMS reference is Tier 1 curated knowledge: it can be changed only by a human-approved edit, never rewritten automatically by the learning loop.
Why it matters: because each figure is tied back to a named equation, variable, or flag in the open EPM source,
a reviewer can independently reproduce or falsify any conclusion — the reasoning is auditable all the way down to the model.