Test a scale constraint

In all but a few cases (for example, a single point on a plane), we
should be able to us the radius-coradius boost symmetry to make the
average co-radius—representing the "overall scale"—roughly one.
This commit is contained in:
Aaron Fenyes 2024-02-10 14:21:52 -05:00
parent 8e33987f59
commit af1d31f6e6

View File

@ -210,13 +210,17 @@ function realize(ctx::Construction{T}) where T
[elt.rel for (_, elt) in eltenum if !isnothing(elt.rel)] [elt.rel for (_, elt) in eltenum if !isnothing(elt.rel)]
) )
# add relations to center and orient the construction # add relations to center, orient, and scale the construction
if !isempty(ctx.points) if !isempty(ctx.points)
append!(eqns, [sum(pt.coords[k] for pt in ctx.points) for k in 1:3]) append!(eqns, [sum(pt.coords[k] for pt in ctx.points) for k in 1:3])
end end
if !isempty(ctx.spheres) if !isempty(ctx.spheres)
append!(eqns, [sum(sph.coords[k] for sph in ctx.spheres) for k in 3:4]) append!(eqns, [sum(sph.coords[k] for sph in ctx.spheres) for k in 3:4])
end end
n_elts = length(ctx.points) + length(ctx.spheres)
if n_elts > 0
push!(eqns, sum(elt.vec[2] for elt in Iterators.flatten((ctx.points, ctx.spheres))) - n_elts)
end
(Generic.Ideal(coordring, eqns), eqns) (Generic.Ideal(coordring, eqns), eqns)
end end
@ -305,10 +309,14 @@ for through_trivial in [false, true]
## [verbose] display(cut_offset) ## [verbose] display(cut_offset)
cut_subspace = LinearSubspace(cut_matrix, cut_offset) cut_subspace = LinearSubspace(cut_matrix, cut_offset)
else else
cut_subspace = LinearSubspace(cut_matrix, fill(0, 3)) cut_subspace = LinearSubspace(cut_matrix, fill(0, freedom))
end end
wtns = witness_set(system, cut_subspace) wtns = witness_set(system, cut_subspace)
for soln in filter(is_nontrivial, solution.(filter(isreal, results(wtns)))) real_solns = solution.(filter(isreal, results(wtns)))
nontrivial_solns = filter(is_nontrivial, real_solns)
println("$(length(real_solns) - length(nontrivial_solns)) trivial solutions found")
for soln in nontrivial_solns
##[test] for soln in filter(is_nontrivial, solution.(filter(isreal, results(wtns))))
if all(norm2(soln - samp) > 1e-4*length(gens(coordring)) for samp in samples) if all(norm2(soln - samp) > 1e-4*length(gens(coordring)) for samp in samples)
push!(samples, soln) push!(samples, soln)
end end