-
Notifications
You must be signed in to change notification settings - Fork 12
Allow expressions in Nodes state_initial and state_final parameters #73
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
10ef4fc
feat: make `state_initial` and `state_final` expressions
daschw 3351b32
fix: add initial state constraint after finalizing expression
daschw ad56701
feat: add test example to check decisions in initial or final state
daschw c91d015
fix: remove redundant state_final state_cyclic check
daschw d7fe66a
feat: check for state_initial, state_final and state_cyclic
daschw 5273a8c
test: update ex 56 to test for state_cyclic with state_final
daschw 7a4f3b0
Apply suggestions from code review
daschw 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
73 changes: 73 additions & 0 deletions
73
assets/examples/56_final_state_decision_cyclic.iesopt.yaml
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,73 @@ | ||
| parameters: | ||
| p_nom: 70 | ||
| hours: 2.0 | ||
| efficiency: 0.975 | ||
| capex: 1000 | ||
| opex_fom: 500 | ||
| opex_vom: 1.8 | ||
| T: 24 | ||
|
|
||
| config: | ||
| general: | ||
| version: | ||
| core: 2.6.2 | ||
| optimization: | ||
| problem_type: LP | ||
| snapshots: | ||
| count: <T> | ||
| solver: | ||
| name: highs | ||
|
|
||
| carriers: | ||
| electricity: {} | ||
|
|
||
| components: | ||
| # -------------------------- | ||
|
|
||
| storage: | ||
| type: Node | ||
| carrier: electricity | ||
| state_final: 0.5 * (<p_nom> + invest:value) * <hours> | ||
| state_cyclic: eq | ||
| has_state: true | ||
| state_lb: 0 | ||
| state_ub: (<p_nom> + invest:value) * <hours> | ||
|
|
||
| node_electricity: | ||
| type: Node | ||
| carrier: electricity | ||
|
|
||
| # -------------------------- | ||
|
|
||
| market_electricity: | ||
| type: Profile | ||
| carrier: electricity | ||
| mode: ranged | ||
| node_from: node_electricity | ||
| cost: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24] | ||
|
|
||
| # -------------------------- | ||
|
|
||
| invest: | ||
| type: Decision | ||
| ub: 30 | ||
| cost: ((<capex> + <opex_fom>) / 8760.0 * <T>) | ||
|
|
||
| # -------------------------- | ||
|
|
||
| charge: | ||
| type: Unit | ||
| inputs: {electricity: node_electricity} | ||
| outputs: {electricity: storage} | ||
| conversion: 1 electricity -> <efficiency> electricity | ||
| capacity: (<p_nom> + invest:value) in:electricity | ||
| marginal_cost: <opex_vom> per out:electricity | ||
| objectives: {total_cost: 0.0 + (<p_nom> * <opex_fom>) / 8760.0 *<T>} | ||
|
|
||
| discharge: | ||
| type: Unit | ||
| inputs: {electricity: storage} | ||
| outputs: {electricity: node_electricity} | ||
| conversion: 1 electricity -> <efficiency> electricity | ||
| capacity: (<p_nom> + invest:value) out:electricity | ||
| marginal_cost: <opex_vom> per out:electricity |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| @doc raw""" | ||
| _node_con_last_state!(node::Node) | ||
|
|
||
| Add the constraint the `node`'s state at the first Snapshot to the `model`, if | ||
| `node.has_state == true` and `node.initial_state` is set. | ||
| """ | ||
| function _node_con_first_state!(node::Node) | ||
| node.has_state || return nothing | ||
| isnothing(node.state_initial.value) && return nothing | ||
|
daschw marked this conversation as resolved.
Outdated
|
||
| model = node.model | ||
| node.con.first_state = @constraint( | ||
| model, | ||
| node.var.state[1] == node.state_initial.value, | ||
| base_name = make_base_name(node, "first_state") | ||
| ) | ||
| return nothing | ||
| end | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.