The bracketed syntax got deprecated some time back - in a current version of Julia and JuMP (Julia 0.6.0, JuMP 0.18.0), the following works when I run it:
using JuMP
using Cbc
bar = Model(solver=CbcSolver())
# data
N = 3
M = 3
W = 3
K = 3
T = 77
s = ones(3,3)
@variable(bar, x[1:N,1:M,1:K,1:T],Bin)
p = reshape( [
[[9,7,12]; [10,6,8]; [8,10,9]];
[[6,5,9]; [8,4,6]; [6,8,6]];
[[4,4,5]; [4,3,4]; [5,3,5]]],
3,3,3)
for t = 1:T
@constraint(bar,
sum( ( ( (x[i, j, k, t] * k
for h = t:t + p[i, j, k] + 1 )
for j = 1:M)
for k = 1:K)
for i = 1:N) == 0)
end
solve(bar)
If using the current versions is not an option, plain old for loops
should also work:
(... same stuff as before up to the for loop ...)
for t = 1:T
s = 0.0
for j = 1:M
for k = 1:K
for i = 1:N
for h = t:t + p[i, j, k] + 1
s += k*x[i,j,k,t]
end
end
end
end
@constraint(bar, s == 0)
end
Which is arguably more readable than the first formulation anyway. Let me know if none of these versions work out for you, then we can look further.
P.S. If you ask something about a snippet of code, a screenshot is good, but actual code is better, then we don't have to type everything again :)