fluxopt.contributions
¶
Per-contributor effect breakdown, read off the program.
Every contribution the ledger sums is a named expression in
math/program/, declared with the entity it came from and reduced only
where effect_accounting adds it up. So the breakdown is not a second
implementation of the effect math that has to be checked against the first —
it is the same declaration, read one step before the sum.
Two views, as before:
- with cross-effects (default): each contributor is charged the full
priced-in cost, CO2 through to cost. This is what the expressions give
directly, because the coefficients bound to the program already carry the
Leontief inverse (:mod:
fluxopt.leontief) — the model never multiplies it at build time. - direct: each contributor shows only what it directly emits, recovered
as
(I - C) . charged. A forward multiply, and the exact inverse of the fold the binder applied.
The contributor axis is a presentation choice rather than model math: flows and storages share one dimension, and a component-level cost is attributed to the first flow its status governs, having no single natural flow of its own.
Functions:
| Name | Description |
|---|---|
contributions_from |
The breakdown, assembled from the program's own contribution expressions. |
validate_against_solver |
The breakdown must add up to the totals the solver reported. |
contributions_from
¶
The breakdown, assembled from the program's own contribution expressions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Reads one named expression as a labelled array, or None where the program declares it but this system has no rows for it. |
required |
|
ModelData
|
The model data that was bound. |
required |
|
bool
|
Charge each contributor the full priced-in cost (default), or show only what it directly emits. |
True
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset with |
Dataset
|
(contributor, effect) and |
Source code in src/fluxopt/contributions.py
validate_against_solver
¶
The breakdown must add up to the totals the solver reported.
Kept although the breakdown and the ledger are now one declaration: what it guards is no longer a second implementation of the math, but the assembly above it — the contributor mapping, the reindexing, and the coordinate order the comparison is positional in.