fluxopt.math.results
¶
Turn an lpspec result into a :class:~fluxopt.results.Result.
Both lanes answer with the same object, which is what lets the parity test compare answers rather than shapes — and what makes deleting the linopy builder a deletion rather than a migration.
The work is relabelling. The program indexes time, period and
build_period by ordinal, because the engine joins on them and a timestamp
is a poor join key; :class:~fluxopt.results.Result is read by humans and
indexes them by the labels the element layer used. Everything else is a
rename: one program variable to one Var name.
Functions:
| Name | Description |
|---|---|
objective_weights |
The weights the objective is actually minimised with. |
to_result |
Build a :class: |
objective_weights
¶
The weights the objective is actually minimised with.
Not simply what the caller passed: the built-in penalty effect is added at
1.0 unless the caller named it, which is what makes a soft constraint cost
something. Both lanes have to agree here or their objectives are different
numbers for the same request — and Result.objective_weights is the
provenance a reader checks that against.
Source code in src/fluxopt/math/results.py
to_result
¶
to_result(
result: Result,
data: ModelData,
weights: dict[str, float],
model: Spec | None = None,
) -> Result
Build a :class:~fluxopt.results.Result from a solved lpspec model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Result
|
The lpspec result — primal frames and named expressions. |
required |
|
ModelData
|
The model data that was bound. Carries the labels the program
indexes by ordinal, and the tables |
required |
|
dict[str, float]
|
Effect ids mapped to their objective weight, for provenance. |
required |
|
Spec | None
|
The program that was solved, whose |
None
|
Returns:
| Type | Description |
|---|---|
Result
|
The same object the linopy lane returns. |
Raises:
| Type | Description |
|---|---|
NoSolutionError
|
If the solve did not produce a primal solution — there is no result to read, and an empty one would read as zeros. lpspec's own, so a caller sweeping scenarios catches one class for every lane and records the outcome. |