You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Rename Calcualtion to optimization.py
# Conflicts:
# flixopt/calculation.py
* Rename new classes slightly
* Also rename results classes
* FInalize port to new names
* Add old methods
* Udpate CHANGELOG.md
* Temp
* I've successfully renamed all aggregation-related classes and modules to use "clustering" terminology for better consistency with the ClusteredOptimization class
name.
Changes Made:
1. Module renamed:
- aggregation.py → clustering.py (via git mv)
2. Classes renamed:
- Aggregation → Clustering
- AggregationParameters → ClusteringParameters
- AggregationModel → ClusteringModel
3. Updated references in:
- optimization.py: All imports, attributes, and method parameters
- calculation.py: Import statement (for backward compat type hints)
- __init__.py: Exports (includes both old and new names)
- Module docstrings updated
4. Attribute updates:
- ClusteredOptimization.clustering_parameters
- ClusteredOptimization.clustering
- ClusteredOptimization.clustering_model
- self.durations['clustering']
- Label strings: 'Clustering' instead of 'Aggregation'
5. Backward compatibility:
- Added deprecated aliases in clustering.py for all old class names
- Old names exported from __init__.py with deprecation warnings
- All warnings point to v6.0.0 removal
6. Changelog updated: Added all clustering renames to the breaking changes section
* Bugfixes
* Use correct deprecation version removal
* Import fix
* Improve docstrings and remove duplicate check
* Remove loguru usage
* Bugfix
* Move solve to Optimization class
* 1. ✅ Added validation for nr_of_previous_values in SegmentedOptimization to prevent silent indexing bugs
2. ✅ Fixed active_timesteps type annotation to include None
3. ✅ Fixed fix_sizes() docstring/implementation inconsistency for optional ds parameter
The changelog now documents all the bug fixes that were applied based on the code review feedback.
* Update CHANGELOG.md
* Update tests
* Update tests
* Add setting logger level to SUCCESS directly
* Remove warnings from examples
* Remove warnings from examples
* Fix SUCCESS Level setting
* 1. Exported SUCCESS_LEVEL Constant ✓
- Added SUCCESS_LEVEL to __all__ in flixopt/config.py:20
- Users can now import and use it: from flixopt.config import SUCCESS_LEVEL
2. Enhanced Documentation ✓
- CONFIG.Logging docstring (flixopt/config.py:227-262):
- Added "Log Levels" section explaining all levels including SUCCESS (25)
- Added examples showing how to use SUCCESS level as string, numeric, or constant
- Shows that SUCCESS is between INFO (20) and WARNING (30)
- set_colors() docstring (flixopt/config.py:460):
- Already included SUCCESS in color customization examples
3. Comprehensive Test Coverage ✓
Added 5 new tests in tests/test_config.py:81-139:
- test_success_level_as_minimum: Verifies SUCCESS level filtering (INFO hidden, SUCCESS shown, WARNING shown)
- test_success_level_numeric: Tests using numeric value (25)
- test_success_level_constant: Tests using SUCCESS_LEVEL constant
- test_success_file_logging: Tests file logging with SUCCESS level
- test_success_color_customization: Tests color customization
* Removed:
- ❌ Monkey-patching logging.Logger.success = ...
- ❌ success() wrapper function
- ❌ All the complexity and fragility
Kept:
- ✅ SUCCESS_LEVEL = 25 constant (exported in __all__)
- ✅ logging.addLevelName(SUCCESS_LEVEL, 'SUCCESS')
- ✅ Clean documentation
* Fix singel line coloring
* FIx single and multiline coloring
* Add proper .modeled, .main_results and .summary to SegmentedOptimization
* Updaet CHANGELOG.md
* Implement Protocol
* Add proper type hints
* Remove not needed hints
* rename methods
* rename calculation variables to optimization
* Fixed the _initialize_optimization_common call in SegmentedOptimization.__init_
* Make init more explicit
* 1. Fixed outdated docstring in SegmentedResults.setup_colors
2. Fixed misleading objective calculation in SegmentedOptimization.main_result
3. Enhanced docstring warning (flixopt/optimization.py:868-87
* Change assertions to proper Exceptions
* Updated Terminology in docs:
Key Terminology Changes:
| Old | New |
|-----------------------|-----------------------|
| Calculation | Optimization |
| CalculationResults | Results |
| FullCalculation | Optimization |
| SegmentedCalculation | SegmentedOptimization |
| AggregatedCalculation | ClusteredOptimization |
| calculation modes | optimization modes |
* Add missing type hints and rename files mentioning claculation
* renamed all the "aggregation" attributes and methods to "clustering" while maintaining full backward compatibility.
* Improve naming in example
* Fix remaining mentions of Calculation
* Imrpove docstring
* Improve conftest.py
* Changed x-axis label from "Calculation type" to "Optimization type" for
consistency with the renamed terminolog
* Fixed xarray boolean comparisons by adding .item() to convert DataArray aggregates to scalar values
before use in conditional statements. This prevents ValueError: The truth value of a DataArray is ambiguous errors
* Updated TimeSeriesData class docstring from "with aggregation metadata" to "with clustering metadata" to
* Fix tests
* removed the unused hours_per_timestep attribute from SegmentedResults.__init__:
- Issue: This attribute was computed with incorrect semantics (using all_timesteps instead of timesteps_extra, producing N-1 values instead of
N)
- Fix: Completely removed the line since it was never accessed anywhere in the codebase
- Impact: No functionality affected - this was dead code with no consumers
* Add early validation
* Remove not needed type hint
* Add guards against results accessing before modeling
* Backward compatibility for legacy JSON key (lines 2128-2133):
* Guard against empty segment_results
* Fix deprecation of flow_system parameter in results.py
* Reuse SUCCESS_LEVEL constant
* Typo
* Typo
* Revert docstring changes
* Improve docstring
* Update CHANGELOG.md
* updated results.py to use the new naming scheme
* Further renamings
* Further renamings
* Rename CalculationResultsPaths to ResultsPaths
* Rename CalculationResultsPaths to ResultsPaths
* Change folder.mkdir(parents=False to True
* Temp
* Synchronized folder creation across codebase to always use parents=True and exist_ok=True
* added overwrite protection to prevent accidentally overwriting Results and SegmentedResults files.
* Use unique names in tests
* Improve logging message
* Improve CHANGELOG.md
* Improve CHANGELOG.md
Copy file name to clipboardExpand all lines: CHANGELOG.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,24 +56,46 @@ If upgrading from v2.x, see the [v3.0.0 release notes](https://github.com/flixOp
56
56
If upgrading from v2.x, see the [v3.0.0 release notes](https://github.com/flixOpt/flixOpt/releases/tag/v3.0.0) and [Migration Guide](https://flixopt.github.io/flixopt/latest/user-guide/migration-guide-v3/).
57
57
58
58
### ✨ Added
59
+
- `overwrite` parameter when saving results to file. If True, overwrite existing files.
59
60
60
61
### 💥 Breaking Changes
61
62
62
63
### ♻️ Changed
63
64
65
+
- Now creates the Results folder even i fparents didnt exist
**Multi-criteria optimization:** Model costs, emissions, resource use - any custom metric. Optimize single objectives or use weighted combinations and ε-constraints.
**Performance at any scale:** Choose calculation modes without changing your model - Full, Segmented, or Aggregated (using [TSAM](https://github.com/FZJ-IEK3-VSA/tsam)).
**Performance at any scale:** Choose optimization modes without changing your model - Optimization, SegmentedOptimization, or ClusteredOptimization (using [TSAM](https://github.com/FZJ-IEK3-VSA/tsam)).
**Built for reproducibility:** Self-contained NetCDF result files with complete model information. Load results months later - everything is preserved.
Copy file name to clipboardExpand all lines: docs/user-guide/core-concepts.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,23 +98,23 @@ This approach allows for multi-criteria optimization using both:
98
98
-**Weighted Sum Method**: Optimize a theoretical Effect which other Effects crosslink to
99
99
-**ε-constraint method**: Constrain effects to specific limits
100
100
101
-
### Calculation
101
+
### Optimization
102
102
103
-
A [`FlowSystem`][flixopt.flow_system.FlowSystem] can be converted to a Model and optimized by creating a[`Calculation`][flixopt.calculation.Calculation] from it.
103
+
A [`FlowSystem`][flixopt.flow_system.FlowSystem] can be converted to a Model and optimized by creating an[`Optimization`][flixopt.optimization.Optimization] from it.
104
104
105
-
FlixOpt offers different calculation modes:
105
+
FlixOpt offers different optimization modes:
106
106
107
-
-[`FullCalculation`][flixopt.calculation.FullCalculation] - Solves the entire problem at once
108
-
-[`SegmentedCalculation`][flixopt.calculation.SegmentedCalculation] - Solves the problem in segments (with optioinal overlap), improving performance for large problems
109
-
-[`AggregatedCalculation`][flixopt.calculation.AggregatedCalculation] - Uses typical periods to reduce computational requirements
107
+
-[`Optimization`][flixopt.optimization.Optimization] - Solves the entire problem at once
108
+
-[`SegmentedOptimization`][flixopt.optimization.SegmentedOptimization] - Solves the problem in segments (with optional overlap), improving performance for large problems
109
+
-[`ClusteredOptimization`][flixopt.optimization.ClusteredOptimization] - Uses typical periods to reduce computational requirements
110
110
111
111
### Results
112
112
113
-
The results of a calculation are stored in a [`CalculationResults`][flixopt.results.CalculationResults] object.
114
-
This object contains the solutions of the optimization as well as all information about the [`Calculation`][flixopt.calculation.Calculation] and the [`FlowSystem`][flixopt.flow_system.FlowSystem] it was created from.
115
-
The solution is stored as an `xarray.Dataset`, but can be accessed through their assotiated Component, Bus or Effect.
113
+
The results of an optimization are stored in a [`Results`][flixopt.results.Results] object.
114
+
This object contains the solutions of the optimization as well as all information about the [`Optimization`][flixopt.optimization.Optimization] and the [`FlowSystem`][flixopt.flow_system.FlowSystem] it was created from.
115
+
The solution is stored as an `xarray.Dataset`, but can be accessed through their associated Component, Bus or Effect.
116
116
117
-
This [`CalculationResults`][flixopt.results.CalculationResults] object can be saved to file and reloaded from file, allowing you to analyze the results anytime after the solve.
117
+
This [`Results`][flixopt.results.Results] object can be saved to file and reloaded from file, allowing you to analyze the results anytime after the solve.
118
118
119
119
## How These Concepts Work Together
120
120
@@ -128,12 +128,12 @@ The process of working with FlixOpt can be divided into 3 steps:
128
128
- Add
129
129
-[`FlowSystems`][flixopt.flow_system.FlowSystem] can also be loaded from a netCDF file*
130
130
2. Translate the model to a mathematical optimization problem
131
-
- Create a[`Calculation`][flixopt.calculation.Calculation] from your FlowSystem and choose a Solver
132
-
- ...The Calculation is translated internally to a mathematical optimization problem...
131
+
- Create an[`Optimization`][flixopt.optimization.Optimization] from your FlowSystem and choose a Solver
132
+
- ...The Optimization is translated internally to a mathematical optimization problem...
133
133
- ...and solved by the chosen solver.
134
134
3. Analyze the results
135
-
- The results are stored in a [`CalculationResults`][flixopt.results.CalculationResults] object
136
-
- This object can be saved to file and reloaded from file, retaining all information about the calculation
135
+
- The results are stored in a [`Results`][flixopt.results.Results] object
136
+
- This object can be saved to file and reloaded from file, retaining all information about the optimization
137
137
- As it contains the used [`FlowSystem`][flixopt.flow_system.FlowSystem], it fully documents all assumptions taken to create the results.
138
138
139
139
<figuremarkdown>
@@ -152,4 +152,4 @@ This allows to adjust your model to very specific requirements without loosing t
152
152
<!--- [FlowSystem](api/flow_system.md) - Time series and system organization-->
153
153
<!--- [Components](api/components.md) - Available component types and how to use them-->
154
154
<!--- [Effects](apieffects.md) - Costs, emissions, and other impacts-->
155
-
<!--- [Calculation Modes](api/calculation.md) - Different approaches to solving your model-->
155
+
<!--- [Optimization Modes](api/optimization.md) - Different approaches to solving your model-->
0 commit comments