Solver time

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!!!
:slight_smile:

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]