Cellular automata¶

cromosim.ca.
compute_exit_times
(dt, results)[source]¶ To compute exit times for all the individuals from the results array
 Parameters
 dt: float
time step
 results: numpy array
positions at each time
 Returns
 exit_times: all the exit times

cromosim.ca.
exit
(domain, people, people_ij)[source]¶ To update people and people_ij arrays in removing individuals who left the domain
 Parameters
 domain: Domain
contains everything for managing the domain
 people: numpy masked arrays
equal to 1 if the cell (i,j) is occupied, 0 elsewhere
 people_ij: numpy array
(i,j) for each individual
 Returns
 people: numpy masked arrays
new positions equal to 1 if the cell (i,j) is occupied, 0 elsewhere
 people_id: numpy masked arrays
new people index (i,j)

cromosim.ca.
parallel_update
(people, people_ij, weight, friction=0, randomstate=None)[source]¶ To move all individuals in parallel according to the following rule: first, desired moves are precomputed and then the conflicts (two individuals at the same position) are resolved
 Parameters
 people: numpy masked arrays
equal to 1 if the cell (i,j) is occupied, 0 elsewhere
 people_ij: numpy array
(i,j) for each individual
 weight: numpy array
weights for the probabilities in order to move in such a way like to reach the door
 friction: float
to designate the effect induced by a modified handling of conflicts, friction is the probability that a conflict remains unresolved (no one moves)
 randomstate: numpy randomstate
create a new one or reuse the given random state
 Returns
 people: numpy masked arrays
new positions equal to 1 if the cell (i,j) is occupied, 0 elsewhere
 people_id: numpy masked arrays
new people index (i,j)

cromosim.ca.
plot_people_according_to_current_door_distance
(ifig, people, domain, axis=None, savefig=False, filename='fig.png')[source]¶ To draw occupied cells with colors depending on current door distances
 Parameters
 ifig: int
figure number
 people: numpy masked arrays
equal to 1 if the cell (i,j) is occupied, 0 elsewhere
 domain: Domain
contains everything for managing the domain
 axis: list
matplotlib axis
 savefig: boolean
writes the figure as a png file if true
 filename: string
png filename used to write the figure

cromosim.ca.
plot_people_according_to_exit_times
(ifig, dt, people, domain, results, axis=None, savefig=False, filename='fig.png')[source]¶ To draw occupied cells with colors depending on the exit times
 Parameters
 ifig: int
figure number
 dt: float
time step
 people: masked ndarray
equal to 1 if the cell (i,j) is occupied, 0 elsewhere
 domain: Domain
contains everything for managing the domain
 results: ndarray
positions at each time
 axis: list
matplotlib axis
 savefig: boolean
writes the figure as a png file if true
 filename: string
png filename used to write the figure

cromosim.ca.
plot_people_according_to_initial_door_distance
(ifig, people, domain, results, axis=None, savefig=False, filename='fig.png')[source]¶ To draw occupied cells with colors depending on initial (time=0) door distances
 Parameters
 ifig: int
figure number
 people: numpy masked arrays
equal to 1 if the cell (i,j) is occupied, 0 elsewhere
 domain: Domain
contains everything for managing the domain
 results: numpy array
contains the results for each iteration in time, used here to determine the initial distance to the door
 axis: list
matplotlib axis
 savefig: boolean
writes the figure as a png file if true
 filename: string
png filename used to write the figure

cromosim.ca.
plot_people_paths
(ifig, dt, pixel_size, people, domain, results, axis=None, savefig=False, filename='fig.png')[source]¶ To draw all the individual paths from intial time to final time
 Parameters
 ifig: int
figure number
 dt: float
time step
 pixel_size: float
size of one pixel in meters
 people: numpy masked arrays
equal to 1 if the cell (i,j) is occupied, 0 elsewhere
 domain: Domain
contains everything for managing the domain
 results: numpy.ndarray
positions at each time
 axis: list
matplotlib axis
 savefig: boolean
writes the figure as a png file if true
 filename: string
png filename used to write the figure

cromosim.ca.
sequential_update
(people, people_ij, weight, shuffle=None, randomstate=None)[source]¶ To move all individuals sequentially according to the following rule: the update of individual i is determined in a stochastic way by computing transition probabilities on neighboring cells (including the current position of i).
 Parameters
 people: numpy masked arrays
equal to 1 if the cell (i,j) is occupied, 0 elsewhere
 people_ij: numpy array
(i,j) for each individual
 weight: numpy array
weights for the probabilities in order to move in such a way like to reach the door
 shuffle: string
shuffle kind (‘random’ or ‘random_frozen’): if the sequential order changes or not at each time
 randomstate: numpy randomstate
create a new one or reuse the given random state
 Returns
 people: numpy masked arrays
new positions equal to 1 if the cell (i,j) is occupied, 0 otherwise
 people_id: numpy masked arrays
new people index (i,j)