JuliaHomotopyContinuation / HomotopyContinuation.jl

A Julia package for solving systems of polynomials via homotopy continuation.
https://www.JuliaHomotopyContinuation.org
MIT License
181 stars 30 forks source link

Add support for SemialgebraicSets.jl #445

Closed saschatimme closed 3 years ago

saschatimme commented 3 years ago

Finally(!) addresses #20.

Basic support:

julia> using HomotopyContinuation, SemialgebraicSets;

julia> solver = SemialgebraicSetsHCSolver(; compile = false) # possible to pass any solve option
SemialgebraicSetsHCSolver(; compile = false)

julia> @polyvar x y
(x, y)

julia> V = @set x^2 == 1 && y^2 == 2 solver
Algebraic Set defined by 2 equalities
 x^2 - 1.0 = 0
 y^2 - 2.0 = 0

julia> collect(V)
4-element Array{Array{Float64,1},1}:
 [1.0, 1.414213562373095]
 [1.0, -1.414213562373095]
 [-1.0, 1.414213562373095]
 [-1.0, -1.414213562373095]

There is now also a direct System constructor from an AbstractAlgebraicSet:

julia> V = @set x^2 == 1 && y^2 == 2
Algebraic Set defined by 2 equalities
 x^2 - 1.0 = 0
 y^2 - 2.0 = 0

julia> System(V; variables= [y, x])
System of length 2
 2 variables: y, x

 -1.0 + 1.0*x^2
 -2.0 + 1.0*y^2

@blegat Is this how you imagined it?

saschatimme commented 3 years ago

One question: I was wondering whether we should set the compile option to false by default here. Otherwise every system will trigger compilation. This obviously depends on the use case. Is this used to solve many small systems? Or can these also be larger?

blegat commented 3 years ago

Is this used to solve many small systems? Or can these also be larger?

That's a good point, it is indeed sometimes used to solve many small systems so compilation might be off by default.

saschatimme commented 3 years ago

Okay, I disabled the compilation by default