# How to iterate the optimization model with the updated bounds of the variables?

Hello all,

The optimization code is given below.

x_min=1; x_max=7; y_min=2; y_max=5;
m= Model(with_optimizer(Ipopt.Optimizer))
@variable(m, x>=0)
@variable(m, y>=0)
@variable(m, z)
@variable(m, w)
@constraint(m, x_min<=x<=x_max)
@constraint(m, w == 12)
@constraint(m, w >= x_min * y + x * y_min - x_min * y_min)
@constraint(m, w >= x_max * y + x * y_max - x_max * y_max)
@constraint(m, w <= x_min * y + x * y_max - x_min * y_max)
@constraint(m, w <= x_max * y + x * y_min - x_max * y_min)
@constraint(m, z == x+y)
@objective(m, Min, z)
optimize!(m)

After the first run of the above code, the x bounds are updated as below.

x_min=JuMP.value(x)
x_max=12/JuMP.value(y)

The code should run for the second time with this updated bounds on x, and this process would continue until a criteria is met.

Now, can anyone please help me how I can iterate the optimization model for 3 or 4 times using `while` loop?

``````criterion = false
i = 1
while !criterion && i < max_i
optimize!(m)
x_min=JuMP.value(x)
x_max=12/JuMP.value(y)
@constraint(__blah__)
criterion = # calculate criterion
i += 1
end
``````