# How to build a constraint with summation?

**URL:** <https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [June 17, 2020, 6:20pm UTC](https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618 "2020-06-17T18:20:39Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![RaquelSantos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raquelsantos/32/3668_2.png) [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Post date:** [June 17, 2020, 6:20pm UTC](https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618/1 "2020-06-17T18:20:39Z")

</div>

I need to mount this restriction

![Restricao](https://global.discourse-cdn.com/julialang/original/3X/e/e/ee1186555fcfcc415a4dd076ad7da00925638ba6.jpeg)

But the following error is appearing when I compile the function:  
`syntax: incomplete: premature end of input`

I’m doing like this

```julia
using JuMP, Cbc
Model1 = Model(with_optimizer(Cbc.Optimizer)) 

a = 79
t = 18
w = 1

A = 1:79 
T = 1:18
Q = [8780; 11310; 8600; 12500; 925; 1918; 4026; 5076]
RHE = [150; 150; 150; 150; 150]
NE = [14; 53; 24; 58; 115]
OHE = [25; 25; 25; 25; 25]
WH = [2486; 1447; 795; 583; 232; 53; 11073; 5414] 

@variable(Model1,s[A,T], lower_bound=0)
@variable(Model1,x[A,T], lower_bound=0)

@constraint(Model1,sum(Q[a,w]*x[a,t]-sum(s[a,t].<=(RHE[w]+OHE[w])*NE[w]-WH[w,t] for a in A))

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618)._
