-
Notifications
You must be signed in to change notification settings - Fork 9
Feature/vintage investment timing #502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FBumann
wants to merge
7
commits into
feature/v5
Choose a base branch
from
feature/vintage-investment-timing
base: feature/v5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3e99524
⏺ The vintage dimension implementation is complete and all tests pass…
FBumann 85a588c
Temp
FBumann d9a2a0b
Temp
FBumann ad34f61
Temp
FBumann 374a535
Temp
FBumann da43796
Temp
FBumann 6148980
_track_lifetime() method in InvestmentModel had complex coordinate ha…
FBumann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
docs/user-guide/mathematical-notation/features/InvestmentParameters.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| # InvestmentParameters | ||
|
|
||
| InvestmentParameters extend [SizingParameters](SizingParameters.md) to model WHEN to invest, not just how much. | ||
|
|
||
| !!! info "Relationship to SizingParameters" | ||
| - **SizingParameters**: Determines capacity size (how much to build) | ||
| - **InvestmentParameters**: Adds timing decisions (when to invest) with fixed lifetime | ||
|
|
||
| ## Key Concept: Investment Timing | ||
|
|
||
| InvestmentParameters tracks: | ||
|
|
||
| 1. **When** the investment occurs (at most once) | ||
| 2. **How long** the investment is active (fixed lifetime) | ||
| 3. **When** decommissioning occurs (lifetime periods after investment) | ||
|
|
||
| $$ | ||
| \sum_{p} x^{invest}_p \leq 1 \quad \text{(invest at most once)} | ||
| $$ | ||
|
|
||
| $$ | ||
| x^{active}_p = 1 \iff \exists p' \leq p : x^{invest}_{p'} = 1 \land p - p' < L | ||
| $$ | ||
|
|
||
| where $L$ is the lifetime in periods. | ||
|
|
||
| --- | ||
|
|
||
| ## Basic Usage | ||
|
|
||
| ```python | ||
| solar_timing = fx.InvestmentParameters( | ||
| lifetime=10, # Investment lasts 10 periods | ||
| minimum_size=50, | ||
| maximum_size=200, | ||
| effects_of_size={'costs': 15000}, | ||
| effects_per_size={'costs': 1200}, | ||
| ) | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Timing Controls | ||
|
|
||
| === "Allow Investment" | ||
|
|
||
| Restrict when investment can occur: | ||
|
|
||
| ```python | ||
| import xarray as xr | ||
|
|
||
| fx.InvestmentParameters( | ||
| lifetime=10, | ||
| allow_investment=xr.DataArray( | ||
| [1, 1, 1, 0, 0], # Only allow in first 3 periods | ||
| coords=[('period', [2020, 2025, 2030, 2035, 2040])], | ||
| ), | ||
| ) | ||
| ``` | ||
|
|
||
| === "Force Investment" | ||
|
|
||
| Force investment in a specific period: | ||
|
|
||
| ```python | ||
| fx.InvestmentParameters( | ||
| lifetime=10, | ||
| force_investment=xr.DataArray( | ||
| [0, 0, 1, 0, 0], # Force in 2030 | ||
| coords=[('period', [2020, 2025, 2030, 2035, 2040])], | ||
| ), | ||
| ) | ||
| ``` | ||
|
|
||
| === "Previous Lifetime" | ||
|
|
||
| Model existing capacity from before the optimization horizon: | ||
|
|
||
| ```python | ||
| fx.InvestmentParameters( | ||
| lifetime=10, | ||
| previous_lifetime=3, # 3 periods of lifetime remaining | ||
| ) | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Investment-Period Effects | ||
|
|
||
| Effects that depend on WHEN the investment is made (technology learning curves, time-varying subsidies): | ||
|
|
||
| === "Fixed by Investment Period" | ||
|
|
||
| Effects that vary by investment timing: | ||
|
|
||
| ```python | ||
| # Cost decreases over time (learning curve) | ||
| fx.InvestmentParameters( | ||
| lifetime=10, | ||
| effects_of_investment={ | ||
| 'costs': xr.DataArray( | ||
| [50000, 45000, 40000, 35000, 30000], | ||
| coords=[('period', [2020, 2025, 2030, 2035, 2040])], | ||
| ) | ||
| }, | ||
| ) | ||
| ``` | ||
|
|
||
| === "Per-Size by Investment Period" | ||
|
|
||
| Size-dependent effects that vary by investment timing: | ||
|
|
||
| ```python | ||
| # Cost per kW decreases (technology improvement) | ||
| fx.InvestmentParameters( | ||
| lifetime=10, | ||
| effects_of_investment_per_size={ | ||
| 'costs': xr.DataArray( | ||
| [1500, 1200, 1000, 900, 800], # €/kW over time | ||
| coords=[('period', [2020, 2025, 2030, 2035, 2040])], | ||
| ) | ||
| }, | ||
| ) | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Variables Created | ||
|
|
||
| | Variable | Description | | ||
| |----------|-------------| | ||
| | `size` | Capacity size | | ||
| | `invested` | Binary: is investment currently active? | | ||
| | `investment_occurs` | Binary: does investment happen this period? | | ||
| | `decommissioning_occurs` | Binary: does decommissioning happen this period? | | ||
| | `size_increase` | Size increase when investing | | ||
| | `size_decrease` | Size decrease when decommissioning | | ||
|
|
||
| --- | ||
|
|
||
| ## Reference | ||
|
|
||
| | Symbol | Type | Description | | ||
| |--------|------|-------------| | ||
| | $P$ | $\mathbb{R}_{\geq 0}$ | Investment size (capacity) | | ||
| | $x^{invest}_p$ | $\{0, 1\}$ | Investment occurs in period $p$ | | ||
| | $x^{decom}_p$ | $\{0, 1\}$ | Decommissioning occurs in period $p$ | | ||
| | $x^{active}_p$ | $\{0, 1\}$ | Investment is active in period $p$ | | ||
| | $L$ | $\mathbb{Z}_{>0}$ | Lifetime in periods | | ||
|
|
||
| **Classes:** [`InvestmentParameters`][flixopt.interface.InvestmentParameters], [`InvestmentModel`][flixopt.features.InvestmentModel] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basic usage example uses sizing parameter names instead of investment-specific ones
In the “Basic Usage” snippet you configure:
Per the
InvestmentParametersAPI (and the later “Investment-Period Effects” examples), these fields should beeffects_of_investmentandeffects_of_investment_per_size, not the sizing-styleeffects_of_size/effects_per_size. Otherwise readers will copy an example that does not match the class signature.Suggestion:
🤖 Prompt for AI Agents