Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 9
V3.0.0/main#284
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
Uh oh!
There was an error while loading. Please reload this page.
V3.0.0/main #284
Changes from all commits
967174cd24b5e7a3c7d470977c1f5cf6e0e4cfa27f16fd74c67d1716b9680279f2f38bdbfb1b56738d34c64d12e0499497ee00577a11ed9224002440f9b30a26e89a9c0cbaae67ebfbb9edd1fad3c0c48e6e680c3d89b74cc772a4d92349e5c2900a8e2e9498d3bbe9be6572df63db8b167fb2cfc76adfcc7b155ec6e792b42aad2b55af45d5ace964187f30617600fe80bba0387cac627734cf4915b81fc5549a299ff43abc22b19b4c44c0ab7ea61dcbbb09aec990e370311793e820b87d9798ec265ea46fe64201d06610d2925cf9d17fbd52e05aa3668963b1c9229062fa18c43e41f9ef075d88fde1e94de3e5828ad870efeee97ec5ff15113e284072eebbb5dda501e051825089126b07f94d841dc19edc836cf47d8f1261d89d69f076f51a80ff4d2984c850b8b9dabb7e72ab517632f33c355c9f473ce57869a72bb29ef28d96a498240da18ac266443a64ea7b67f8db3fe443483ba12dee1de44ec39142554d8ad0627276dc23f5e6100d646f20356baeb8eaeaaa8315fd124d0b231d4ebe6a56b56daca7ec9942a75ed3dae9f01ba195ff605f034656000678132efa53c1162cb551bd7be766e60dd07bd2f1b8a7da9d2b8f0e227123b6bfa5475d80cb16181ad3ba691a45e3931ac575a45e1288214750491ff4f3a798314aef9030294740c437a8d2d2089c0c95fd568ad6ffc196a6142f44cec7367eba1ec45f97bf3935108399e6b194981a9c516f45bef0acfc706c1eca4cdb43148a85261755f966f6a86a757e7f941d93f745e885c9bae2ad1b5509c7568ddfc62634e320b9f33a22aa904211f3c6c08b22a1cef44dbefcf82556a33460a0ff70674fa5e30aa3511f9404dc031ad74ced1408a4ab000ca2afc24eb248f58d34445cbde07b45861b287809ee42bbdb442a01abe1f1ebb7c7b351f5d9b5915c56b639d242b609978431d6ef97972cb9029bec8c370ac940f89ff04781cff333ab83970230391bd46194314c350cc2cbe52f80092812569001c6a286a8b7ae1752b18223842aa9d4b5ca97077e043994f95ebcf73fe992d9c9205fd05e320a19649b05f8f4d7fd29362651750fbb679368985e4ec41066283cba84dfadd2182aa75c05ee66a6ff1e2e1f1362b18b65f0b50315a08e997de53c25f726e1716607b4a9236b7734f8e06692bcf0186c5510297b694dbe262e8b42a469f1159bcb3e764a1320f74f31474af6be6bd4226e091aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,115 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Investments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Current state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| \beta_{\text{invest}} \cdot \text{max}(\epsilon, \text V^{\text L}) \leq V \leq \beta_{\text{invest}} \cdot \text V^{\text U} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| With: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - $V$ = size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - $V^{\text L}$ = minimum size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - $V^{\text U}$ = maximum size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - $\epsilon$ = epsilon, a small number (such as $1e^{-5}$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - $\beta_{invest} \in {0,1}$ = wether the size is invested or not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+5
to
+12
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix LaTeX and definition typos in the core inequality. Use proper LaTeX for max, symbols, and sets; also fix spelling/wording in definitions. Apply: -$$-\beta_{\text{invest}} \cdot \text{max}(\epsilon, \text V^{\text L}) \leq V \leq \beta_{\text{invest}} \cdot \text V^{\text U}-$$+$$+\beta_{\mathrm{invest}} \cdot \max(\varepsilon, V^{\mathrm L}) \le V \le \beta_{\mathrm{invest}} \cdot V^{\mathrm U}+$$
@@
-- $\epsilon$ = epsilon, a small number (such as $1e^{-5}$)-- $\beta_{invest} \in {0,1}$ = wether the size is invested or not+- $\varepsilon$ = small positive number (e.g., $10^{-5}$)+- $\beta_{\mathrm{invest}} \in \{0,1\}$ = whether the size is invested📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _Please edit the use cases as needed_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Quickfix 1: Optimize the single best size overall | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Single variable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This is already possible and should be, as this is a needed use case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| An additional factor to when the size is actually available might me practical (Which indicates the (fixed) time of investment) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Math | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| V(p) = V * a(p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - $V$ = size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - $a(p)$ = factor for availlability per period | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Factor $a(p)$ is simply multiplied with relative minimum or maximum(t). This is already possible by doing this yourself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Effectively, the relative minimum or maximum are altered before using the same constraiints as before. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| THis might lead to some issues regariding minimum_load factor, or others, as the size is not 0 in a scenario where the component cant produce. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| **Therefore this might not be the best choice. See (#Variable per Scenario) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+27
to
+31
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typos, grammar, and anchor link. -Factor $a(p)$ is simply multiplied with relative minimum or maximum(t). This is already possible by doing this yourself.-Effectively, the relative minimum or maximum are altered before using the same constraiints as before.-THis might lead to some issues regariding minimum_load factor, or others, as the size is not 0 in a scenario where the component cant produce.-**Therefore this might not be the best choice. See (#Variable per Scenario)+Factor $a(p)$ is simply multiplied with the relative minimum or maximum(t). This is already possible to express externally.+Effectively, the relative minimum or maximum are altered before applying the same constraints as before.+This might lead to issues regarding a minimum_load factor or others, since the size is not 0 in a scenario where the component can't produce.+**Therefore this might not be the best choice. See [Variable per Scenario](#variable-per-scenario).**📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Variable per Scenario | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - **size** and **invest** as a variable per period $V(s)$ and $\beta_{invest}(s)$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - with scenario $s \in S$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Usecase 1: Optimize the size for each Scenario independently | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Restrictions are seperatly for each scenario | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| No changes needed. This could be the default behaviour. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Usecase 2: Optimize ONE size for ALL scenarios | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The size is the same globally, but not a scalar, but a variable per scenario $V(s)$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #### 2a: The same size in all scenarios | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| V(s) = V(s') \quad \forall s,s' \in S | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| With: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - $V(s)$ and $V(s')$ = size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - $S$ = set of scenarios | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #### 2b: The same size, but can be 0 prior to the first increment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Find the Optimal time of investment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Force an investment in a certain scenario (parameter optional as a list/array ob booleans) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Combine optional and minimum/maximum size to force an investment inside a range if scenarios | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| \beta_{\text{invest}}(s) \leq \beta_{\text{invest}}(s+1) \quad \forall s \in \{1,2,\ldots,S-1\} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| V(s') - V(s) \leq M \cdot (2 - \beta_{\text{invest}}(s) - \beta_{\text{invest}}(s')) \quad \forall s, s' \in S | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| V(s') - V(s) \geq M \cdot (2 - \beta_{\text{invest}}(s) - \beta_{\text{invest}}(s')) \quad \forall s, s' \in S | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+56
to
+66
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Big‑M pair: lower bound sign is wrong; define M. The second inequality must use a negative RHS; otherwise it forces a large positive difference when any beta is 0. \beta_{\text{invest}}(s) \leq \beta_{\text{invest}}(s+1) \quad \forall s \in \{1,2,\ldots,S-1\}
@@
-V(s') - V(s) \geq M \cdot (2 - \beta_{\text{invest}}(s) - \beta_{\text{invest}}(s')) \quad \forall s, s' \in S+V(s') - V(s) \geq -\,M \cdot (2 - \beta_{\text{invest}}(s) - \beta_{\text{invest}}(s')) \quad \forall s, s' \in S
@@
-This could be the default behaviour. (which would be consistent with other variables)+Here, $M$ is a sufficiently large constant (Big‑M). This could be the default behaviour (consistent with other variables).📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.17.2)56-56: Unordered list indentation (MD007, ul-indent) 58-58: Unordered list indentation (MD007, ul-indent) 59-59: Unordered list indentation (MD007, ul-indent) 60-60: Unordered list indentation (MD007, ul-indent) 61-61: Unordered list indentation (MD007, ul-indent) 63-63: Unordered list indentation (MD007, ul-indent) 64-64: Unordered list indentation (MD007, ul-indent) 66-66: Unordered list indentation (MD007, ul-indent) 🤖 Prompt for AI Agents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This could be the default behaviour. (which would be consistent with other variables) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Switch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| \begin{aligned} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| & \text{SWITCH}_s \in \{0,1\} \quad \forall s \in \{1,2,\ldots,S\} \\ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| & \sum_{s=1}^{S} \text{SWITCH}_s = 1 \\ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| & \beta_{\text{invest}}(s) = \sum_{s'=1}^{s} \text{SWITCH}_{s'} \quad \forall s \in \{1,2,\ldots,S\} \\ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| \end{aligned} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| \begin{aligned} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| & V(s) \leq V_{\text{actual}} \quad \forall s \in \{1,2,\ldots,S\} \\ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| & V(s) \geq V_{\text{actual}} - M \cdot (1 - \beta_{\text{invest}}(s)) \quad \forall s \in \{1,2,\ldots,S\} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| \end{aligned} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+70
to
+85
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Define V_actual and add non‑negativity (or lower bound). \sum_{s=1}^{S} \text{SWITCH}_s = 1 \\
\beta_{\text{invest}}(s) = \sum_{s'=1}^{s} \text{SWITCH}_{s'} \quad \forall s \in \{1,2,\ldots,S\} \\
@@
-& V(s) \leq V_{\text{actual}} \quad \forall s \in \{1,2,\ldots,S\} \\-& V(s) \geq V_{\text{actual}} - M \cdot (1 - \beta_{\text{invest}}(s)) \quad \forall s \in \{1,2,\ldots,S\}+& V(s) \leq V_{\text{actual}} \quad \forall s \in \{1,2,\ldots,S\} \\+& V(s) \geq V_{\text{actual}} - M \cdot (1 - \beta_{\text{invest}}(s)) \quad \forall s \in \{1,2,\ldots,S\} \\+& V(s) \ge 0 \quad \forall s \in \{1,2,\ldots,S\}Add a short sentence after the block: +where $V_{\text{actual}}$ is the global size variable shared across scenarios.📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.17.2)70-70: Unordered list indentation (MD007, ul-indent) 71-71: Unordered list indentation (MD007, ul-indent) 76-76: Strong style (MD050, strong-style) 76-76: Strong style (MD050, strong-style) 82-82: Trailing punctuation in heading (MD026, no-trailing-punctuation) 🤖 Prompt for AI Agents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Usecase 3: Find the best scenario to increment the size (Timing of the investment) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The size can only increment once (based on a starting point). This allows to optimize the timing of an investment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #### Math | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Treat $\beta_{invest}$ like an ON/OFF variable, and introduce a SwitchOn, that can only be active once. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *Thoughts:* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Treating $\beta_{invest}$ like an ON/OFF variable suggest using the already presentconstraints linked to On/OffModel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - The timing could be constraint to be first in scenario x, or last in scenario y | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Restrict the number of consecutive scenarios | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| THis might needs the OnOffModel to be more generic (HOURS). Further, the span between scenarios needs to be weighted (like dt_in_hours), or the scenarios need to be measureable (integers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Others | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #### Usecase 4: Only increase/decrease the size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Start from a certain size. For each scenario, the size can increase, but never decrease. (Or the other way around). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This would mean that a size expansion is possible, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #### Usecase 5: Restrict the increment in size per scenario | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Restrict how much the size can increase/decrease for in scenario, based on the prior scenario. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Many more are possible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -48,9 +48,9 @@ | ||||||||||||||
| # TimeSeriesData objects | ||||||||||||||
| TS_heat_demand = fx.TimeSeriesData(heat_demand) | ||||||||||||||
| TS_electricity_demand = fx.TimeSeriesData(electricity_demand, agg_weight=0.7) | ||||||||||||||
| TS_electricity_price_sell = fx.TimeSeriesData(-(electricity_demand - 0.5), agg_group='p_el') | ||||||||||||||
| TS_electricity_price_buy = fx.TimeSeriesData(electricity_price + 0.5, agg_group='p_el') | ||||||||||||||
| TS_electricity_demand = fx.TimeSeriesData(electricity_demand, aggregation_weight=0.7) | ||||||||||||||
| TS_electricity_price_sell = fx.TimeSeriesData(-(electricity_demand - 0.5), aggregation_group='p_el') | ||||||||||||||
| TS_electricity_price_buy = fx.TimeSeriesData(electricity_price + 0.5, aggregation_group='p_el') | ||||||||||||||
Comment on lines
+51
to
54
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix sell-price series: using demand instead of price
Apply: -TS_electricity_price_sell = fx.TimeSeriesData(-(electricity_demand - 0.5), aggregation_group='p_el')+TS_electricity_price_sell = fx.TimeSeriesData(-(electricity_price - 0.5), aggregation_group='p_el')📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents | ||||||||||||||
| flow_system = fx.FlowSystem(timesteps) | ||||||||||||||
| flow_system.add_elements( | ||||||||||||||
| @@ -164,12 +164,12 @@ | ||||||||||||||
| if full: | ||||||||||||||
| calculation = fx.FullCalculation('Full', flow_system) | ||||||||||||||
| calculation.do_modeling() | ||||||||||||||
| calculation.solve(fx.solvers.HighsSolver(0, 60)) | ||||||||||||||
| calculation.solve(fx.solvers.HighsSolver(0.01 / 100, 60)) | ||||||||||||||
| calculations.append(calculation) | ||||||||||||||
| if segmented: | ||||||||||||||
| calculation = fx.SegmentedCalculation('Segmented', flow_system, segment_length, overlap_length) | ||||||||||||||
| calculation.do_modeling_and_solve(fx.solvers.HighsSolver(0, 60)) | ||||||||||||||
| calculation.do_modeling_and_solve(fx.solvers.HighsSolver(0.01 / 100, 60)) | ||||||||||||||
| calculations.append(calculation) | ||||||||||||||
| if aggregated: | ||||||||||||||
| @@ -178,7 +178,7 @@ | ||||||||||||||
| aggregation_parameters.time_series_for_low_peaks = [TS_electricity_demand, TS_heat_demand] | ||||||||||||||
| calculation = fx.AggregatedCalculation('Aggregated', flow_system, aggregation_parameters) | ||||||||||||||
| calculation.do_modeling() | ||||||||||||||
| calculation.solve(fx.solvers.HighsSolver(0, 60)) | ||||||||||||||
| calculation.solve(fx.solvers.HighsSolver(0.01 / 100, 60)) | ||||||||||||||
| calculations.append(calculation) | ||||||||||||||
| # Get solutions for plotting for different calculations | ||||||||||||||
| @@ -194,34 +194,35 @@ def get_solutions(calcs: List, variable: str) -> xr.Dataset: | ||||||||||||||
| # --- Plotting for comparison --- | ||||||||||||||
| fx.plotting.with_plotly( | ||||||||||||||
| get_solutions(calculations, 'Speicher|charge_state').to_dataframe(), | ||||||||||||||
| mode='line', | ||||||||||||||
| style='line', | ||||||||||||||
| title='Charge State Comparison', | ||||||||||||||
| ylabel='Charge state', | ||||||||||||||
| ).write_html('results/Charge State.html') | ||||||||||||||
Comment on lines
195
to
201
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Ensure 'results' directory exists before writing HTML Prevent FileNotFoundError when writing plots. fx.plotting.with_plotly(
get_solutions(calculations, 'Speicher|charge_state').to_dataframe(),
style='line',
title='Charge State Comparison',
ylabel='Charge state',
).write_html('results/Charge State.html')
++# Create once before first write_html+pathlib.Path('results').mkdir(parents=True, exist_ok=True)
🤖 Prompt for AI Agents | ||||||||||||||
| fx.plotting.with_plotly( | ||||||||||||||
| get_solutions(calculations, 'BHKW2(Q_th)|flow_rate').to_dataframe(), | ||||||||||||||
| mode='line', | ||||||||||||||
| style='line', | ||||||||||||||
| title='BHKW2(Q_th) Flow Rate Comparison', | ||||||||||||||
| ylabel='Flow rate', | ||||||||||||||
| ).write_html('results/BHKW2 Thermal Power.html') | ||||||||||||||
| fx.plotting.with_plotly( | ||||||||||||||
| get_solutions(calculations, 'costs(operation)|total_per_timestep').to_dataframe(), | ||||||||||||||
| mode='line', | ||||||||||||||
| style='line', | ||||||||||||||
| title='Operation Cost Comparison', | ||||||||||||||
| ylabel='Costs [€]', | ||||||||||||||
| ).write_html('results/Operation Costs.html') | ||||||||||||||
| fx.plotting.with_plotly( | ||||||||||||||
| pd.DataFrame(get_solutions(calculations, 'costs(operation)|total_per_timestep').to_dataframe().sum()).T, | ||||||||||||||
| mode='bar', | ||||||||||||||
| style='stacked_bar', | ||||||||||||||
| title='Total Cost Comparison', | ||||||||||||||
| ylabel='Costs [€]', | ||||||||||||||
| ).update_layout(barmode='group').write_html('results/Total Costs.html') | ||||||||||||||
| fx.plotting.with_plotly( | ||||||||||||||
| pd.DataFrame([calc.durations for calc in calculations], index=[calc.name for calc in calculations]), 'bar' | ||||||||||||||
| pd.DataFrame([calc.durations for calc in calculations], index=[calc.name for calc in calculations]), | ||||||||||||||
| 'stacked_bar', | ||||||||||||||
| ).update_layout(title='Duration Comparison', xaxis_title='Calculation type', yaxis_title='Time (s)').write_html( | ||||||||||||||
| 'results/Speed Comparison.html' | ||||||||||||||
| ) | ||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
This should be redone probably.