Skip to content

Commit 5c2b619

Browse files
authored
Merge pull request #384 from SciML/sasha-sasha
Test the size of the generated systems
2 parents 60f82e4 + 49c4f25 commit 5c2b619

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

src/RationalFunctionFields/IdealMQS.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,8 @@ function fractionfree_generators_raw(mqs::IdealMQS)
194194
K = base_ring(ring_params)
195195
varnames = map(string, Nemo.symbols(ring_params))
196196
# The hope is that new variables' names would not intersect with the old ones
197-
@assert mqs.sat_var_index == length(varnames) + 1
198197
old_varnames = map(i -> "y$i", 1:length(varnames))
199-
new_varnames = map(i -> "$i", 1:(length(varnames) + 1))
198+
new_varnames = map(i -> "__var_$i", 1:(length(varnames) + 1))
200199
if !isempty(intersect(old_varnames, new_varnames))
201200
@warn "Intersection in two sets of variables! $varnames $new_varnames"
202201
end
@@ -221,7 +220,7 @@ function fractionfree_generators_raw(mqs::IdealMQS)
221220
end
222221
polys[end] = sat_y
223222
main_var_indices = 1:(length(varnames) + 1)
224-
param_var_indices = (main_var_indices + 1):length(big_vars)
223+
param_var_indices = (length(varnames) + 2):length(big_vars)
225224
return polys, main_var_indices, param_var_indices
226225
end
227226

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Test that the following pipeline works:
2+
# ODE -> IO equations -> raw identifiable functions -> RFF -> MQS -> (maybe specialize) -> ideal generators
3+
import Groebner
4+
5+
@testset "Raw Generators of RFF" begin
6+
# SIWR
7+
ode = StructuralIdentifiability.@ODEmodel(
8+
S'(t) = mu - bi * S(t) * I(t) - bw * S(t) * W(t) - mu * S(t) + a * R(t),
9+
I'(t) = bw * S(t) * W(t) + bi * S(t) * I(t) - (gam + mu) * I(t),
10+
W'(t) = xi * (I(t) - W(t)),
11+
R'(t) = gam * I(t) - (mu + a) * R(t),
12+
y(t) = k * I(t)
13+
)
14+
15+
io_eqs = StructuralIdentifiability.find_ioequations(ode)
16+
id_funcs, bring = StructuralIdentifiability.extract_identifiable_functions_raw(
17+
io_eqs,
18+
ode,
19+
empty(ode.parameters),
20+
true,
21+
)
22+
23+
param_ring, _ = polynomial_ring(
24+
base_ring(bring),
25+
map(string, ode.parameters),
26+
internal_ordering = Nemo.internal_ordering(bring),
27+
)
28+
29+
id_funcs_no_states = map(
30+
polys -> map(
31+
poly -> StructuralIdentifiability.parent_ring_change(poly, param_ring),
32+
polys,
33+
),
34+
id_funcs[:no_states],
35+
)
36+
37+
rff = StructuralIdentifiability.RationalFunctionField(id_funcs_no_states)
38+
39+
# Part 1: mod p and specialized
40+
p = Nemo.Native.GF(2^62 + 135)
41+
StructuralIdentifiability.ParamPunPam.reduce_mod_p!(rff.mqs, p)
42+
point = rand(
43+
p,
44+
length(Nemo.gens(StructuralIdentifiability.ParamPunPam.parent_params(rff.mqs))),
45+
)
46+
eqs = StructuralIdentifiability.ParamPunPam.specialize_mod_p(rff.mqs, point)
47+
gb = Groebner.groebner(eqs, ordering = Groebner.DegRevLex())
48+
# GB is linear
49+
@test length(gb) == length(gens(parent(eqs[1])))
50+
expected = 10e6
51+
str = join(map(string, eqs), ",")
52+
@info "" length(str)
53+
@test abs(length(str) - expected) / expected * 100 < 5
54+
55+
# Part 2: over Q
56+
eqs = StructuralIdentifiability.fractionfree_generators_raw(rff.mqs)[1]
57+
expected = 26e6
58+
str = join(map(string, eqs), ",")
59+
@info "" length(str)
60+
@test abs(length(str) - expected) / expected * 100 < 5
61+
end

0 commit comments

Comments
 (0)