This isn’t doing what you think it is doing.
You have instead written:
for s = 1:5
w = 1:4
d = 1:7
@constraint(model, sum(x[m,s,w,d] for m in 1:9) >= 3)
end
And then it attempts the constraint sum(x[m, s, 1:4, 1:7] for m in 1:9) >= 3)
which has a matrix on the left and a constant on the right.
Do instead:
function solve()
model = Model(Gurobi.Optimizer)
@variable(model, x[m = 1:30, s = 1:5, w = 1:4, d = 1:7], Bin)
for s = 1:5, w = 1:4, d = 1:7
@constraint(model, sum(x[m,s,w,d] for m in 1:9) >= 3)
end
@objective(model, Min, sum(x))
println("\n\nsolving mathematical model...")
optimize!(model)
return termination_status(model)
end
Note the s = 1:5, w = 1:4, d = 1:7
instead of s = 1:5; w = 1:4; d = 1:7