Skip to content

Commit

Permalink
update readme, format benchmark dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasha Demin committed Sep 17, 2024
1 parent 3649358 commit 249dab4
Show file tree
Hide file tree
Showing 30 changed files with 188 additions and 718 deletions.
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,13 @@ It works with polynomials from AbstractAlgebra.jl, DynamicPolynomials.jl, and Ne

### with AbstractAlgebra.jl

We create a ring of polynomials in 3 variables
We create a ring of polynomials in 3 variables and a simple polynomial system

```julia
using AbstractAlgebra

R, (x1, x2, x3) = QQ["x1", "x2", "x3"]
```

Then, we can define a simple polynomial system

```julia
system = [
x1 + x2 + x3,
x1*x2 + x1*x3 + x2*x3,
Expand All @@ -66,9 +62,9 @@ G = groebner(system)
```julia
# result
3-element Vector{AbstractAlgebra.Generic.MPoly{Rational{BigInt}}}:
x1 + x2 + x3
x2^2 + x2*x3 + x3^2
x3^3 - 1
x2^2 + x2*x3 + x3^2
x1 + x2 + x3
```

### with DynamicPolynomials.jl
Expand All @@ -86,10 +82,10 @@ G = groebner(system)
```
```julia
# result
3-element Vector{Polynomial{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, Graded{LexOrder}, Int64}}:
10x2 - 10x1 - 11x2² + 11x1²
110 - 121x2 - 100x2² + 100x1x2 + 110x2³
10 - 11x1 + 10x1x2²
3-element Vector{Polynomial{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, Graded{LexOrder}, Rational{BigInt}}}:
10//11x2 - 10//11x1 - x2² + x1²
1//1 - 11//10x2 - 10//11x2² + 10//11x1x2 + x2³
1//1 - 11//10x1 + x1x2²
```

## Contacts
Expand Down
35 changes: 7 additions & 28 deletions benchmark/CI-scripts/run_benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ push!(
(
problem_name="groebner,AA,2^30+3,yang1",
type=:time,
result=compute_gb(
Groebner.Examples.yang1(internal_ordering=:degrevlex, k=GF(2^30 + 3)),
2
)
result=compute_gb(Groebner.Examples.yang1(internal_ordering=:degrevlex, k=GF(2^30 + 3)), 2)
)
)
push!(
Expand Down Expand Up @@ -148,11 +145,7 @@ push!(
result=[
sum(
compute_gb(
Groebner.Examples.cyclicn(
6,
internal_ordering=:degrevlex,
k=GF(2^30 + 3)
),
Groebner.Examples.cyclicn(6, internal_ordering=:degrevlex, k=GF(2^30 + 3)),
2000
)
)
Expand All @@ -165,12 +158,7 @@ push!(
problem_name="groebner,AA,QQ,100xchandra 7",
type=:time,
result=[
sum(
compute_gb(
Groebner.Examples.chandran(7, internal_ordering=:degrevlex, k=QQ),
100
)
)
sum(compute_gb(Groebner.Examples.chandran(7, internal_ordering=:degrevlex, k=QQ), 100))
]
)
)
Expand Down Expand Up @@ -221,9 +209,7 @@ push!(
(
problem_name="groebner,AA,100 vars drl",
type=:time,
result=compute_gb(
n_variable_set(100, internal_ordering=:degrevlex, k=GF(2^31 - 1))
)
result=compute_gb(n_variable_set(100, internal_ordering=:degrevlex, k=GF(2^31 - 1)))
)
)

Expand Down Expand Up @@ -343,19 +329,15 @@ push!(
(
problem_name="groebner,AA,QQ,katsura 8",
type=:time,
result=compute_gb(
Groebner.Examples.katsuran(8, internal_ordering=:degrevlex, k=QQ)
)
result=compute_gb(Groebner.Examples.katsuran(8, internal_ordering=:degrevlex, k=QQ))
)
)
push!(
suite,
(
problem_name="groebner,Nemo,QQ,katsura 8",
type=:time,
result=compute_gb(
Groebner.Examples.katsuran(8, internal_ordering=:degrevlex, k=Nemo.QQ)
)
result=compute_gb(Groebner.Examples.katsuran(8, internal_ordering=:degrevlex, k=Nemo.QQ))
)
)
push!(
Expand All @@ -379,10 +361,7 @@ push!(
(
problem_name="groebner,AA,QQ,noon 8",
type=:time,
result=compute_gb(
Groebner.Examples.noonn(8, internal_ordering=:degrevlex, k=QQ),
3
)
result=compute_gb(Groebner.Examples.noonn(8, internal_ordering=:degrevlex, k=QQ), 3)
)
)
push!(
Expand Down
28 changes: 6 additions & 22 deletions benchmark/benchmark_systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,9 @@ function benchmark_set_1()
("NFkB (w.)", NFkB_with_weights(k=ground_field)),
("Goodwin (w.)", Goodwin_with_weights(k=ground_field)),
("yang1", Groebner.Examples.yang1(internal_ordering=:degrevlex, k=ground_field)),
(
"bayes148",
Groebner.Examples.bayes148(internal_ordering=:degrevlex, k=ground_field)
),
(
"gametwo2",
Groebner.Examples.gametwo2(internal_ordering=:degrevlex, k=ground_field)
),
(
"jason210",
Groebner.Examples.jason210(internal_ordering=:degrevlex, k=ground_field)
),
("bayes148", Groebner.Examples.bayes148(internal_ordering=:degrevlex, k=ground_field)),
("gametwo2", Groebner.Examples.gametwo2(internal_ordering=:degrevlex, k=ground_field)),
("jason210", Groebner.Examples.jason210(internal_ordering=:degrevlex, k=ground_field)),
("alea6", Groebner.Examples.alea6(internal_ordering=:degrevlex, k=ground_field)),
("mayr42", Groebner.Examples.mayr42(internal_ordering=:degrevlex, k=ground_field)),
("BIOMD0000000103", BIOMD0000000103(k=ground_field)),
Expand Down Expand Up @@ -150,10 +141,7 @@ function benchmark_set_3()
("reimer 6", Groebner.Examples.reimern(6, k=ground_field)),
("reimer 7", Groebner.Examples.reimern(7, k=ground_field)),
("reimer 8", Groebner.Examples.reimern(8, k=ground_field)),
(
"chandra 9",
Groebner.Examples.chandran(9, k=ground_field, internal_ordering=:degrevlex)
),
("chandra 9", Groebner.Examples.chandran(9, k=ground_field, internal_ordering=:degrevlex)),
(
"chandra 10",
Groebner.Examples.chandran(10, k=ground_field, internal_ordering=:degrevlex)
Expand All @@ -170,10 +158,7 @@ function benchmark_set_3()
"chandra 13",
Groebner.Examples.chandran(13, k=ground_field, internal_ordering=:degrevlex)
),
(
"ipp",
Groebner.Examples.ipp(k=ground_field, tol=0.0, internal_ordering=:degrevlex)
)
("ipp", Groebner.Examples.ipp(k=ground_field, tol=0.0, internal_ordering=:degrevlex))
]

(name="The rationals", field=ground_field, systems=systems)
Expand Down Expand Up @@ -253,8 +238,7 @@ end

function benchmark_set_9()
ground_field = AbstractAlgebra.QQ
systems =
[("BIOMD0000000103", BIOMD0000000103()), ("BIOMD0000000123", BIOMD0000000123())]
systems = [("BIOMD0000000103", BIOMD0000000103()), ("BIOMD0000000123", BIOMD0000000123())]
(name="BIOMD, the rationals", field=ground_field, systems=systems)
end

Expand Down
79 changes: 11 additions & 68 deletions benchmark/generate/benchmark_generators.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@

function generate_benchmark_source_for_groebner(
name,
system,
dir,
validate,
nruns,
time_filename
)
function generate_benchmark_source_for_groebner(name, system, dir, validate, nruns, time_filename)
ring = parent(system[1])
field = base_ring(ring)
vars_repr = join(map(string, gens(ring)), ", ")
Expand All @@ -33,32 +26,11 @@ function generate_benchmark_source_for_groebner(
String(take!(buf))
end

function generate_benchmark_source_for_singular(
name,
system,
dir,
validate,
nruns,
time_filename
)
generate_benchmark_source_for_groebner(
name,
system,
dir,
validate,
nruns,
time_filename
)
function generate_benchmark_source_for_singular(name, system, dir, validate, nruns, time_filename)
generate_benchmark_source_for_groebner(name, system, dir, validate, nruns, time_filename)
end

function generate_benchmark_source_for_maplefgb(
name,
system,
dir,
validate,
nruns,
time_filename
)
function generate_benchmark_source_for_maplefgb(name, system, dir, validate, nruns, time_filename)
ring = parent(system[1])
field = base_ring(ring)
buf = IOBuffer()
Expand All @@ -84,10 +56,7 @@ function generate_benchmark_source_for_maplefgb(
println(buf, "")
println(buf, "timings_fn := \"$time_filename\":")
println(buf, "FileTools[Text][WriteLine](timings_fn, \"$name\");")
println(
buf,
"FileTools[Text][WriteLine](timings_fn, cat(\"total_time, \", String(runtime))):"
)
println(buf, "FileTools[Text][WriteLine](timings_fn, cat(\"total_time, \", String(runtime))):")
if validate
println(buf)
output_fn = output_filename()
Expand All @@ -106,14 +75,7 @@ function generate_benchmark_source_for_maplefgb(
String(take!(buf))
end

function generate_benchmark_source_for_mgb(
name,
system,
dir,
validate,
nruns,
time_filename
)
function generate_benchmark_source_for_mgb(name, system, dir, validate, nruns, time_filename)
ring = parent(system[1])
field = base_ring(ring)
buf = IOBuffer()
Expand All @@ -136,10 +98,7 @@ function generate_benchmark_source_for_mgb(
println(buf, "")
println(buf, "timings_fn := \"$time_filename\":")
println(buf, "FileTools[Text][WriteLine](timings_fn, \"$name\");")
println(
buf,
"FileTools[Text][WriteLine](timings_fn, cat(\"total_time, \", String(runtime))):"
)
println(buf, "FileTools[Text][WriteLine](timings_fn, cat(\"total_time, \", String(runtime))):")
if validate
println(buf)
output_fn = output_filename()
Expand All @@ -158,14 +117,7 @@ function generate_benchmark_source_for_mgb(
String(take!(buf))
end

function generate_benchmark_source_for_msolve(
name,
system,
dir,
validate,
nruns,
time_filename
)
function generate_benchmark_source_for_msolve(name, system, dir, validate, nruns, time_filename)
ring = parent(system[1])
field = base_ring(ring)
vars_repr = join(map(string, gens(ring)), ", ")
Expand All @@ -177,14 +129,7 @@ function generate_benchmark_source_for_msolve(
String(take!(buf))
end

function generate_benchmark_source_for_openf4(
name,
system,
dir,
validate,
nruns,
time_filename
)
function generate_benchmark_source_for_openf4(name, system, dir, validate, nruns, time_filename)
ring = parent(system[1])
field = base_ring(ring)
buf = IOBuffer()
Expand All @@ -203,10 +148,8 @@ function generate_benchmark_source_for_openf4(
{
"""
)
vars_repr =
join(map(s -> "\tvariableName.push_back(\"$s\");", map(repr, gens(ring))), "\n")
system_repr =
join(map(s -> "\tpolynomialArray.emplace_back(\"$s\");", map(repr, system)), "\n")
vars_repr = join(map(s -> "\tvariableName.push_back(\"$s\");", map(repr, gens(ring))), "\n")
system_repr = join(map(s -> "\tpolynomialArray.emplace_back(\"$s\");", map(repr, system)), "\n")
println(
buf,
"""
Expand Down
6 changes: 2 additions & 4 deletions benchmark/generate/benchmark_systems/SI/SI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ include((@__DIR__) * "/parser.jl")
function load_SI_problem(name; k=AbstractAlgebra.QQ)
if name == "SIWR"
sys = read_SIWR(k=k)[2]
@assert AbstractAlgebra.internal_ordering(AbstractAlgebra.parent(sys[1])) ==
:degrevlex
@assert AbstractAlgebra.internal_ordering(AbstractAlgebra.parent(sys[1])) == :degrevlex
return sys
elseif name == "SEAIJRC"
sys = read_SEAIJRC(k=k)[2]
@assert AbstractAlgebra.internal_ordering(AbstractAlgebra.parent(sys[1])) ==
:degrevlex
@assert AbstractAlgebra.internal_ordering(AbstractAlgebra.parent(sys[1])) == :degrevlex
return sys
else
throw("Beda beda ogorchenie")
Expand Down
13 changes: 4 additions & 9 deletions benchmark/generate/benchmark_systems/biomodels/BIOMD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ function BIOMD0000000123(; k=AbstractAlgebra.QQ, internal_ordering=:degrevlex)
2 // k(78125) * x5 +
21 // k(12500) * x6 +
807 // k(226000) * x9,
x1^3 * x8 - 663 // k(100) * x3 * x4 - 663 // k(100) * x4 * x5 -
25023 // k(25000) * x4 +
x1^3 * x8 - 663 // k(100) * x3 * x4 - 663 // k(100) * x4 * x5 - 25023 // k(25000) * x4 +
21 // k(12500) * x6 +
21 // k(12500) * x7 +
5111 // k(1130000) * x10,
8 // k(3125) * x3 - 663 // k(100) * x4 * x5 - 78129 // k(156250) * x5 +
21 // k(12500) * x7 +
269 // k(22600) * x11,
663 // k(100) * x3 * x4 - 231 // k(25000) * x6 +
1 // k(2) * x7 +
269 // k(226) * x12,
663 // k(100) * x3 * x4 - 231 // k(25000) * x6 + 1 // k(2) * x7 + 269 // k(226) * x12,
663 // k(100) * x4 * x5 + 8 // k(3125) * x6 - 12521 // k(12500) * x7 +
269 // k(22600) * x13,
-x1^3 * x8 + x4 - 23 // k(25000) * x8 + 5111 // k(1130000) * x14,
Expand All @@ -37,8 +34,7 @@ function BIOMD0000000123(; k=AbstractAlgebra.QQ, internal_ordering=:degrevlex)
21 // k(12500) * x13,
113 // k(538) * x5 + 8 // k(3125) * x9 - 663 // k(100) * x10 * x11 -
3141 // k(625000) * x11 + 21 // k(12500) * x13,
113 // k(53800) * x6 + 663 // k(100) * x9 * x10 - 6303 // k(12500) * x12 +
1 // k(2) * x13,
113 // k(53800) * x6 + 663 // k(100) * x9 * x10 - 6303 // k(12500) * x12 + 1 // k(2) * x13,
113 // k(538) * x7 + 663 // k(100) * x10 * x11 + 8 // k(3125) * x12 -
12667 // k(25000) * x13,
-x2^3 * x14 + 2599 // k(6725000) * x8 + x10 - 19 // k(10000) * x14
Expand Down Expand Up @@ -102,8 +98,7 @@ function BIOMD0000000103(; k=AbstractAlgebra.QQ, internal_ordering=:degrevlex)
1 // k(500) * x1 * x3 + 1 // k(1000) * x4 * x6 - 3 // k(1000) * x5 * x8 -
51 // k(500) * x5 + 1 // k(1000) * x15,
1 // k(500) * x1 * x2 - 1 // k(1000) * x4 * x6 + 1 // k(1000) * x5 -
1 // k(5000) * x6 * x8 - 1 // k(1000) * x6 * x9 - 101 // k(1000) * x6 +
1 // k(1000) * x15,
1 // k(5000) * x6 * x8 - 1 // k(1000) * x6 * x9 - 101 // k(1000) * x6 + 1 // k(1000) * x15,
-1 // k(200000) * x2 * x7 - 7 // k(20000) * x6 * x7 - 1 // k(20000) * x7 * x11 -
7 // k(2000) * x7 * x12 - 1 // k(1000) * x7 + 1 // k(5),
1 // k(200000) * x2 * x7 - 3 // k(1000) * x3 * x8 - 3 // k(1000) * x4 * x8 -
Expand Down
4 changes: 1 addition & 3 deletions benchmark/generate/benchmark_systems/biomodels/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ function read_BIOMDs(nspecies)

symvs = map(x -> Symbol(x), vs)
expvs = Meta.parse(join(symvs, ","))
R, xs = eval(
:((R, $expvs) = AbstractAlgebra.polynomial_ring(AbstractAlgebra.QQ, $symvs))
)
R, xs = eval(:((R, $expvs) = AbstractAlgebra.polynomial_ring(AbstractAlgebra.QQ, $symvs)))

for p in params
p = eval(Meta.parse(p))
Expand Down
Loading

0 comments on commit 249dab4

Please sign in to comment.