I’m a beginner with julia and working on a MIP optimization problem and I’ve been having trouble finishing my objective. Below is the portion of the objective I have traced the error to.
sum(sum(3*t[i,j,l]+v1[i,j,l] for l in 1:days)*from_site_dist[i,j] for i in 1:sites for j in 1:stores)
The goal is to sum all the t and v1 int variables over 1:7 days, with respect to the route from site i to store j. Julia is telling me I’m indexing wrong but I can’t seem to figure out what the proper way to go about this is. Any help would be greatly appreciated.
julia> days=7
julia> sites=5
julia> stores=12
julia> t=rand(Int,sites,stores,days);
julia> v1=rand(Int,sites,stores,days);
julia> from_site_dist=rand(Int,sites,stores);
julia> sum(sum(3*t[i,j,l]+v1[i,j,l] for l in 1:days)*from_site_dist[i,j] for i in 1:sites for j in 1:stores)
2869535901568287053
It seems to work, so your arrays are not of the dimensions you are trying to index.