14
14
# ------------------------------------------------------------------------------
15
15
16
16
"""
17
- linear_compartment_model(graph, inputs, outputs, leaks)
17
+ linear_compartment_model(graph; inputs = [] , outputs = [] , leaks = [] )
18
18
19
19
Input: defines a linear compartment model with nodes numbered from 1 to `n` by
20
20
- `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
23
23
- `leaks` - array of sink nodes
24
24
25
25
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
+ ```
27
43
"""
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 = [])
34
45
n = length (graph)
35
46
x_vars_names = [" x$i " for i in 1 : n]
36
47
y_vars_names = [" y$i " for i in outputs]
0 commit comments