slwu89 / Individual.jl

Tools to specify and simulate individual based models, using applied category theory
https://slwu89.github.io/Individual.jl/
MIT License
7 stars 2 forks source link

new schema design #31

Open slwu89 opened 2 years ago

slwu89 commented 2 years ago

@slibkind suggested the following updated schema: Figures-For-Royal-Soc-Paper-17

Some of the key points were:

Scheduling updates:

Any new schema must fulfill the following:

Note from 2/18/22 meeting:

dynamic attrs are linked to Person at a time, static attrs are attached to actual person.

slwu89 commented 2 years ago

This schema as described here may not work, when not all states/attributes are updated on every time step:

┌────────┬─────────┬──────┬─────────────┬────────────┐
│ Person │ current │ next │ statestatic │ attrstatic │
├────────┼─────────┼──────┼─────────────┼────────────┤
│      1 │       1 │    1 │           1 │          1 │
│      2 │       2 │    0 │           1 │          2 │
│      3 │       3 │    2 │           1 │          3 │
│      4 │       4 │    0 │           2 │          4 │
│      5 │       5 │    0 │           2 │          5 │
│      6 │       6 │    0 │           2 │          6 │
└────────┴─────────┴──────┴─────────────┴────────────┘
┌─────────┬───────────────┬──────────────────────┬─────────────────────┐
│ Current │ current_state │ current_statedynamic │ current_attrdynamic │
├─────────┼───────────────┼──────────────────────┼─────────────────────┤
│       1 │             1 │                    1 │                   7 │
│       2 │             2 │                    2 │                   8 │
│       3 │             3 │                    3 │                   9 │
│       4 │             1 │                    1 │                  10 │
│       5 │             2 │                    2 │                  11 │
│       6 │             3 │                    3 │                  12 │
└─────────┴───────────────┴──────────────────────┴─────────────────────┘
┌──────┬────────────┬───────────────────┬──────────────────┐
│ Next │ next_state │ next_statedynamic │ next_attrdynamic │
├──────┼────────────┼───────────────────┼──────────────────┤
│    1 │          3 │                 0 │  140506839372384 │
│    2 │          1 │                 0 │                1 │
└──────┴────────────┴───────────────────┴──────────────────┘
┌───────┬────────────┐
│ State │ statelabel │
├───────┼────────────┤
│     1 │          S │
│     2 │          I │
│     3 │          R │
└───────┴────────────┘

In this case only the Ob "State" should be updated but because the "Next" object creates a single table to all updates, by definition the other objects/attributes are listed in the updates. Because not every object or attribute will be updated each time step, this is undesirable (also in this example the unset statedynamic and attrdynamic objects will be set to unintended values).

What we need is for each dynamic object or attribute to have its own update table. This is how individual does it.

One way to do this is to have this kind of a relation between each state or attribute which is dynamic. image