# JuMP slow model generation

**URL:** <https://discourse.julialang.org/t/jump-slow-model-generation/1623>\
**Category:** Optimization (Mathematical)\
**Tags:** question\
**Created:** [January 20, 2017, 7:34pm UTC](https://discourse.julialang.org/t/jump-slow-model-generation/1623 "2017-01-20T19:34:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [January 20, 2017, 7:34pm UTC](https://discourse.julialang.org/t/jump-slow-model-generation/1623/1 "2017-01-20T19:34:13Z")

</div>

I am constructing large LP model with JuMP, that I want to solve using Gurobi. I get the following warning:

> WARNING: The addition operator has been used on JuMP expressions a large number of times. This warning is safe to ignore but may indicate that model generation is slower than necessary. For performance reasons, you should not add expressions in a loop. Instead of x += y, use append!(x,y) to modify x in place. If y is a single variable, you may also use push!(x, coef, y) in place of x += coef\*y.

I’m not sure what this means and how I can fix it. Looking at the output, I find that the model generation phase is very slow. After the model is generated, Gurobi solves it fast, in a few iterations with O(1) seconds each.

I don’t want to post my full code here because it is problem specific and complex. I would really appreciate some pointers on the meaning of the Warning above and how I can start looking to find the issue.

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [January 20, 2017, 10:29pm UTC](https://discourse.julialang.org/t/jump-slow-model-generation/1623/2 "2017-01-20T22:29:19Z")

</div>

I found the issue. Basically I was using `dot` of two large vectors of JuMP variables in a constraint. Replacing this with a `sum` fixed the issue. I think `dot` should do this automatically:

[https://github.com/JuliaOpt/JuMP.jl/issues/940](https://github.com/JuliaOpt/JuMP.jl/issues/940)
