diff --git a/engine-proto/gram-test/circles-in-triangle.jl b/engine-proto/gram-test/circles-in-triangle.jl index c1f8bf2..f7248df 100644 --- a/engine-proto/gram-test/circles-in-triangle.jl +++ b/engine-proto/gram-test/circles-in-triangle.jl @@ -47,14 +47,6 @@ append!(values, fill(-0.5, 4)) =# gram = sparse(J, K, values) -# set initial guess (random) -## Random.seed!(58271) # stuck; step size collapses on step 48 -## Random.seed!(58272) # good convergence -## Random.seed!(58273) # stuck; step size collapses on step 18 -## Random.seed!(58274) # stuck -## Random.seed!(58275) # -## guess = Engine.rand_on_shell(fill(BigFloat(-1), 8)) - # set initial guess Random.seed!(58271) guess = hcat( @@ -69,39 +61,12 @@ guess = hcat( BigFloat[0, 0, 0, 0, 1] ) frozen = [CartesianIndex(j, 9) for j in 1:5] -#= -guess = hcat( - Engine.plane(BigFloat[0, 0, 1], BigFloat(0)), - Engine.sphere(BigFloat[0, 0, 0], BigFloat(0.9)), - Engine.plane(BigFloat[1, 0, 0], BigFloat(1)), - Engine.plane(BigFloat[cos(2pi/3), sin(2pi/3), 0], BigFloat(1)), - Engine.plane(BigFloat[cos(-2pi/3), sin(-2pi/3), 0], BigFloat(1)), - Engine.sphere(4//3*BigFloat[-1, 0, 0], BigFloat(1//3)), - Engine.sphere(4//3*BigFloat[cos(-pi/3), sin(-pi/3), 0], BigFloat(1//3)), - Engine.sphere(4//3*BigFloat[cos(pi/3), sin(pi/3), 0], BigFloat(1//3)), - BigFloat[0, 0, 0, 1, 1] -) -=# -# complete the gram matrix using gradient descent followed by Newton's method -#= -L, history = Engine.realize_gram_gradient(gram, guess, scaled_tol = 0.01) -L_pol, history_pol = Engine.realize_gram_newton(gram, L, rate = 0.3, scaled_tol = 1e-9) -L_pol2, history_pol2 = Engine.realize_gram_newton(gram, L_pol) -=# +# complete the gram matrix using Newton's method with backtracking L, success, history = Engine.realize_gram(gram, guess, frozen) completed_gram = L'*Engine.Q*L println("Completed Gram matrix:\n") display(completed_gram) -#= -println( - "\nSteps: ", - size(history.scaled_loss, 1), - " + ", size(history_pol.scaled_loss, 1), - " + ", size(history_pol2.scaled_loss, 1) -) -println("Loss: ", history_pol2.scaled_loss[end], "\n") -=# if success println("\nTarget accuracy achieved!") else diff --git a/engine-proto/gram-test/overlapping-pyramids.jl b/engine-proto/gram-test/overlapping-pyramids.jl index 0d1f018..c530296 100644 --- a/engine-proto/gram-test/overlapping-pyramids.jl +++ b/engine-proto/gram-test/overlapping-pyramids.jl @@ -50,19 +50,11 @@ guess = begin ) end -# complete the gram matrix -#= -L, history = Engine.realize_gram_gradient(gram, guess, scaled_tol = 0.01) -L_pol, history_pol = Engine.realize_gram_newton(gram, L) -=# +# complete the gram matrix using Newton's method with backtracking L, success, history = Engine.realize_gram(gram, guess) completed_gram = L'*Engine.Q*L println("Completed Gram matrix:\n") display(completed_gram) -#= -println("\nSteps: ", size(history.scaled_loss, 1), " + ", size(history_pol.scaled_loss, 1)) -println("Loss: ", history_pol.scaled_loss[end], "\n") -=# if success println("\nTarget accuracy achieved!") else diff --git a/engine-proto/gram-test/sphere-in-tetrahedron.jl b/engine-proto/gram-test/sphere-in-tetrahedron.jl index 631f0e5..1c36e99 100644 --- a/engine-proto/gram-test/sphere-in-tetrahedron.jl +++ b/engine-proto/gram-test/sphere-in-tetrahedron.jl @@ -53,10 +53,7 @@ guess = hcat( ) frozen = [CartesianIndex(j, 6) for j in 1:5] -# complete the gram matrix -#= -L, history = Engine.realize_gram_newton(gram, guess) -=# +# complete the gram matrix using Newton's method with backtracking L, success, history = Engine.realize_gram(gram, guess, frozen) completed_gram = L'*Engine.Q*L println("Completed Gram matrix:\n") diff --git a/engine-proto/gram-test/tetrahedron-radius-ratio.jl b/engine-proto/gram-test/tetrahedron-radius-ratio.jl index c284078..7ceb794 100644 --- a/engine-proto/gram-test/tetrahedron-radius-ratio.jl +++ b/engine-proto/gram-test/tetrahedron-radius-ratio.jl @@ -77,7 +77,7 @@ frozen = vcat( [CartesianIndex(j, 11) for j in 1:5] ) -# complete the gram matrix +# complete the gram matrix using Newton's method with backtracking L, success, history = Engine.realize_gram(gram, guess, frozen) completed_gram = L'*Engine.Q*L println("Completed Gram matrix:\n")