This commit is contained in:
Marek Kaluba 2024-02-27 17:17:29 +00:00 committed by GitHub
commit 1fcca1bfde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 170 additions and 6 deletions

View File

@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised
julia_version = "1.10.0"
julia_version = "1.10.1"
manifest_format = "2.0"
project_hash = "b435980f07b6de69a5d6ab1d537b9adb4a603bdd"
project_hash = "7b0e0c798d016406da5e7a51aaec57e29f93bbb7"
[[deps.AMD]]
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse_jll"]
@ -99,7 +99,7 @@ weakdeps = ["Dates", "LinearAlgebra"]
[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.0.5+1"
version = "1.1.0+0"
[[deps.Conda]]
deps = ["Downloads", "JSON", "VersionParsing"]
@ -418,7 +418,7 @@ version = "0.3.24+0"
[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.23+2"
version = "0.3.23+4"
[[deps.OpenLibm_jll]]
deps = ["Artifacts", "Libdl"]

162
scripts/PRA_has_T.jl Normal file
View File

@ -0,0 +1,162 @@
using LinearAlgebra
BLAS.set_num_threads(4)
ENV["OMP_NUM_THREADS"] = 4
include(joinpath(@__DIR__, "../test/optimizers.jl"))
using SCS_MKL_jll
using Groups
import Groups.MatrixGroups
using PropertyT
import PropertyT.SW as SW
using PropertyT.PG
using PropertyT.SA
include(joinpath(@__DIR__, "argparse.jl"))
const N = parsed_args["N"]
const HALFRADIUS = parsed_args["halfradius"]
const UPPER_BOUND = parsed_args["upper_bound"]
# fixes/hacks
import Groups.KnuthBendix
KnuthBendix.ordering(o::KnuthBendix.WordOrdering) = o
function KnuthBendix.rewrite!(
u::KnuthBendix.AbstractWord,
w::KnuthBendix.AbstractWord,
o::KnuthBendix.WordOrdering,
)
return KnuthBendix.rewrite!(u, w, KnuthBendix.alphabet(o))
end
struct Letter{T} <: Groups.GSymbol # letter of an Alphabet
elt::T
end
Base.show(io::IO, tt::Letter) = show(io, tt.elt)
Base.inv(tt::Letter) = Letter(inv(tt.elt))
Base.:(==)(tt::Letter, ss::Letter) = tt.elt == ss.elt
Base.hash(tt::Letter, h::UInt) = hash(tt.elt, hash(Letter, h))
Base.Base.@propagate_inbounds function Groups.evaluate!(
v::Tuple{Vararg{T,N}},
tt::Letter,
tmp = one(first(v)),
) where {T,N}
return Groups.evaluate!(v, tt.elt, tmp)
end
function PropertyT._conj(tt::Letter, g)
G = parent(tt.elt)
A = alphabet(G)
w = [A[PropertyT._conj(A[l], g)] for l in word(tt.elt)]
return Letter(G(w))
end
G = let G = SpecialAutomorphismGroup(FreeGroup(N + 1))
A = alphabet(G)
lambdas = [Groups.λ(1, i) for i in 2:N+1]
append!(lambdas, [Groups.λ(i, 1) for i in 2:N+1])
rhos = [Groups.ϱ(1, i) for i in 2:N+1]
append!(rhos, [Groups.ϱ(i, 1) for i in 2:N+1])
_alph = eltype(G)[]
for i in 2:N+1
for j in 2:N+1
i == j && continue
g = G([A[Groups.ϱ(1, i)], A[Groups.ϱ(j, 1)]])
h = G([A[Groups.λ(1, i)], A[Groups.λ(j, 1)]])
push!(_alph, g, h)
end
end
alph = Letter.(_alph)
AutomorphismGroup(
FreeGroup(N + 1),
alph,
KnuthBendix.LenLex(Groups.Alphabet(alph)),
Groups.domain(one(G)),
)
end
# @info "Running Δ² - λ·Δ sum of squares decomposition for " G
@info "computing group algebra structure"
RG, S, sizes = @time PropertyT.group_algebra(G, halfradius = HALFRADIUS)
@info "computing WedderburnDecomposition"
wd = let RG = RG, N = N
G = StarAlgebras.object(RG)
P = PermGroup(perm"(2,3)", Perm([1; 1 .+ circshift(1:N, -1)]))
Σ = Groups.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P)
act = PropertyT.action_by_conjugation(G, P)
wdfl = @time SW.WedderburnDecomposition(
Float64,
P,
act,
basis(RG),
StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[HALFRADIUS]]),
)
end
@info wd
Δ = RG(length(S)) - sum(RG(s) for s in S)
elt = Δ^2;
unit = Δ;
warm = nothing
@info "defining optimization problem"
@time model, varP = PropertyT.sos_problem_primal(
elt,
unit,
wd;
upper_bound = UPPER_BOUND,
augmented = true,
show_progress = true,
)
let status = JuMP.OPTIMIZE_NOT_CALLED, warm = warm, eps = 1e-10
certified, λ = false, 0.0
while status JuMP.OPTIMAL
@time status, warm = PropertyT.solve(
model,
scs_optimizer(;
linear_solver = SCS.MKLDirectSolver,
eps = eps,
max_iters = N * 10_000,
accel = 50,
alpha = 1.95,
),
warm,
)
@info "reconstructing the solution"
Q = @time let wd = wd, Ps = [JuMP.value.(P) for P in varP], eps = 1e-10
PropertyT.__droptol!.(Ps, 100eps)
Qs = real.(sqrt.(Ps))
PropertyT.__droptol!.(Qs, eps)
PropertyT.reconstruct(Qs, wd)
end
@info "certifying the solution"
certified, λ = PropertyT.certify_solution(
elt,
unit,
JuMP.objective_value(model),
Q;
halfradius = HALFRADIUS,
augmented = true,
)
end
if certified && λ > 0
Κ(λ, S) = round(sqrt(2λ / length(S)), Base.RoundDown; digits = 5)
@info "Certified result: $G has property (T):" N λ Κ(λ, S)
else
@info "Could NOT certify the result:" certified λ
end
end

View File

@ -3,6 +3,7 @@ ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
COSMO = "1e616198-aa4e-51ec-90a2-23f7fbd31d8d"
Groups = "5d8bd718-bd84-11e8-3b40-ad14f4a32557"
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
PermutationGroups = "8bc5a954-2dfc-11e9-10e6-cd969bffa420"
PropertyT = "03b72c93-0167-51e2-8a1e-eb4ff1fb940d"

View File

@ -177,16 +177,17 @@ function _constraints(
)
cnstrs = [signed(eltype(mstr))[] for _ in 1:num_constraints]
LI = LinearIndices(size(mstr))
star_of = [mstr.basis[SA.star(mstr.basis[i])] for i in 1:size(mstr, 1)]
for ci in CartesianIndices(size(mstr))
k = LI[ci]
i, j = Tuple(ci)
a_star_b = mstr[-i, j]
a_star_b = mstr[star_of[i], j]
push!(cnstrs[a_star_b], k)
if augmented
# (1-a)'(1-b) = 1 - a' - b + a'b
push!(cnstrs[id], k)
a_star, b = mstr[-i, id], j
a_star, b = mstr[star_of[i], id], j
push!(cnstrs[a_star], -k)
push!(cnstrs[b], -k)
end