I work on an iterative algorithm. The simplified version of it is

Step 1: optimize problem1

Step 2: if objective_function_of_problem1 > zub exclude the answer and go to the step 1

Step 3: optimize problem2 with data pertaining to the solution of p1

Step 4: if objective_function_of_problem1 + objective_function_of_problem2 < zub then update zub = function of problem2

I do this for step 1 and 2:

```
zub=1000
function initiate()
for k in 1:10
optimize!(p1)
xᵏ=value.(x)
o¹=objective_value(p1)
if o¹ > zub
#@constraint for excluding the answer ......
break
end
end
return xᵏ
end
UndefVarError: xᵏ not defined
```

It looks like after break the data is lost.

Is it possible to stop the iteration with a condition without losing the data?

I wrote below code for step 4

```
zub=1000
function initiate()
optimize!(p1)
o¹=objective_value(p1)
o²=solve_p2(xʳ)[1]
if o²+o¹ < zub
zub=o²+o¹
end
end
UndefVarError: zub not defined
```

But it says zub is not defined. I defined it in the first line!

Thanks!