# Solver time

**URL:** <https://discourse.julialang.org/t/solver-time/42114>\
**Category:** Optimization (Mathematical)\
**Created:** [June 26, 2020, 4:37pm UTC](https://discourse.julialang.org/t/solver-time/42114 "2020-06-26T16:37:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lausilvag](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lausilvag/32/9778_2.png) [@lausilvag](https://discourse.julialang.org/u/lausilvag)\
**Post date:** [June 26, 2020, 4:37pm UTC](https://discourse.julialang.org/t/solver-time/42114/1 "2020-06-26T16:37:40Z")

</div>

Hi!  
I have the following problem

```
t3 = time()
Z_OP = Model(with_optimizer(CPLEX.Optimizer))
t4 = time()
if RE ==2
    @variable(Z_OP, 0 <= x[l,m] <= 1 )
else
    @variable(Z_OP, x[l,m], Bin)
end
t5 = time()
for i = 1:size(A,1)
    @constraint(Z_OP, (A*x)[i,1] .== 1)           
end
t6 = time()
@objective(Z_OP, Min, sum(B*x))
t7 = time()
optimize!(Z_OP)

```

when I run the model, t6-t5 is very large if I compare it with t7-t6.

For 220 constraints and 24310 variables:  
t6-t5 = 105.4s  
t7-t6 = 0.304s

I have no idea what that time (t6-t5) refers to or why it takes longer in that step. Anybody can help me, please!!!  
🙂

---

<div class="post-metadata">

**Author:** ![blegat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blegat/32/217090_2.png) [@blegat](https://discourse.julialang.org/u/blegat)\
**Post date:** [June 26, 2020, 7:20pm UTC](https://discourse.julialang.org/t/solver-time/42114/2 "2020-06-26T19:20:03Z")

</div>

It is the time to build the constraints. Here, you could speed it up by avoiding to compute A\*x many times.  
You can compute `Ax = A * x` just once outside the loop or even do `A[i, :] * x[:, 1]`
