[julia-users] Re: JuMP @addConstraint Sum over list of tuples

2014-05-10 Thread Joey Huchette
Hi Andrew, There are a couple of ways to make this work. The first is to construct x such that it is indexed by the tuples (1,2) and (3,4): @defVar(m, x[con_values] >= 0) @addConstraint(m, t == sum{param[i,j]*x[(i,j)], (i,j)=con_values}) The second is to unpack the tuples and construct x indexed

[julia-users] Re: JuMP @addConstraint Sum over list of tuples

2014-05-10 Thread Joey Huchette
Also note that by placing @defVar in a loop, you are overwriting the Julia variable x in every pass through the loop. New variables will be added to the JuMP model with every call to @defVar, but the only one accessible to the user will be the last one created (in this case, x[3,4]). I can't see

[julia-users] Re: JuMP @addConstraint Sum over list of tuples

2014-05-10 Thread Andrew B. Martin
This is exactly what I was looking for: > @defVar(m, x[con_values] >= 0) > @addConstraint(m, t == sum{param[i,j]*x[(i,j)], (i,j)=con_values}) > > Also good to know about overwriting variables and where to direct future questions. Thanks Joey!

[julia-users] Re: JuMP @addConstraint Sum over list of tuples

2014-05-10 Thread Iain Dunning
and thank you Andrew for using JuMP! On Saturday, May 10, 2014 1:40:22 PM UTC-4, Andrew B. Martin wrote: > > This is exactly what I was looking for: > > >> @defVar(m, x[con_values] >= 0) >> @addConstraint(m, t == sum{param[i,j]*x[(i,j)], (i,j)=con_values}) >> >> > Also good to know about overwri