-
Notifications
You must be signed in to change notification settings - Fork 49
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
Improve documentation on overriding coordinates feature #256
Comments
After some more time spend on this, I found at least two solutions/work arounds for this. Both create a corresponding The first one uses the Pyomo-style
The second one is kind of complicated as it builds a copy of the time dimension (with different name) and creates a square coefficient matrix between both dimensions, multiplies this onto the
After calling
Both solutions do not really satisfy me due to the mentioned drawbacks. Also the execution time for large dimensions compared to a simple So I would still appreciate any tips on how to improve the construction of the model 🙂 |
Hey @apfelix, have you played around with .groupby("time.day") (this requires to have a date time index) with a subsequent rolling operation? Something like previous_level = level.groupby("time.day").roll(time=1) Or you can create the index first and add the reindexed level ind = [24, 1, ...] (None of this is tested, but might help anyway) |
@FabianHofmann Thanks for the fast response! However, I'm a little confused on why this works to be honest ^^ When I print
So, the array value positions are as I need them, but the coordinates in front is also adjusted. I guess the coordinates are also the reason that
I guess that the coordinates are taken from the first of the terms, as switching the order in the sum results in a
When closely reading the documentation, it even mentions this overwrite behaviour in https://linopy.readthedocs.io/en/latest/creating-expressions.html#Using-.loc-to-select-a-subset Anyway, thanks for the help and for the general work you do on linopy! I really like the library and am especially grateful that you respond and fix things so quickly! Nice job! |
Thanks for the nice feedback @apfelix :) happy to hear that. You are right about making this overriding feature clearer to the user base. From your direct experience now, where would you have expected this quite important info? We could think about a runtime logger info the first time executing such an operation. Or a more prominent spot in the doc? |
Good question. I'm not sure about the logger, as it would produce just noise for those who are aware. Also it wouldn't have helped me, as you need to accidentally use the feature to get the corresponding notification explaining it. Wrt to documentation, I would have two proposals:
|
very good, thanks for the feedback! I will keep this issue then open (renamed it) and try to tackle that asap. If in the meanwhile you would like to make a PR, feel free to do so. We are happy about every contribution. |
I would be happy to adjust the documentation (and also incorporate the result of the discussion in #257 ) 🙂 However, I will probably not have time today and next week is fully blocked, so I can only do that the week after. |
Sounds great! I will make a PR that fixes the remaining inconsistency discussed in #257 |
Hi,
I'm currently stuck trying to archive the following rather specific problem in linopy:
So problem is in the creation of
previous_level
: I don't know have to do that. I know there isVariable.roll()
for creating a shift in specific dimensions, but I basically want this operation but restricted to a subset of the time index. My plan was to use the result ofroll()
and assign the correct variable value to the positions0
and24
myself, but assignment does not seem to work. Is there any way to create a self-defined variable vector that has the form of the result ofroll()
(single variables per coordinate tuple), but using an arbitrary assignment?PS: My fallback solution would be to create single constraints per point in time, but I would like to avoid that if possible ^^
The text was updated successfully, but these errors were encountered: