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.
According to your line of code I tried the following MWE (minimal working example, see also here: https://discourse.julialang.org/t/psa-make-it-easier-to-help-you)
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)
It seems to work, so your arrays are not of the dimensions you are trying to index.
You can check for your arrays, the following should all give true:
Should have used this MWE strategy from the start, I’ll make sure to start implementing it in my debugging. This helped me fix the issue, thanks.