SimulationState
SimulationState
Representation of the state during a single step of the simulation. This is essentially a dictionary that maps the IDs of sites in the simulation structure to dictionaries with arbitrary keys and values that can store whatever state is relevant for the simulation.
Additionally, there is a concept of general simulation state that is separate from the state of any specific site in the simulation.
Source code in pylattica/core/simulation_state.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
__init__(state=None)
Initializes the SimulationState.
Parameters
dict, optional
A state to store. should be a map with keys "GENERAL" and "SITES", by default None
Source code in pylattica/core/simulation_state.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
all_site_states()
Returns a list of dictionaries representing the site state values.
Returns
List[Dict] The state dictionaries for every site in this state.
Source code in pylattica/core/simulation_state.py
77 78 79 80 81 82 83 84 85 86 |
|
batch_update(update_batch)
Applies a batch update to many sites and the general state. Takes a dictionary formatted like this:
{ "GENERAL": {...}, "SITES": { 1: {...} } }
Parameters
Dict
The updates to apply as a batch.
Source code in pylattica/core/simulation_state.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
copy()
Creates a new simulation state identical to this one. This is a deepcopy operation, so changing the copy will not change the original.
Returns
SimulationState The copy of this SimulationState
Source code in pylattica/core/simulation_state.py
167 168 169 170 171 172 173 174 175 176 |
|
get_general_state()
Returns the general state.
Returns
Dict The general state.
Source code in pylattica/core/simulation_state.py
103 104 105 106 107 108 109 110 111 |
|
get_site_state(site_id)
Returns the state stored for the specified site ID, if any.
Parameters
int
The ID of the site for which state information should be retrieved.
Returns
Dict The state of that site. Returns None if no state is stored under that site ID.
Source code in pylattica/core/simulation_state.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
set_general_state(updates)
Updates the general state with the keys and values provided by the updates parameter.
Parameters
Dict
The updates to apply. Note that this overwrites values in the old state, but unspecified values are left unchanged.
Source code in pylattica/core/simulation_state.py
113 114 115 116 117 118 119 120 121 122 123 |
|
set_site_state(site_id, updates)
Updates the state stored for site with ID site_id.
Parameters
int
The ID of the site for which the state should be updated.
dict
The updates to the state that should be performed.
Source code in pylattica/core/simulation_state.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
site_ids()
A list of site IDs for which some state is stored.
Returns
List[int]
Source code in pylattica/core/simulation_state.py
68 69 70 71 72 73 74 75 |
|
size()
property
Gives the number of sites for which state information is stored.
Returns
int The number of sites for which state information is stored.
Source code in pylattica/core/simulation_state.py
57 58 59 60 61 62 63 64 65 66 |
|