KeyError in PowerModels

Hi All,

I developed PowerModels and PowerModelsAnnex, then ran my customized code in PowerModelsAnnex and encountered the following error. Could you please provide guidance on how to resolve this? Thanks in advance!

"ERROR: LoadError: KeyError: key “delta” not found
Stacktrace:
[1] getindex(h::Dict{String, Real}, key::String)
@ Base .\dict.jl:498 "

Hi @Rasoul,

I think you need to provide a reproducible example for this.

The error is saying you are trying to access a dictionary with the key "delta" but it doesn’t exist. But the where and how and why depends on your code.

julia> d = Dict("alpha" => 1, "beta" => 2)
Dict{String, Int64} with 2 entries:
  "alpha" => 1
  "beta"  => 2

julia> d["delta"]
ERROR: KeyError: key "delta" not found
Stacktrace:
 [1] getindex(h::Dict{String, Int64}, key::String)
   @ Base ./dict.jl:498
 [2] top-level scope
   @ REPL[224]:1

Hi Odow, thanks for the response! The dictionary in PowerModels is defined as follows:

‘buspairs = Dict((i, j) => Dict(
“branch” => bp_branch[(i, j)],
“angmin” => bp_angmin[(i, j)],
“angmax” => bp_angmax[(i, j)],
“tap” => branch_lookup[bp_branch[(i, j)]][“tap”],
“vm_fr_min” => bus_lookup[i][“vmin”],
“vm_fr_max” => bus_lookup[i][“vmax”],
“vm_to_min” => bus_lookup[j][“vmin”],
“vm_to_max” => bus_lookup[j][“vmax”],
“delta” => angle(1.0 / (branches[bp_branch[(i, j)]][“br_r”] + im * (branches[bp_branch[(i, j)]][“br_x”]))),
“shift” => branches[bp_branch[(i, j)]][“shift”]
)) for (i, j) in buspair_indexes’

I ran the same code a year ago, and it worked. Today, when I tried to run the same code, it didn’t work. I removed both PowerModels and PowerModelsAnnex, resolved, and instantiated the packages, but I still get this error.

Sure. But where is the code that generates the error?

Can you provide a reproducible example?