|
| 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