Skip to content

Commit ef889ab

Browse files
authored
Merge pull request #390 from SciML/lincomp_revision
Lincomp revision
2 parents 4349381 + 6857cdc commit ef889ab

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/lincomp.jl

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#------------------------------------------------------------------------------
1515

1616
"""
17-
linear_compartment_model(graph, inputs, outputs, leaks)
17+
linear_compartment_model(graph; inputs = [], outputs = [], leaks = [])
1818
1919
Input: defines a linear compartment model with nodes numbered from 1 to `n` by
2020
- `graph` - and array of integer arrays representing the adjacency lists of the graph
@@ -23,14 +23,25 @@ Input: defines a linear compartment model with nodes numbered from 1 to `n` by
2323
- `leaks` - array of sink nodes
2424
2525
Output:
26-
- the corresponding ODE system in the notation of https://doi.org/10.1007/s11538-015-0098-0
26+
- the corresponding ODE system in a standard notation (as, e.g., in [this paper](https://doi.org/10.1007/s11538-015-0098-0))
27+
28+
Example: Consider a bidirected cycle with four nodes. Its adjacency list can be written as follows:
29+
```
30+
[ [2, 4], [1, 3], [2, 4], [1, 3] ]
31+
```
32+
In the list above, the `i`-th element is a list of vertices to which there exists an edge
33+
from the vertex `i`. Now we can create a linear compartment model over this graph with
34+
the output at vertex 1, input at vertex 2, and leaks at vertices 3 and 4 as follows:
35+
```jldoctest
36+
julia> ode = linear_compartment_model([[2, 4], [1, 3], [2, 4], [1, 3]], outputs = [1], inputs = [2], leaks = [2, 3])
37+
x1' = -x1*a_2_1 - x1*a_4_1 + x2*a_1_2 + x4*a_1_4
38+
x3' = x2*a_3_2 - x3*a_2_3 - x3*a_4_3 - x3*a_0_3 + x4*a_3_4
39+
x2' = x1*a_2_1 - x2*a_1_2 - x2*a_3_2 - x2*a_0_2 + x3*a_2_3 + u2
40+
x4' = x1*a_4_1 + x3*a_4_3 - x4*a_1_4 - x4*a_3_4
41+
y1 = x1
42+
```
2743
"""
28-
function linear_compartment_model(
29-
graph::Vector{Vector{Int}},
30-
inputs::Vector{Int},
31-
outputs::Vector{Int},
32-
leaks::Vector{Int},
33-
)
44+
function linear_compartment_model(graph; inputs = [], outputs = [], leaks = [])
3445
n = length(graph)
3546
x_vars_names = ["x$i" for i in 1:n]
3647
y_vars_names = ["y$i" for i in outputs]

test/linear_compartment.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@
152152
for case in test_cases
153153
ode = linear_compartment_model(
154154
case[:graph],
155-
case[:inputs],
156-
case[:outputs],
157-
case[:leaks],
155+
inputs = case[:inputs],
156+
outputs = case[:outputs],
157+
leaks = case[:leaks],
158158
)
159159
bring = ode.poly_ring
160160
correct = Dict{QQMPolyRingElem, Symbol}()

0 commit comments

Comments
 (0)