Memory Allocation JuMP constraint!

Hi all,
I am implementing the following constraint which is allocating around 27MB of memory.

for i in 1:nLines
    f_bus     = nw_lines[i].line_from
    t_bus     = nw_lines[i].line_to
    idx_t_bus = findall(x->x==t_bus,rdata_buses[:,1])
    idx_f_bus = findall(x->x==f_bus,rdata_buses[:,1])
    for t in 1:nTP
        for s in 1:nSc
 @timeit tmr "con_current_brnc"  @NLconstraint(acopf,((gij_line^2+bij_line^2)*((e[s,t,idx_f_bus]^2+f[s,t,idx_f_bus]^2)+(e[s,t,idx_t_bus]^2+f[s,t,idx_t_bus]^2)-2*((e[s,t,idx_f_bus]*e[s,t,idx_t_bus]+f[s,t,idx_f_bus]*f[s,t,idx_t_bus]))))<=Imax_lpu^2)

To check the time and memory allocation of this constraint, I am using ‘TimerOutputs’ package and as can be seen, this constraint allocates a large memory (7.68k allocations and 27.2MiB memory).

con_current_brnc 7.68k 13.5ms 46.3% 1.76μs 27.2MiB 68.9% 3.63KiB

Can someone help why is that so? and how can I implement this constraint in a more efficient manner?

The parameters are as follows:

nLines = 34
nTP = 24,
nSc = 10
gij_line and bij_line are paramteres
acopf is JuMP model

Hi @musman, since your last post was a few months ago, please read Please read: make it easier to help you. It’s easier to help if you can provide a minimal working example that others can copy-paste.

Is this a bottleneck in your code?

It seems like the 7,680 times this line was called only took 13.5 ms? The 27 MiB is also not that much, and slightly misleading because it isn’t the peak allocation, but the total of all allocations (i.e., it counts temporary allocations).

1 Like