-
Notifications
You must be signed in to change notification settings - Fork 94
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
custom constraint foreach doesn't filter parameters in expression #679
Comments
This looks to be linked to #604 in that you want to be able to filter on a dimension (in this case, |
I think the distinction here is that I want to modify the behavior of individual instances of base techs based on different carrier groups per tech(/possibly node) by setting a parameter/group on the tech itself. My first attempt was just a list of carriers as a new parameter (formatted like the general input/output carrier params), but the model complained about the parameter formatting and I couldn't get it to just pass the list of carriers through to the slice.
This approach just gives the below error and doesn't look like it can even set the parameter:
If I could just define the list of carriers as a parameter and have the model take that and pass it in as if I define that same list in the slice expression I wouldn't need to set an indexed carrier parameter, but might have the same issue of needing to index by each Going with the carrier-indexed parameters lets me at least get a boolean array written to pass into the constraint but the constraint definition code can't take the multi-dimensional array and filter down to the tech in the
|
I still think it is essentially the same problem, even if the exact use case isn't the same. To test it, can you try the following constraint implementation: constraints:
balance_conversion:
description: >-
Recreate v0.6 conversion plus functionality. Override balance_conversion to tie just in_group_1 and out_group_1 together.
foreach: [nodes, techs, timesteps]
equations:
- where: NOT conversion_plus_flag AND NOT include_storage=true
expression: sum(flow_out_inc_eff, over=carriers) == sum(flow_in_inc_eff, over=carriers)
- where: conversion_plus_flag AND NOT include_storage=true
expression: sum(flow_in_inc_eff * default_if_empty(in_group_1, 0), over=carriers) == sum(flow_out_inc_eff * default_if_empty(out_group_1, 0), over=carriers) This follows the same approach as mentioned in #604 for filtering a dimension within an expression, for which I'd like to implement a more intuitive helper function (as discussed in the thread). |
What happened?
I've been working on rebuilding a general purpose implementation of the v0.6 conversion plus archetype in v0.7 as part of experimenting with more complex multicarrier conversion in v0.7. The goal is to eventually get the 3 input/output carrier groups working toggled by a new
conversion_plus_flag
parameter specified at thetech
level, but I am having issues slicing ontech
-specified carrier groups in thebalance_conversion
override with the first groups.Constraint YAML:
Tech definition:
The issue seems to be that the slice returns a 2D array indexed by
techs
andcarriers
when I try and slice and I'm not sure how to get the expression to slice to the tech/node being selected in theforeach
.Below is the error and a dump of the group parameter array causing it:
I'm trying in this example to get the second "row" passed in to the slice so that only the "Fuel" carrier is selected for summing
flow_in_inc_eff
in the custom expression. Not sure if this is a bug or if I'm missing something needed to build the slice so that it only selects the elements for thenode
and/ortech
selected in theforeach
.Which operating systems have you used?
Version
v0.7.0.dev3
Relevant log output
No response
The text was updated successfully, but these errors were encountered: