I have been using Jump to model a LP. The variable in my problem can be represented as follow:
x_prod[year, hour, site, product]
In my obj function I need something like that, for all the sites existing
sum(annual_prod[year, site] * cost[year,site] )
where :
annual_prod[year, site] = sum(x_prod[year, hour, site, product])
That means, I need to get the annual production by site. In order to get this value,
I’ve tried to use the object Accumulator from DataStrucutre like that :
annual_prod= Accumulator(Array,Float64)
for y in years
for t in timeslice
for site in list_available_site[y]
for p in prod_by_site[site]
push!(annual_prod,[y,site],x_prod[y,t,site,p])
end
end
end
end
end
That didn’t work at all because it isn’t defined for JumpVariables. I tried to get the values of the variables( that are float) it doesn’t work neither because the model has to be solved before using the values.
So, I’ve tried to create a Dictionary to accumulate these values but I haven’t found a way to push them by accumulating themselves into their respective key. Anyone knows if it is possible to do it ? This dumb code shows what I would like to be able to do:
for y in years
for t in timeslice
for site in list_available_site[y]
for p in prod_by_site[site]
annual_prod[y,site]= accumulate(+,x_prod[y,t,site,p])
end
end
end
end