using JuMP, Cbc
Model1 = Model(with_optimizer(Cbc.Optimizer))
a = 2
t = 2
w = 2
A = 1:a
T = 1:t
W = 1:w
CR = [11, 11]
@variable(Model1,r[A,T], lower_bound=0)
@variable(Model1,o[A,T], lower_bound=0)
@objective(Model1,Min,sum((CR[w]*(r[a,t]+o[a,t])) for w in W, a in A, t in T))
But when I try to compile the objective function it adds up the values and gives me the following result:
Your objective function has a for w in W, this means for each pair of values a and t can assume (and, consequently, for each variable you have), you will have a loop with w == 1 and then another with w == 2, so what you do is: 11 r[1,1] + 11 o[1,1] ... 11 r[2,2] + 11 o[2,2] and then again 11 r[1,1] + 11 o[1,1] ... 11 r[2,2] + 11 o[2,2]. JuMP simplifies this to the completely equivalent expression 22 r[1,1] + 22 o[1,1] ... 22 r[2,2] + 22 o[2,2] (a single time). There is no bug in JuMP. Your code is doing exactly what is written it should do. There is no difference between two instances of 11 r[1, 1] and one instance of 22 r[1, 1].