Perhaps something like this? (I didn’t test, so there might be typos, etc).
using JuMP
import Mosek
import MosekTools
function inner_loop(x, y)
NumVar = 5
a = [0,2.5,-2.5,2,-2.5]
b = [0,0.3,0.25,-2.5,-2.25]
r = [4, 8, 9, 8, 8]
R = 0.0
for i in 1:length(a)
R = max(R, sqrt((a[i] - x)^2 + (b[i] - y)^2) + r[i])
end
model = Model(Mosek.Optimizer)
@variable(model, x >= 0)
@variable(model, y >= 0)
@variable(model, z >= 0)
@objective(model, Min, x^2 + y^2 - z)
@constraint(
model,
[i in 1:NumVar],
-2 * x * a[i] - 2 * b[i] * y + z <= (R - r[i])^2 - a[i]^2 - b[i]^2,
)
optimize!(model)
return value(x), value(y), value(z), R
end
function main()
x, y, z, R = 0.0, 0.0, Inf, 0.0
while abs(x^2 + y^2 - z) >= 0.01
x, y, z, R = inner_loop(x, y)
end
return x, y, z, R
end