-
Notifications
You must be signed in to change notification settings - Fork 5
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
Shorthand conditional evaluation doesn't work with parameter[(kwargs)] syntax #61
Comments
Thanks @DillonJ. yeah, I'm pretty sure we haven't implemented the proper methods for that syntax to work with our |
|
I get a not method defined for * nothing, int64 (or whatever). I.e. the parameter value call results in nothing but for some reason
The variable is used for both regular connections and ptdf based connections and in the latter case it can only be zero one, but for regular connections, there is no reason candidate_connections can't be greater than one. For example, if you want to make the capacity of an interconnection a variable, but in steps of 500 MW. Edit: and actually, in the connection investment tests, we test for candidate_connections=4 |
Here is the example I'm working on The code: *
(
(connection_capacity[(connection=conn, node=n, direction=d, stochastic_scenario=s, analysis_time=t0, t=t)] == nothing)
? typemax(Int)
: connection_capacity[(connection=conn, node=n, direction=d, stochastic_scenario=s, analysis_time=t0, t=t)]
) The error:
|
On a side note, I see that in the tests, it tells you exactly where the nothing is - so I guess that can be very useful in debugging constraints! Didn't realise that until now! |
remember the brackets return a Edit: so, |
But I believe the problem here is we haven't implemented |
What about this
that would return "something" if the parameter is not defined, instead of just |
I really like that a lot - it would be incredibly useful! |
I'm not sure it's too great, |
And I'm not sure that it solves the issue...? |
Actually - you're right - what we want to do in some cases is conditionally include a term based on the value of a parameter - the investment variable for example |
The problem is, the value of the parameter is not known at the moment of generating the constraint. It's something that might change as the model rolls. So I suggest we split the indices into two, one set that needs the first constraint form, and a second set that needs the second constraint form, and write the two constraints independently. (While reusing as much code as possible) |
What about the case of method parameters though - they should not be time dependent |
Then I guess you use the call without the brackets that actually works... right? |
Ah, ok - cool |
Another option is to preprocess a parameter that returns 0 or 1 so we can multiply it with the other expression to get what we want. That's something that JuMP would understand I believe, and would be compatible with the automated model update. |
But sometimes multiplying is not enough - in cases where the variable won't exist at all, we want to omit the term - but I think we can live with the restriction that we can't have terms that are conditional on something that might be time varying |
Ah, right. Another option then is to use I did try some ideas this morning on getting the time varying conditional but hit some walls. There might be ways around it though, maybe I can think of something. |
For example, in constraint_connection_flow_capacity.jl, we only want to include the investment variable if candidate_connections is defined so we conditionally include the term as follows
The above works - however, it fails to behave correctly if we include the square brackets in the call to
candidate_connections()
as follows:candidate_connections[(connection=conn)]
Any thoughts @manuelma ?
The text was updated successfully, but these errors were encountered: