I am trying to recreate the SDP formulation of the OPF given by Lavaei and Low 2013.
After defining the whole model, I receive a warning of an invalid variable. Am I missing any type declaration besides the one for the SDP matrices?
Any help is highly appreciated.
Here’s the error and code:
Invalid variable type present
Stacktrace:
[1] setvartype!(::Mosek.MosekMathProgSolverInterface.MosekMathProgConicModel, ::Array{Symbol,1}) at C:\Users\alvaro.gonzalez\.julia\v0.6\Mosek\src\MosekConicInterface.jl:619
[2] #build#119(::Bool, ::Bool, ::JuMP.ProblemTraits, ::Function, ::JuMP.Model) at C:\Users\alvaro.gonzalez\.julia\v0.6\JuMP\src\solvers.jl:388
[3] (::JuMP.#kw##build)(::Array{Any,1}, ::JuMP.#build, ::JuMP.Model) at .\<missing>:0
[4] #solve#116(::Bool, ::Bool, ::Bool, ::Array{Any,1}, ::Function, ::JuMP.Model) at C:\Users\alvaro.gonzalez\.julia\v0.6\JuMP\src\solvers.jl:168
[5] solve(::JuMP.Model) at C:\Users\alvaro.gonzalez\.julia\v0.6\JuMP\src\solvers.jl:150
[6] include_string(::String, ::String) at .\loading.jl:522
`# Optimization model
sdpOPF = Model(solver = MosekSolver())
#Sets
Nodes = 1:N
# Variables
@variable(sdpOPF, h)
@variable(sdpOPF, λ[k in Nodes])
@variable(sdpOPF, λsub[k in Nodes], lowerbound = 0)
@variable(sdpOPF, λover[k in Nodes], lowerbound = 0)
@variable(sdpOPF, ζ[k in Nodes])
@variable(sdpOPF, ζsub[k in Nodes], lowerbound = 0)
@variable(sdpOPF, ζover[k in Nodes], lowerbound = 0)
@variable(sdpOPF, μ[k in Nodes])
@variable(sdpOPF, μsub[k in Nodes], lowerbound = 0)
@variable(sdpOPF, μover[k in Nodes], lowerbound = 0)
# Lagrange multiplier for line-flow limits
Hlm = Dict()
for l in Nodes
for m in Nodes
Hlm[l,m] = @variable(sdpOPF, [1:3,1:3], category = :SDP, basename="H_$l$m")
end
end
# Lagrange multiplier for the cuadratic cost functions
Rk = Dict()
for k in Nodes
Rk[k] = @variable(sdpOPF, [1:2,1:2], category = :SDP, basename="R_$k")
end
# Matrxi-valued function A. A is PSD
@variable(sdpOPF, A[1:2*N, 1:2*N], SDP)
# CONSTRAINTS
@constraint(sdpOPF, λk[k in Nodes],
λ[k] == λover[k] - λsub[k] + c[k,2] + 2*sqrt(c[k,3])*Rk[k][1,2])
@constraint(sdpOPF, ζk[k in Nodes],
ζ[k] == ζover[k] - ζsub[k])
@constraint(sdpOPF, μk[k in Nodes],
μ[k] == μover[k] - μsub[k])
# Objective function
@constraint(sdpOPF, objtest,
h == sum(λsub[k]*Pmin[k] - λover[k]*Pmax[k] + λ[k]*Pd[k]
+ ζsub[k]*Qmin[k] - ζover[k]*Qmax[k] + ζ[k]*Qd[k]
+ μsub[k]*Vmin[k]^2 - μover[k]*Vmax[k]^2 + Ω[k]*(c[k,1]-Rk[k][1,2]) for k in Nodes)
-sum(Ωlm[l,m]*((Smax[l,m]^2)*Hlm[l,m][1,1]+Hlm[l,m][2,2]+Hlm[l,m][3,3]) for l in Nodes, m in Nodes)
)
# Matrix-valued function A
@constraint(sdpOPF,
A .== sum(λ[k]*Yk[k] + ζ[k]*Yk_over[k] + μ[k]*Mk[k] for k in Nodes)
+ sum(2*Hlm[l,m][1,2]*Ylm[l,m] + 2*Hlm[l,m][1,3]*Ylm_over[l,m] for l in Nodes, m in Nodes))
# H must be Symmetric
@constraintref H_Symm[Nodes, Nodes, 1:3, 1:3]
for l in Nodes, m in Nodes, i in 1:3, j in 1:3
if i!=j
H_Symm[l,m,i,j] = @constraint(sdpOPF, Hlm[l,m][i,j] == Hlm[l,m][j,i])
end
end
# R must be Symmetric
@constraintref R_Symm[Nodes, 1:2, 1:2]
for k in Nodes, i in 1:2, j in 1:2
if i!=j
R_Symm[k,i,j] = @constraint(sdpOPF, Rk[k][i,j] == Rk[k][j,i])
end
end
# Rk[1,1] ==1
@constraintref R_11[Nodes]
for k in Nodes
R_11[k] = @constraint(sdpOPF, Rk[k][1,1] == 1)
end
@objective(sdpOPF, Max, h)
solve(sdpOPF)`