@@ -62,23 +62,16 @@ is `construct(T::AbstractMultiScaleArray, nodes, values)`, though if `values` is
62
62
taken to be empty.
63
63
64
64
``` julia
65
- population = construct (Population, deepcopy ([cell1, cell2])) # Make a Population from cells
66
65
cell3 = Cell ([3.0 ; 2.0 ; 5.0 ])
67
66
cell4 = Cell ([4.0 ; 6.0 ])
68
- population2 = construct (Population, deepcopy ([cell3, cell4]))
69
- tissue1 = construct (Tissue, deepcopy ([population, population2])) # Make a Tissue from Populations
70
- tissue2 = construct (Tissue, deepcopy ([population2, population]))
67
+ population2 = construct (Population, deepcopy ([cell1, cell3, cell4]))
68
+ population3 = construct (Population, deepcopy ([cell1, cell3, cell4]))
69
+ tissue1 = construct (Tissue, deepcopy ([population, population2, population3])) # Make a Tissue from Populations
70
+ tissue2 = construct (Tissue, deepcopy ([population2, population, population3]))
71
71
embryo = construct (Embryo, deepcopy ([tissue1, tissue2])) # Make an embryo from Tissues
72
72
```
73
73
74
- Note that tuples can be used as well. This allows for type-stable indexing with
75
- heterogeneous nodes. For example:
76
-
77
- ``` julia
78
- tissue1 = construct (Tissue, deepcopy ((population, cell3)))
79
- ```
80
-
81
- (of course at the cost of mutability).
74
+ ## Indexing and Iteration
82
75
83
76
The head node then acts as the king. It is designed to have functionality which
84
77
mimics a vector in order for usage in DifferentialEquations or Optim. So for example
@@ -142,6 +135,53 @@ remove_node!(embryo, 2, 1) # Removes population 1 from tissue 2 of the embryo
142
135
Combined with event handling, this allows for dynamic structures to be derived from
143
136
low level behaviors.
144
137
138
+ ## Heterogeneous Nodes via Tuples
139
+
140
+ Note that tuples can be used as well. This allows for type-stable broadcasting with
141
+ heterogeneous nodes. This could be useful for mixing types
142
+ inside of the nodes. For example:
143
+
144
+ ``` julia
145
+ struct PlantSettings{T} x:: T end
146
+ struct OrganParams{T} y:: T end
147
+
148
+ struct Organ{B<: Number ,P} <: AbstractMultiScaleArrayLeaf{B}
149
+ values:: Vector{B}
150
+ name:: Symbol
151
+ params:: P
152
+ end
153
+
154
+ struct Plant{B,S,N<: Tuple{Vararg{<:Organ{<:Number}}} } <: AbstractMultiScaleArray{B}
155
+ nodes:: N
156
+ values:: Vector{B}
157
+ end_idxs:: Vector{Int}
158
+ settings:: S
159
+ end
160
+
161
+ struct Community{B,N<: Tuple{Vararg{<:Plant{<:Number}}} } <: AbstractMultiScaleArray{B}
162
+ nodes:: N
163
+ values:: Vector{B}
164
+ end_idxs:: Vector{Int}
165
+ end
166
+
167
+ mutable struct Scenario{B,N<: Tuple{Vararg{<:Community{<:Number}}} } <: AbstractMultiScaleArrayHead{B}
168
+ nodes:: N
169
+ values:: Vector{B}
170
+ end_idxs:: Vector{Int}
171
+ end
172
+
173
+ organ1 = Organ ([1.1 ,2.1 ,3.1 ], :Shoot , OrganParams (:grows_up ))
174
+ organ2 = Organ ([4.1 ,5.1 ,6.1 ], :Root , OrganParams (" grows down" ))
175
+ organ3 = Organ ([1.2 ,2.2 ,3.2 ], :Shoot , OrganParams (true ))
176
+ organ4 = Organ ([4.2 ,5.2 ,6.2 ], :Root , OrganParams (1 // 3 ))
177
+ plant1 = construct (Plant, (deepcopy (organ1), deepcopy (organ2)), Float64[], PlantSettings (1 ))
178
+ plant2 = construct (Plant, (deepcopy (organ3), deepcopy (organ4)), Float64[], PlantSettings (1.0 ))
179
+ community = construct (Community, (deepcopy (plant1), deepcopy (plant2), ))
180
+ scenario = construct (Scenario, (deepcopy (community),))
181
+ ```
182
+
183
+ (of course at the cost of mutability).
184
+
145
185
## Idea
146
186
147
187
The idea behind MultiScaleArrays is simple. The ` *DiffEq ` solvers (OrdinaryDiffEq.jl,
0 commit comments