Search code examples
juliajulia-jump

Sum only for elements less than N


I want to add the following constraint:

@addConstraint(m, sum{sum{x[:alpha, d, s], s in S}, d in D} >= 5)

where x is a decision variable and

D = [1:50]

but I want the sum to be calculated only for d less than 10.
Is there a built-in way or do I have to find some workaround?


Solution

  • Should be able to just do d in D; d < 10, i.e.

    @addConstraint(m, sum{sum{x[:alpha, d, s], s in S}, d in D; d < 10} >= 5)
    

    For completeness, here is the link to the relevant section of the manual, which could be structured better. We'll work on that!