mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-12-26 02:30:29 +01:00
clearly separate creation of the optimization problem
This commit is contained in:
parent
d2f6682a39
commit
13bc1bef8b
18
src/SDPs.jl
18
src/SDPs.jl
@ -31,27 +31,25 @@ function spLaplacian(RG::GroupRing{R}, S, T::Type=Float64) where {R<:Ring}
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function create_SDP_problem(Δ::GroupRingElem, matrix_constraints; upper_bound=Inf)
|
function SOS_problem(X::GroupRingElem, orderunit::GroupRingElem; upper_bound=Inf)
|
||||||
N = size(parent(Δ).pm, 1)
|
N = size(parent(X).pm, 1)
|
||||||
Δ² = Δ*Δ
|
matrix_constraints = PropertyT.constraints(parent(X).pm)
|
||||||
@assert length(Δ.coeffs) == length(matrix_constraints)
|
|
||||||
m = JuMP.Model();
|
m = JuMP.Model();
|
||||||
|
|
||||||
JuMP.@variable(m, P[1:N, 1:N])
|
JuMP.@variable(m, P[1:N, 1:N])
|
||||||
JuMP.@SDconstraint(m, P >= 0)
|
JuMP.@SDconstraint(m, P >= 0)
|
||||||
JuMP.@constraint(m, sum(P[i] for i in eachindex(P)) == 0)
|
JuMP.@constraint(m, sum(P[i] for i in eachindex(P)) == 0)
|
||||||
|
|
||||||
|
JuMP.@variable(m, λ)
|
||||||
if upper_bound < Inf
|
if upper_bound < Inf
|
||||||
JuMP.@variable(m, 0.0 <= λ <= upper_bound)
|
JuMP.@constraint(m, λ <= upper_bound)
|
||||||
else
|
|
||||||
JuMP.@variable(m, λ >= 0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for (pairs, δ², δ) in zip(matrix_constraints, Δ².coeffs, Δ.coeffs)
|
for (cnstr, x, u) in zip(matrix_constraints, X.coeffs, orderunit.coeffs)
|
||||||
JuMP.@constraint(m, sum(P[i,j] for (i,j) in pairs) == δ² - λ*δ)
|
JuMP.@constraint(m, sum(P[cnstr]) == x - λ*u)
|
||||||
end
|
end
|
||||||
|
|
||||||
JuMP.@objective(m, Max, λ)
|
JuMP.@objective(m, Max, λ)
|
||||||
|
|
||||||
return m, λ, P
|
return m, λ, P
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user