I want to write the code below in Julia but I keep getting the error
MethodError: no method matching getindex(::VariableRef, ::Int64)
Any help will be appreciated please. Thank you for your help.
using JuMP
using Mosek
using MosekTools
model= Model(Mosek.Optimizer)
#Input parameter
xs = [0, 5, -5, 4, -5]
ys = [0, 0.6, 0.5, -5, -4.5]
r=[0 0 0 0 0]
NumVar=5
#Input varaibles
@variable(model, p[i=1:NumVar]>=0)
@variable(model, q[i=1:NumVar]>=0)
@variable(model, z[i=1:NumVar]>=0)
@variable(model, R>=0)
@variable(model, X>=0)
@variable(model, y>=0)
#Objective function
@objective(model, Min, R)
##Constraints
for i in 1:NumVar
@constraint(model, p[i] == X-xs[i])
@constraint(model, q[i] == y-ys[i])
@constraint(model, z[i] == R-r[i])
@constraint(model, [z[i], x[i], y[i]] in SecondOrderCone())
end
@show model
print(model)
optimize!(model)
@show termination_status(model)
@show primal_status(model)
@show dual_status(model)
@show objective_value(model)
for i in 1:NumVar
println("x[$i] = ", value(x[i]))
println("y[$i] = ", value(y[i]))
println("z[$i] = ", value(z[i]))
end