How to use the summation in Julia?

The JuMP repo has a number of examples that should be helpful. For example: JuMP.jl/cannery.jl at v0.21.2 · jump-dev/JuMP.jl · GitHub

For your example, you want something like this:

using JuMP
model = Model()

CR = [11; 11; 11; 11; 11]
CO = [50; 50; 50; 50; 50]

A = 1:80 #atividades
T = 1:18 #peírodo de tempo
W = 1:5 #centro de trabalho

@variable(model, r[A, T] >= 0)
@variable(model, o[A, T] >= 0)

@objective(
    model, 
    Min, 
    sum(CR[w] * (r[a, t] + o[a, t]) + CO[w] * o[a, t] for w in W, a in A, t in T)
)
2 Likes