Skip to content
Closed
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
460 commits
Select commit Hold shift + click to select a range
b248f58
Improve BoundingPatterns
FBumann Jul 18, 2025
d34445c
Fix duration Modeling
FBumann Jul 18, 2025
bde07b4
Fix On + Size
FBumann Jul 18, 2025
5861b28
Fix InvestmentModel
FBumann Jul 19, 2025
7809ee4
Fix Models
FBumann Jul 19, 2025
2bbdb44
Update constraint names in test
FBumann Jul 19, 2025
2a01abe
Fix OnOffModel for multiple Flows
FBumann Jul 19, 2025
1f1ebb7
Update constraint names in tests
FBumann Jul 19, 2025
c7b351f
Simplify
FBumann Jul 19, 2025
5d9b591
Improve handling of vars/cons and models
FBumann Jul 19, 2025
5c56b63
Revising the basic structure of a class Model
FBumann Jul 20, 2025
9d242b6
Revising the basic structure of a class Model
FBumann Jul 20, 2025
0997843
Simplify and focus more on own Model class
FBumann Jul 21, 2025
1d6ef97
Update tests
FBumann Jul 21, 2025
972cb90
Improve state computation in ModelingUtilities
FBumann Jul 21, 2025
29bec8c
Improve handling of previous flowrates
FBumann Jul 21, 2025
370ac94
Imropove repr and submodel acess
FBumann Jul 21, 2025
0f89ff0
Update access pattern in tests
FBumann Jul 21, 2025
4781cff
Fix PiecewiseEffects and StorageModel
FBumann Jul 21, 2025
333ab83
Fix StorageModel and Remove PreventSimultaniousUseModel
FBumann Jul 21, 2025
9702303
Fix Aggregation and SegmentedCalculation
FBumann Jul 21, 2025
91bd461
Update tests
FBumann Jul 21, 2025
94314c3
Loosen precision in tests
FBumann Jul 21, 2025
50cc2cb
Update test_on_hours_computation.py and some types
FBumann Jul 21, 2025
e52f800
Rename class Model to Submodel
FBumann Jul 21, 2025
9281256
rename sub_model to submodel everywhere
FBumann Jul 21, 2025
9001c6a
rename self.model to self.submodel everywhere
FBumann Jul 21, 2025
286a8b7
Rename .model with .submodel if its only a submodel
FBumann Jul 21, 2025
ae1752b
Rename .sub_models with .submodels
FBumann Jul 21, 2025
1822384
Improve repr
FBumann Jul 22, 2025
2aa9d4b
Improve repr
FBumann Jul 22, 2025
5ca9707
Include def do_modeling() into __init__() of models
FBumann Jul 22, 2025
7e04399
Make properties private
FBumann Jul 22, 2025
4f95ebc
Improve Inheritance of Models
FBumann Jul 22, 2025
f73fe99
Merge branch 'main' into v3.0.0/main
FBumann Jul 22, 2025
2d9c920
V3.0.0/plotting (#285)
FBumann Jul 22, 2025
5fd05e3
ruff check
FBumann Jul 22, 2025
20a1964
Improve typehints
FBumann Jul 22, 2025
9b05f8f
Update CHANGELOG.md
FBumann Jul 22, 2025
4d7fd29
Bugfix from renaming to .submodel
FBumann Jul 22, 2025
3626517
Bugfix from renaming to .submodel
FBumann Jul 23, 2025
50fbb67
Improve indexer in results plotting
FBumann Jul 23, 2025
9368985
rename register_submodel() to .add_submodels() adn add SUbmodels coll…
FBumann Jul 23, 2025
e4ec410
Add nice repr to FlowSystemModel and Submodel
FBumann Jul 23, 2025
66283cb
Bugfix .variables and .constraints
FBumann Jul 23, 2025
a84dfad
Add type checks to modeling.py
FBumann Jul 23, 2025
d2182aa
Improve assertion in tests
FBumann Jul 23, 2025
75c05ee
Improve docstrings and register ElementModels directly in FlowSystemM…
FBumann Jul 23, 2025
66a6ff1
Improve __repr__()
FBumann Jul 23, 2025
e2e1f13
ruff check
FBumann Jul 23, 2025
62b18b6
Use new method to compare sets in tests
FBumann Jul 23, 2025
5f0b503
ruff check
FBumann Jul 23, 2025
15a08e9
Update Contribute.md, some dependencies and add pre-commit
FBumann Jul 23, 2025
97de53c
Pre commit hook
FBumann Jul 23, 2025
25f726e
Run Pre-Commit Hook for the first time
FBumann Jul 23, 2025
1716607
Fix link in README.md
FBumann Jul 23, 2025
b4a9236
Update Effect name in tests to be 'costs' instead of 'Costs' Everywhere
FBumann Jul 23, 2025
b7734f8
Improve some of the modeling and coord handling
FBumann Jul 23, 2025
e06692b
Add tests with years and scenarios
FBumann Jul 23, 2025
cf0186c
Update tests to run with multiple coords
FBumann Jul 23, 2025
5510297
Fix Effects dataset computation in case of empty effects
FBumann Jul 23, 2025
b694dbe
Update Test for multiple dims
FBumann Jul 24, 2025
262e8b4
Fix test with multiple dims
FBumann Jul 28, 2025
2a469f1
Fix test with multiple dims
FBumann Jul 28, 2025
159bcb3
New test
FBumann Jul 28, 2025
e764a13
New test for previous flow_rates
FBumann Jul 28, 2025
20f74f3
Merge pull request #286 from flixOpt/v3.0.0/testing
FBumann Jul 28, 2025
2c1c750
Add Model for YearAwareInvestments
FBumann Jul 29, 2025
70979fb
Add FlowSystem.years_per_year attribute and "years_of_last_year" para…
FBumann Jul 29, 2025
c9c4ddf
Add YearAwareInvestmentModel
FBumann Jul 29, 2025
85ec956
Add new Interface
FBumann Jul 29, 2025
18146c2
Improve YearAwareInvestmentModel
FBumann Jul 29, 2025
015aa1d
Rename and improve
FBumann Jul 30, 2025
e6da5ad
Move piecewise_effects
FBumann Jul 30, 2025
aafe95b
COmbine TImingInvestment into a single interface
FBumann Jul 30, 2025
9316d8a
Add model tests for investment
FBumann Jul 30, 2025
5ecb3c9
Add size_changes variables
FBumann Jul 31, 2025
b1c9b71
Add size_changes variables
FBumann Jul 31, 2025
3c98553
Improve InvestmentModel
FBumann Jul 31, 2025
5688c8f
Improve InvestmentModel
FBumann Aug 4, 2025
84c8f15
Rename parameters
FBumann Aug 4, 2025
566bcdf
remove old code
FBumann Aug 4, 2025
c334515
Add a duration_in_years to the InvestTimingParameters
FBumann Aug 4, 2025
98216e2
Improve handling of fixed_duration
FBumann Aug 5, 2025
7b45a19
Improve validation and make Investment/divestment optional by default
FBumann Aug 5, 2025
b919c0a
Rename some vars and improve previous handling
FBumann Aug 5, 2025
8e21165
Add validation for previous size
FBumann Aug 5, 2025
c2ce728
Change fit_to_model_coords to work with a Collection of dims
FBumann Aug 5, 2025
02c1f31
Improve fit_to_model_coords
FBumann Aug 5, 2025
5f85887
Improve test
FBumann Aug 5, 2025
815b8bf
Update transform_data()
FBumann Aug 6, 2025
1ffe27f
Add new "year of investment" coord to FlowSystem
FBumann Aug 7, 2025
3632965
Add 'year_of_investment' dimension to FlowSystem
FBumann Aug 7, 2025
9d78314
Improve InvestmentTiming
FBumann Aug 7, 2025
ca6fb06
Improve InvestmentTiming
FBumann Aug 7, 2025
abbe534
Add specific_effect back
FBumann Aug 7, 2025
6f550dd
add effects_by_investment_year back
FBumann Aug 7, 2025
b618578
Add year_of_investment to FLowSystem.sel()
FBumann Aug 7, 2025
4ff3e31
Improve Interface
FBumann Aug 7, 2025
98b6072
Handle selection of years properly again
FBumann Aug 7, 2025
fa4c107
Temp
FBumann Aug 7, 2025
f29dcde
Make ModelingPrimitives.consecutive_duration_tracking() dim-agnostic
FBumann Aug 13, 2025
d7574d8
Use new lifetime variable and constraining methods
FBumann Aug 13, 2025
1e61937
Improve Plausibility check
FBumann Aug 13, 2025
da3f29f
Improve InvestmentTImingParameters
FBumann Aug 13, 2025
331ed06
Improve weights
FBumann Aug 13, 2025
16c7481
Adjust test
FBumann Aug 13, 2025
e9e5e04
Remove old classes
FBumann Aug 13, 2025
1474af6
V3.0.0/main fit to model coords improve (#295)
FBumann Aug 13, 2025
d81a150
Merge branch 'v3.0.0/main' into v3.0.0/invest
FBumann Aug 13, 2025
3f03d22
ruff format
FBumann Sep 2, 2025
299f629
Merge remote-tracking branch 'origin/v3.0.0/invest' into dev
FBumann Sep 13, 2025
b9cf441
Revert changes
FBumann Sep 23, 2025
42e4f59
Revert changes
FBumann Sep 23, 2025
e1dcfb8
Update type hints
FBumann Sep 23, 2025
d1a6cae
Increase time delay of pypi install retrys in CI-CD
FBumann Sep 24, 2025
0552d8a
Feature/changelog (#353)
FBumann Sep 25, 2025
6452f28
Remove examples drom default CI for speedup (#359)
FBumann Sep 27, 2025
c1afaf0
Update Renovate config: add minimum release age and dependency groupi…
FBumann Sep 29, 2025
9ad68cc
Release v2.1.10
FBumann Sep 29, 2025
bbb3871
Exclude packages
FBumann Sep 29, 2025
6041b58
Update packaging configuration
FBumann Sep 29, 2025
0899360
Change to save netcdf files with 'h5netcdf' instead of netcdf4. Follo…
FBumann Sep 30, 2025
fa61e6e
Feature/h5netcdf update (#375)
FBumann Sep 30, 2025
80a9071
Update Renovate config: set custom rules for CalVer dependencies
FBumann Sep 30, 2025
55dea59
Allow automerge on dev dependencies with renovate.json
FBumann Sep 30, 2025
4b2b31f
Add "separateMinorPatch": false to renovate.json
FBumann Sep 30, 2025
dee2b23
Fix `charge_state` Constraint in `Storage` leading to incorrect losse…
FBumann Oct 5, 2025
8791012
Fix CHANGELOG.md
FBumann Oct 5, 2025
eb6bab0
Simplify changes from next release
FBumann Oct 5, 2025
1281d82
Update CHANGELOG.md
FBumann Oct 5, 2025
f8c196e
Fix CHANGELOG.md
FBumann Oct 5, 2025
f61a978
chore(deps): update dependency mkdocs-material to v9.6.20 (#369)
renovate[bot] Oct 5, 2025
2cc5af7
Improve renovate.json to automerge ruff despite 0.x version
FBumann Oct 6, 2025
bd1ef9c
chore(deps): update dependency tsam to v2.3.9 (#379)
renovate[bot] Oct 6, 2025
5e66d50
chore(deps): update dependency ruff to v0.13.2 (#378)
renovate[bot] Oct 7, 2025
493ca97
Feature/Improve Configuration options and handling (#385)
FBumann Oct 9, 2025
906fe99
Update CHANGELOG.md
FBumann Oct 9, 2025
f957ee8
Fix CHANGELOG.md
FBumann Oct 9, 2025
f3e765c
Allow blank issues
FBumann Oct 9, 2025
b4dde06
Add Multi-Period-modeling and stochastic modeling to flixopt (#348)
FBumann Oct 13, 2025
1bf330a
chore(deps): update dependency ruff to v0.13.3 (#400)
renovate[bot] Oct 13, 2025
06bb79d
chore(deps): update dependency mkdocs-material to v9.6.21 (#399)
renovate[bot] Oct 13, 2025
0f80565
chore(deps): update dependency astral-sh/uv to v0.8.23 (#368)
renovate[bot] Oct 13, 2025
6d2b56e
Fix docs and add migration guide (#404)
FBumann Oct 13, 2025
d6bb01f
Fix broken link in docs
FBumann Oct 13, 2025
924ef17
Feature/readme and vision (#405)
FBumann Oct 14, 2025
79233f1
Update CHANGELOG.md
FBumann Oct 14, 2025
64eb5ed
Fix workflow to run example test IN PARALLEL and WITH WARNINGS
FBumann Oct 14, 2025
e04c5aa
Update CI
FBumann Oct 14, 2025
c70a54c
Revert Development increase to new Status "Beta"
FBumann Oct 15, 2025
8294a64
Use Readme in docs for maintainability
FBumann Oct 15, 2025
552569a
Fix/update migration guide and changelog (#411)
FBumann Oct 16, 2025
236a387
Fix/revert rename of mode to style in plotting (#412)
FBumann Oct 16, 2025
f332c00
Update CHANGELOG.md
FBumann Oct 16, 2025
f6aef3a
Improve CHANGELOG.md
FBumann Oct 16, 2025
c72357e
Add error handling for empty buses (#416)
FBumann Oct 17, 2025
8323b27
Fix/409 bug error handling in investparameterslinked periods (#415)
FBumann Oct 17, 2025
babe326
Feature/pretty docs with theme (#413)
FBumann Oct 18, 2025
84ab912
Update CHANGELOG.md
FBumann Oct 18, 2025
75a2391
Feature/398 feature facet plots in results (#419) (#422)
FBumann Oct 19, 2025
9dd1342
Improved CHANGELOG.md
FBumann Oct 19, 2025
6b587e2
Readd Changelog Unreleased section
FBumann Oct 19, 2025
9b498e7
Convert numpy style docstrings to google style
FBumann Oct 19, 2025
434eebe
Fix/effects per component bug (#430)
FBumann Oct 20, 2025
27e4754
Update CHANGELOG.md
FBumann Oct 20, 2025
63b39af
Update CHANGELOG.md
FBumann Oct 20, 2025
28a6b9a
Fix concurrency testing issue
FBumann Oct 20, 2025
4296cde
chore(deps): update dependency astral-sh/uv to v0.9.2 (#425)
renovate[bot] Oct 20, 2025
dbec1bb
Improve examples
FBumann Oct 21, 2025
4305ed2
Fix docstring
FBumann Oct 22, 2025
feb0ced
Feature/plotting kwargs and streamline data conversion (#439)
FBumann Oct 24, 2025
ae56e6c
Feature/component colors (#440)
FBumann Oct 24, 2025
2b72783
Feature/centralized io (#441)
FBumann Oct 26, 2025
a6ee2c2
Update CHANGELOG.md
FBumann Oct 26, 2025
612ef70
Fix CI for examples
FBumann Oct 26, 2025
16aebe2
chore(deps): update dependency mkdocs-material to v9.6.22
renovate[bot] Oct 27, 2025
0d8e2b1
Merge pull request #445 from flixOpt/renovate/mkdocs-material-9.x
FBumann Oct 28, 2025
1794d0b
chore(deps): update dependency astral-sh/uv to v0.9.5 (#444)
renovate[bot] Oct 28, 2025
633a067
Improve bug_report.yml
FBumann Oct 28, 2025
acf35eb
Make minimal_example actually minimal
FBumann Oct 28, 2025
6ed521f
Add task.yml and strip down config.yml
FBumann Oct 28, 2025
dd33f6a
Fix Bug in resample regarding the duration of the last timestep durat…
FBumann Oct 29, 2025
c40cc9d
Update CI: RUn examples on push to main to catch errors pre release
FBumann Oct 29, 2025
98db5e4
Update CHANGELOG.md
FBumann Oct 29, 2025
2b2e835
Feature/containers-and-reprs-for-better-element-organization (#443)
FBumann Oct 29, 2025
3e9839b
Update CHANGELOG.md
FBumann Oct 30, 2025
4bf5cfc
Feature/improve docs (#449)
FBumann Oct 30, 2025
5905d9d
Typo and update CONTRIBUTE.md
FBumann Oct 30, 2025
0fc96d4
447 fix bug with switch on and multiple periods or scenarios (#450)
FBumann Oct 30, 2025
2cdc9fd
Feature/yaml representer (#451)
FBumann Oct 30, 2025
3b4809a
Update CHANGELOG.md
FBumann Oct 30, 2025
b91f804
Added type hint to all submodel attributes (#424)
FBumann Oct 30, 2025
28f0472
chore(deps): update dependency dash to v3.2.0 (#426)
renovate[bot] Oct 31, 2025
3fd56b5
Merge from main
FBumann Oct 31, 2025
363f9b6
Merge remote-tracking branch 'origin/main' into feature/v3/invest-mul…
FBumann Oct 31, 2025
d24c3eb
Merge from main
FBumann Oct 31, 2025
451b6d4
Temp 1
FBumann Oct 31, 2025
6beebb6
Only allow fixed lifetime for now
FBumann Nov 1, 2025
560b5ff
Rename parameters of InvestParameters
FBumann Nov 1, 2025
d62a9c1
Rename parameters of InvestParameters
FBumann Nov 1, 2025
ac7be9d
Rename parameters of InvestParameters
FBumann Nov 1, 2025
422d9c1
Rename InvestParameters to Sizing Parameters
FBumann Nov 1, 2025
15896b9
Rename piecewise_effects_of_investment to piecewise_effects_per_size
FBumann Nov 1, 2025
0d0e301
Remove linked_periods
FBumann Nov 1, 2025
1510a5b
Update
FBumann Nov 1, 2025
c1da66f
Update
FBumann Nov 1, 2025
3584d3c
Update
FBumann Nov 1, 2025
553d784
Update
FBumann Nov 1, 2025
b9cf855
Improve _SizeModel
FBumann Nov 1, 2025
4b6eaab
Improve _SizeModel
FBumann Nov 1, 2025
b131781
Rename to InvestmentModel
FBumann Nov 1, 2025
34bad2a
Reuse code
FBumann Nov 1, 2025
3c305d7
Rename initial_level to previous_level and use it
FBumann Nov 1, 2025
8e48c0b
Remove old InvestmentTiming class
FBumann Nov 1, 2025
a0c3e31
Fix old year dim
FBumann Nov 1, 2025
193581e
Fix in Storage
FBumann Nov 1, 2025
63707a5
Re-add old InvestParameters
FBumann Nov 1, 2025
efd6b31
Unify Contributing guides
FBumann Nov 1, 2025
31844f0
Feature/402 feature silent framework (#407)
FBumann Nov 1, 2025
7d5392a
Merge remote-tracking branch 'origin/main' into feature/v3/invest-mul…
FBumann Nov 1, 2025
ca3d88e
Typo Bugfix
FBumann Nov 1, 2025
e7fe67b
Add proper handling of mandatory size for all cases: all, some, no pe…
FBumann Nov 1, 2025
3c65db9
Bugfix
FBumann Nov 1, 2025
36fae3b
Bugfix
FBumann Nov 1, 2025
2bddd5a
Rename fixed_lifetime to lifetime
FBumann Nov 2, 2025
52c1f8a
Fix type hints
FBumann Nov 2, 2025
ae14baf
Small bugfixes
FBumann Nov 2, 2025
3db741d
Small bugfixes
FBumann Nov 2, 2025
24618d9
Fix inherritance issues
FBumann Nov 2, 2025
f8ac1eb
Fix missing availlable variable
FBumann Nov 2, 2025
7f28d62
Track lifetime
FBumann Nov 3, 2025
190ae49
Temp
FBumann Nov 3, 2025
e9b5287
Temp
FBumann Nov 3, 2025
45c3fad
Revert "Temp"
FBumann Nov 3, 2025
e465a62
Revert "Temp"
FBumann Nov 3, 2025
3d2e52b
Add constraints for lifetime with warnings
FBumann Nov 3, 2025
c1d501e
Improve warning massage
FBumann Nov 3, 2025
85e7cc7
Improve warning message
FBumann Nov 3, 2025
3a8bebd
Fix
FBumann Nov 3, 2025
e95f651
Fix
FBumann Nov 3, 2025
2bd61d5
Fix
FBumann Nov 3, 2025
75cb42a
Fix
FBumann Nov 3, 2025
603f54f
Use ffill instead of bfill
FBumann Nov 3, 2025
37cebdd
Revert "Use ffill instead of bfill"
FBumann Nov 3, 2025
c9caf96
Update
FBumann Nov 3, 2025
b50b0e5
Fix
FBumann Nov 3, 2025
1a9c5a7
Fix
FBumann Nov 3, 2025
c750fdc
Fix
FBumann Nov 3, 2025
43561ed
Fix for scenarios
FBumann Nov 4, 2025
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
1 change: 1 addition & 0 deletions flixopt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
FlowSystem,
FullCalculation,
InvestParameters,
InvestTimingParameters,
LinearConverter,
OnOffParameters,
Piece,
Expand Down
8 changes: 5 additions & 3 deletions flixopt/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from .components import Storage
from .config import CONFIG
from .core import DataConverter, Scalar, TimeSeriesData, drop_constant_arrays
from .features import InvestmentModel
from .features import InvestmentModel, InvestmentTimingModel
from .flow_system import FlowSystem
from .results import CalculationResults, SegmentedCalculationResults

Expand Down Expand Up @@ -118,13 +118,15 @@ def main_results(self) -> dict[str, Scalar | dict]:
model.label_of_element: model.size.solution
for component in self.flow_system.components.values()
for model in component.submodel.all_submodels
if isinstance(model, InvestmentModel) and model.size.solution.max() >= CONFIG.modeling.EPSILON
if isinstance(model, (InvestmentModel, InvestmentTimingModel))
and model.size.solution.max() >= CONFIG.modeling.EPSILON
},
'Not invested': {
model.label_of_element: model.size.solution
for component in self.flow_system.components.values()
for model in component.submodel.all_submodels
if isinstance(model, InvestmentModel) and model.size.solution.max() < CONFIG.modeling.EPSILON
if isinstance(model, (InvestmentModel, InvestmentTimingModel))
and model.size.solution.max() < CONFIG.modeling.EPSILON
},
},
'Buses with excess': [
Expand Down
11 changes: 10 additions & 1 deletion flixopt/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@
from .effects import Effect
from .elements import Bus, Flow
from .flow_system import FlowSystem
from .interface import InvestParameters, OnOffParameters, Piece, Piecewise, PiecewiseConversion, PiecewiseEffects
from .interface import (
InvestParameters,
InvestTimingParameters,
OnOffParameters,
Piece,
Piecewise,
PiecewiseConversion,
PiecewiseEffects,
)

__all__ = [
'TimeSeriesData',
Expand Down Expand Up @@ -48,4 +56,5 @@
'results',
'linear_converters',
'solvers',
'InvestTimingParameters',
]
6 changes: 3 additions & 3 deletions flixopt/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _plausibility_checks(self) -> None:
f'(in {self.label_full}) and variable size is uncommon. Please check if this is intended!'
)

def transform_data(self, flow_system: FlowSystem):
def transform_data(self, flow_system: FlowSystem, name_prefix: str = '') -> None:
super().transform_data(flow_system)
if self.conversion_factors:
self.conversion_factors = self._transform_conversion_factors(flow_system)
Expand Down Expand Up @@ -420,7 +420,7 @@ def create_model(self, model: FlowSystemModel) -> StorageModel:
self.submodel = StorageModel(model, self)
return self.submodel

def transform_data(self, flow_system: FlowSystem) -> None:
def transform_data(self, flow_system: FlowSystem, name_prefix: str = '') -> None:
super().transform_data(flow_system)
self.relative_minimum_charge_state = flow_system.fit_to_model_coords(
f'{self.label_full}|relative_minimum_charge_state',
Expand Down Expand Up @@ -691,7 +691,7 @@ def create_model(self, model) -> TransmissionModel:
self.submodel = TransmissionModel(model, self)
return self.submodel

def transform_data(self, flow_system: FlowSystem) -> None:
def transform_data(self, flow_system: FlowSystem, name_prefix: str = '') -> None:
super().transform_data(flow_system)
self.relative_losses = flow_system.fit_to_model_coords(
f'{self.label_full}|relative_losses', self.relative_losses
Expand Down
6 changes: 3 additions & 3 deletions flixopt/effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import numpy as np
import xarray as xr

from .core import Scalar, TemporalData, TemporalDataUser
from .core import NonTemporalDataUser, Scalar, TemporalData, TemporalDataUser
from .features import ShareAllocationModel
from .structure import Element, ElementModel, FlowSystemModel, Submodel, register_class_for_io

Expand Down Expand Up @@ -174,7 +174,7 @@ def __init__(
self.minimum_total = minimum_total
self.maximum_total = maximum_total

def transform_data(self, flow_system: FlowSystem):
def transform_data(self, flow_system: FlowSystem, name_prefix: str = '') -> None:
self.minimum_operation_per_hour = flow_system.fit_to_model_coords(
f'{self.label_full}|minimum_operation_per_hour', self.minimum_operation_per_hour
)
Expand Down Expand Up @@ -275,7 +275,7 @@ def _do_modeling(self):
TemporalEffectsUser = TemporalDataUser | dict[str, TemporalDataUser] # User-specified Shares to Effects
""" This datatype is used to define a temporal share to an effect by a certain attribute. """

NonTemporalEffectsUser = Scalar | dict[str, Scalar] # User-specified Shares to Effects
NonTemporalEffectsUser = NonTemporalDataUser | dict[str, NonTemporalDataUser] # User-specified Shares to Effects
""" This datatype is used to define a scalar share to an effect by a certain attribute. """

TemporalEffects = dict[str, TemporalData] # User-specified Shares to Effects
Expand Down
51 changes: 32 additions & 19 deletions flixopt/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

from .config import CONFIG
from .core import PlausibilityError, Scalar, TemporalData, TemporalDataUser
from .features import InvestmentModel, ModelingPrimitives, OnOffModel
from .interface import InvestParameters, OnOffParameters
from .features import InvestmentModel, InvestmentTimingModel, ModelingPrimitives, OnOffModel
from .interface import InvestParameters, InvestTimingParameters, OnOffParameters
from .modeling import BoundingPatterns, ModelingUtilitiesAbstract
from .structure import Element, ElementModel, FlowSystemModel, register_class_for_io

Expand Down Expand Up @@ -97,7 +97,7 @@ def create_model(self, model: FlowSystemModel) -> ComponentModel:
self.submodel = ComponentModel(model, self)
return self.submodel

def transform_data(self, flow_system: FlowSystem) -> None:
def transform_data(self, flow_system: FlowSystem, name_prefix: str = '') -> None:
if self.on_off_parameters is not None:
self.on_off_parameters.transform_data(flow_system, self.label_full)

Expand Down Expand Up @@ -189,7 +189,7 @@ def create_model(self, model: FlowSystemModel) -> BusModel:
self.submodel = BusModel(model, self)
return self.submodel

def transform_data(self, flow_system: FlowSystem):
def transform_data(self, flow_system: FlowSystem, name_prefix: str = '') -> None:
self.excess_penalty_per_flow_hour = flow_system.fit_to_model_coords(
f'{self.label_full}|excess_penalty_per_flow_hour', self.excess_penalty_per_flow_hour
)
Expand Down Expand Up @@ -368,7 +368,7 @@ def __init__(
self,
label: str,
bus: str,
size: Scalar | InvestParameters = None,
size: Scalar | InvestParameters | InvestTimingParameters = None,
fixed_relative_profile: TemporalDataUser | None = None,
relative_minimum: TemporalDataUser = 0,
relative_maximum: TemporalDataUser = 1,
Expand Down Expand Up @@ -417,7 +417,7 @@ def create_model(self, model: FlowSystemModel) -> FlowModel:
self.submodel = FlowModel(model, self)
return self.submodel

def transform_data(self, flow_system: FlowSystem):
def transform_data(self, flow_system: FlowSystem, name_prefix: str = '') -> None:
self.relative_minimum = flow_system.fit_to_model_coords(
f'{self.label_full}|relative_minimum', self.relative_minimum
)
Expand Down Expand Up @@ -445,7 +445,7 @@ def transform_data(self, flow_system: FlowSystem):

if self.on_off_parameters is not None:
self.on_off_parameters.transform_data(flow_system, self.label_full)
if isinstance(self.size, InvestParameters):
if isinstance(self.size, (InvestParameters, InvestTimingParameters)):
self.size.transform_data(flow_system, self.label_full)
else:
self.size = flow_system.fit_to_model_coords(f'{self.label_full}|size', self.size, dims=['year', 'scenario'])
Expand All @@ -455,7 +455,7 @@ def _plausibility_checks(self) -> None:
if np.any(self.relative_minimum > self.relative_maximum):
raise PlausibilityError(self.label_full + ': Take care, that relative_minimum <= relative_maximum!')

if not isinstance(self.size, InvestParameters) and (
if not isinstance(self.size, (InvestParameters, InvestTimingParameters)) and (
np.any(self.size == CONFIG.modeling.BIG) and self.fixed_relative_profile is not None
): # Default Size --> Most likely by accident
logger.warning(
Expand Down Expand Up @@ -556,15 +556,28 @@ def _create_on_off_model(self):
)

def _create_investment_model(self):
self.add_submodels(
InvestmentModel(
model=self._model,
label_of_element=self.label_of_element,
parameters=self.element.size,
label_of_model=self.label_of_element,
),
'investment',
)
if isinstance(self.element.size, InvestParameters):
self.add_submodels(
InvestmentModel(
model=self._model,
label_of_element=self.label_of_element,
parameters=self.element.size,
label_of_model=self.label_of_element,
),
'investment',
)
elif isinstance(self.element.size, InvestTimingParameters):
self.add_submodels(
InvestmentTimingModel(
model=self._model,
label_of_element=self.label_of_element,
parameters=self.element.size,
label_of_model=self.label_of_element,
),
'investment',
)
else:
raise ValueError(f'Invalid InvestParameters type: {type(self.element.size)}')

def _constraint_flow_rate(self):
if not self.with_investment and not self.with_on_off:
Expand Down Expand Up @@ -614,7 +627,7 @@ def with_on_off(self) -> bool:

@property
def with_investment(self) -> bool:
return isinstance(self.element.size, InvestParameters)
return isinstance(self.element.size, (InvestParameters, InvestTimingParameters))

# Properties for clean access to variables
@property
Expand Down Expand Up @@ -687,7 +700,7 @@ def absolute_flow_rate_bounds(self) -> tuple[TemporalData, TemporalData]:
if not self.with_investment:
# Basic case without investment and without OnOff
lb = lb_relative * self.element.size
elif not self.element.size.optional:
elif isinstance(self.element.size, InvestParameters) and not self.element.size.optional:
# With non-optional Investment
lb = lb_relative * self.element.size.minimum_or_fixed_size

Expand Down
Loading