Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions flixopt/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,20 @@
folder: Optional[pathlib.Path] = None,
):
"""
Args:
name: name of calculation
flow_system: flow_system which should be calculated
active_timesteps: list with indices, which should be used for calculation. If None, then all timesteps are used.
folder: folder where results should be saved. If None, then the current working directory is used.
Initialize a Calculation.

Check failure on line 51 in flixopt/calculation.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W293)

flixopt/calculation.py:51:1: W293 Blank line contains whitespace
Creates a calculation scaffold for a FlowSystem: stores name, target flow_system, optional active timesteps, and prepares places to hold the SystemModel and CalculationResults. Initializes timing counters and ensures an output folder exists.

Check failure on line 53 in flixopt/calculation.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W293)

flixopt/calculation.py:53:1: W293 Blank line contains whitespace
Parameters:
name: Human-readable name for the calculation.
flow_system: Target FlowSystem to be modeled and solved.
active_timesteps: Optional subset of timesteps to activate for modeling; when None all timesteps are used.
folder: Optional output folder for results; when None a `./results` directory under the current working directory is used.

Check failure on line 59 in flixopt/calculation.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W293)

flixopt/calculation.py:59:1: W293 Blank line contains whitespace
Notes:
- The output folder is created if it does not exist. If a path exists but is not a directory a NotADirectoryError is raised.
- If the specified folder's parent does not exist, directory creation will raise FileNotFoundError.
- The instance initializes `model` and `results` to None and `durations` tracking for modeling, solving, and saving to 0.0.
"""
self.name = name
self.flow_system = flow_system
Expand All @@ -68,6 +77,23 @@

@property
def main_results(self) -> Dict[str, Union[Scalar, Dict]]:
"""
Return a structured summary of core results extracted from the solved model.

Check failure on line 82 in flixopt/calculation.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W293)

flixopt/calculation.py:82:1: W293 Blank line contains whitespace
The returned dictionary contains:
- "Objective": scalar objective value from the solved model.
- "Penalty": total penalty value from model effects.
- "Effects": a mapping per effect labeled as "Label [unit]" to a dict with
numeric "operation", "invest", and "total" values taken from the effect submodel solutions.
- "Invest-Decisions": two groups ("Invested" and "Not invested") mapping element labels to
the numeric invested sizes; classification uses CONFIG.modeling.EPSILON as the threshold
(values >= EPSILON are considered invested).
- "Buses with excess": a list of single-key dicts (bus full label -> { "input", "output" })
for buses marked with excess where either total excess input or output exceeds 1e-3.

Check failure on line 93 in flixopt/calculation.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W293)

flixopt/calculation.py:93:1: W293 Blank line contains whitespace
All numeric values are returned as native Python floats. The function inspects submodels
to identify InvestmentModel instances to build the investment partitions.
"""
from flixopt.features import InvestmentModel

return {
Expand Down
Loading