Convert a JuMPArray in PowerModels

Hi All,

I have the following piece of code in PowerModels that does some post processing procedures. It works perfectly for small test systems.

aa = getvalue(var(pm, :cs))
bpp = Dict( (parse(Int,i),   branch["f_bus"] , branch["t_bus"]) => aa[(branch["f_bus"],branch["t_bus"])] for (i,branch) in case["branch"])

However, when I apply it on larger test systems (e.g., nesta_case1394_sop_eir), I would get the following error. I will appreciate it if you guide me to fix this issue.

ERROR: Failed attempt to index JuMPArray along dimension 1

All the best,

If you only see the issue on larger cases it may be caused by parallel lines in the network. Try testing on the IEEE 24-bus RTS, which has some parallel lines in it.

Thanks for the response!
I have already apply the code on “nesta_case24_ieee_rts” and “nesta_case73_ieee_rts” test cases and have not gotten any error. The code also works for “nesta_case1354_pegase” test case which is a relatively large test system.
I really don’t know why it doesn’t work for some large test systems. I will appreciate your help to figuring out what is wrong with my code? Thanks in advance!

Is there any other way to put variable values and and branch indices (i.e., index, f_bus, t_bus) in an array?

All the best,

Another possiblity is that some branches have status 0. Have you tried ref(pm, :branch) instead of case["branch"]?

Thanks for the response! The issue exactly stems from considering lines with zero status.
I have faced another issue in my code. I want to apply some mathematical process on specific set of branches in which I have their associated “index” and “bp i.e., (f_bus , t_bus)”.
I want to define a dictionary with bp as key and binaries as value. If bp belong to the specified set of branches the value would be 1 otherwise it would be zero. Can you please help me to define such a dictionary in PowerModels. Thanks in advance!

I have implemented a similar code that works for cases with no line outages. But for large test systems with several line outages my code doesn’t work. Because the index of some specific branches (that I want to set their corresponding value to 1) is greater than the size of branches in ref(:branch).

All the best,

my recommendation would be to use the ref(pm, ...) function instead of the data dictionary. All of the inactive components are pre-filtered in ref.

I took your word and used ref(pm, :branch) instead of `case[“branch”] which resolved my first issue.
I have a specific array (e.g., [1 2; 3 9, 7 15]) which define a specific set of buspairs and I want to determine a dictionary such that values for the key in specific buspairs are “1” and values for other keys which are not in the specific set of buspairs (other buspairs in network) are “0”. I need such a dictionary to decide whether some mathematical process should enforce on a specific branch or not. Can you please let me know how can I define such a dictionary. Thanks in advance!

All the best,