06 — Build a model#
v0.8.0 offers two extension paths without requiring a CGE-Core inheritance hierarchy: functional Python authoring and an experimental deterministic .cge.md specification.
%pip install -q "https://github.com/miraflor/CGE-core/releases/download/v0.8.0/cge_core-0.8.0-py3-none-any.whl"
Parse and compile .cge.md#
from importlib.resources import files
from cge_core.experimental.spec import parse_file, validate_document, compile_document
path = files("cge_core.experimental.spec").joinpath("examples", "two_good_exchange.cge.md")
doc = validate_document(parse_file(path))
model = compile_document(doc)
print("equations:", [eq.name for eq in doc.equations])
print("shockable groups:", [group.names for group in doc.shockables])
print("compiled Pyomo model:", model.name)
Only fenced cge blocks affect computation. Ordinary Markdown prose is documentation and cannot silently supply equations, parameters, or closure choices.