2024-07-07 17:58:55 -07:00
|
|
|
include("Engine.jl")
|
|
|
|
|
|
|
|
using SparseArrays
|
2024-07-08 14:19:05 -07:00
|
|
|
using Random
|
2024-07-07 17:58:55 -07:00
|
|
|
|
|
|
|
# initialize the partial gram matrix for a sphere inscribed in a regular
|
|
|
|
# tetrahedron
|
|
|
|
J = Int64[]
|
|
|
|
K = Int64[]
|
|
|
|
values = BigFloat[]
|
2024-07-15 23:54:59 -07:00
|
|
|
for j in 1:6
|
|
|
|
for k in 1:6
|
|
|
|
filled = false
|
|
|
|
if j == 6
|
|
|
|
if k <= 4
|
|
|
|
push!(values, 0)
|
|
|
|
filled = true
|
|
|
|
end
|
|
|
|
elseif k == 6
|
|
|
|
if j <= 4
|
|
|
|
push!(values, 0)
|
|
|
|
filled = true
|
|
|
|
end
|
|
|
|
elseif j == k
|
2024-07-07 17:58:55 -07:00
|
|
|
push!(values, 1)
|
2024-07-15 23:54:59 -07:00
|
|
|
filled = true
|
2024-07-07 17:58:55 -07:00
|
|
|
elseif (j <= 4 && k <= 4)
|
|
|
|
push!(values, -1/BigFloat(3))
|
2024-07-15 23:54:59 -07:00
|
|
|
filled = true
|
2024-07-07 17:58:55 -07:00
|
|
|
else
|
|
|
|
push!(values, -1)
|
2024-07-15 23:54:59 -07:00
|
|
|
filled = true
|
|
|
|
end
|
|
|
|
if filled
|
|
|
|
push!(J, j)
|
|
|
|
push!(K, k)
|
2024-07-07 17:58:55 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
gram = sparse(J, K, values)
|
|
|
|
|
|
|
|
# set initial guess
|
|
|
|
Random.seed!(99230)
|
2024-07-17 14:30:43 -07:00
|
|
|
guess = Engine.nullmix * hcat(
|
2024-07-15 23:54:59 -07:00
|
|
|
sqrt(1/BigFloat(3)) * BigFloat[
|
|
|
|
1 1 -1 -1 0
|
|
|
|
1 -1 1 -1 0
|
|
|
|
1 -1 -1 1 0
|
|
|
|
1 1 1 1 -2
|
|
|
|
1 1 1 1 1
|
|
|
|
] + 0.2*Engine.rand_on_shell(fill(BigFloat(-1), 5)),
|
|
|
|
BigFloat[0, 0, 0, 1, 1]
|
|
|
|
)
|
|
|
|
frozen = [CartesianIndex(j, 6) for j in 1:5]
|
2024-07-07 17:58:55 -07:00
|
|
|
|
2024-07-15 11:32:04 -07:00
|
|
|
# complete the gram matrix
|
|
|
|
#=
|
2024-07-11 13:43:52 -07:00
|
|
|
L, history = Engine.realize_gram_newton(gram, guess)
|
2024-07-15 11:32:04 -07:00
|
|
|
=#
|
2024-07-15 23:54:59 -07:00
|
|
|
L, success, history = Engine.realize_gram(gram, guess, frozen)
|
2024-07-07 17:58:55 -07:00
|
|
|
completed_gram = L'*Engine.Q*L
|
|
|
|
println("Completed Gram matrix:\n")
|
|
|
|
display(completed_gram)
|
2024-07-15 13:15:15 -07:00
|
|
|
if success
|
|
|
|
println("\nTarget accuracy achieved!")
|
|
|
|
else
|
|
|
|
println("\nFailed to reach target accuracy")
|
|
|
|
end
|
|
|
|
println("Steps: ", size(history.scaled_loss, 1))
|
2024-07-07 17:58:55 -07:00
|
|
|
println("Loss: ", history.scaled_loss[end], "\n")
|