The following code seems to consume a lot of memory. Could anyone spot what
I'm doing wrong here? I'm also using the JuMP library.
function initUtilityConstraint()
c = categories[1]
me = attack_methods[1]
t = teams[1]
tuple = Simulate.cmt(c, me, t)
w = windows[1]
r = resources[1]
wrtuple = Simulate.wr(w, r)
for ni in 1:size(list,1), c in categories,* f in flights*
performloop(ni, c, f, tuple, wrtuple)
end
end
function performloop(ni, c, f, tuple, wrtuple)
fi = findfirst(flights, f)
for w in windows, me in attack_methods
tuple.c = c
tuple.m = me
total = 0.0
for t in teams
tuple.t = t
strat = linearizeStrategyS(f, c, t, w, ni)
total = total + effectiveness[tuple]*strat
end
total = ( total*(flight_vals[fi]*(-1)) + flight_vals[fi] )
for w2 in owindows, r2 in resources
wrtuple.w = w2
wrtuple.r = r2
over = linearizeOverflow(w2, r2, ni)
total = total - resource_fines[wrtuple]*over
end
# println(string( sc[c], "<=", ( total*(flight_vals[fi]*(-1)) +
flight_vals[fi] )))
@addConstraint(m, sc[c] <= total)
end
end
Following are the stats for piece this code. Stats were recorded using
@time.
For 1 item in the flights array, it takes about 620KB to execute the
performloop method - peak memory consumption by the program is 8.84GBs.
2 flights - 1.02MB per iteration of performloop - peak 8.88GBs.
3 flights - 3.45MB - 9.60GBs
4 flights - 4.35MB - 10.24GBs
5 flights - 10.8MB - 15.63GBs
It'd be great if someone could help me with this asap!
Thanks.