| … | … | @@ -178,16 +178,55 @@ |
| 178 | 178 | ) |
| 179 | 179 | |
| 180 | 180 | ; --------------------------------------------------------------------- |
| 181 | | ; A grammar that defines a random network. This grammar will be used |
| 182 | | ; to generate fixed, static networks of individuals. Why use a static |
| 183 | | ; network? To better model geographical isolation. Thus, for example, |
| 184 | | ; a person who mostly stays home is likely to encounter only three |
| 185 | | ; people: other family members. A person who is highly social might |
| 186 | | ; meet dozens of people - now, this does NOT mean that the meetings |
| 187 | | ; happen every day - they may be very infrequent. But its usually |
| 188 | | ; the same dozen people, from the same neighborhood - even, maybe |
| 189 | | ; random strangers in the grocery store. The static network captures |
| 190 | | ; this locality, and the general invariance of the potential network. |
| 181 | ; The above state-transmission model was verbose. Just a tiny-bit of |
| 182 | ; script-fu can clean it up and make it easier to read. Lets do that. |
| 183 | ; |
| 184 | ; Define a wrapper for each of the state-transition clauses |
| 185 | (define (condition CURRENT-STATE NEXT-STATE DISTRIBUTION) |
| 186 | (list |
| 187 | (And |
| 188 | (Equal (ValueOf (Variable "$A") seir-state) CURRENT-STATE) |
| 189 | (GreaterThan |
| 190 | (ValueOf (Variable "$A") DISTRIBUTION) |
| 191 | (RandomNumber (Number 0) (Number 1)))) |
| 192 | (SetValue (Variable "$A") seir-state NEXT-STATE))) |
| 193 | |
| 194 | ; Define a wrapper, just like above, but instead using (1-probability) |
| 195 | (define (inverted CURRENT-STATE NEXT-STATE DISTRIBUTION) |
| 196 | (list |
| 197 | (And |
| 198 | (Equal (ValueOf (Variable "$A") seir-state) CURRENT-STATE) |
| 199 | (GreaterThan |
| 200 | (Minus (Number 1) (ValueOf (Variable "$A") DISTRIBUTION)) |
| 201 | (RandomNumber (Number 0) (Number 1)))) |
| 202 | (SetValue (Variable "$A") seir-state NEXT-STATE))) |
| 203 | |
| 204 | ; Here's the easier-to-read version. So Atomese is verbose, but |
| 205 | ; that's not hard to hide behind some wrappers. |
| 206 | (Define |
| 207 | (DefinedSchema "alt version of state transition") |
| 208 | (Lambda |
| 209 | (Variable "$A") |
| 210 | (Cond |
| 211 | (condition exposed infected susceptibility) |
| 212 | (inverted exposed susceptible susceptibility) |
| 213 | (condition infected died infirmity) |
| 214 | (condition infected recovered recovery)))) |
| 215 | |
| 216 | ; --------------------------------------------------------------------- |
| 217 | ; Generate a random social network. This starts by defining a grammar |
| 218 | ; that will express the network. |
| 219 | ; |
| 220 | ; The generated network will be a fixed, static networks of individuals. |
| 221 | ; Why use a static network? To better model geographical isolation. |
| 222 | ; Thus, for example, a person who mostly stays home is likely to |
| 223 | ; encounter only three people: other family members. A person who is |
| 224 | ; highly social might meet dozens of people - now, this does NOT mean |
| 225 | ; that the meetings happen every day - they may be very infrequent. |
| 226 | ; But its usually the same dozen people, from the same neighborhood |
| 227 | ; - even, maybe the same set of random strangers in the grocery store. |
| 228 | ; The static network captures this geographical locality, and the |
| 229 | ; general invariance of the potential network. |
| 191 | 230 | ; |
| 192 | 231 | ; The grammar used here is quite simple: it is just a minor twist on |
| 193 | 232 | ; the grammar used in the `basic-network.scm` example. It introduces |
| … | … | @@ -199,10 +238,13 @@ |
| 199 | 238 | ; The code here just automates the generation of the grammar. The |
| 200 | 239 | ; setting of susceptibilities and infirmities will be done after the |
| 201 | 240 | ; network has been generated. |
| 241 | ; |
| 242 | ; ---- |
| 243 | ; Network Gneration parameters. |
| 202 | 244 | |
| 203 | | ; This is the key under which the likelihood of creating this kind of |
| 204 | | ; network node will be stored. This is used to select nodes during the |
| 205 | | ; random network generation. |
| 245 | ; The key identifying the likelihood of creating a particular kind of |
| 246 | ; network node. This weighting controls the selection of the particular |
| 247 | ; node-type. |
| 206 | 248 | (define node-weight (Predicate "node likelihood")) |
| 207 | 249 | |
| 208 | 250 | ; This is the anchor-point to which the grammar will be attached. |