Class VoteAgent
Bases: Agent
An agent that has limited knowledge and resources and can decide to use them to participate in elections.
Source code in src/agents/vote_agent.py
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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
assets
deletable
property
writable
Return the assets of this agent.
col
property
Return the col location of the agent.
num_elections_participated
property
writable
Return the number of elections this agent has participated in.
position
property
Return the location of the agent.
row
property
Return the row location of the agent.
__init__(unique_id, model, pos, personality=None, personality_idx=None, assets=1, add=True)
Create a new agent.
Attributes:
| Name | Type | Description |
|---|---|---|
unique_id |
The unique identifier of the agent. |
|
model |
The simulation model of which the agent is part of. |
|
pos |
The position of the agent in the grid. |
|
personality |
Represents the agent's preferences among colors. |
|
personality_idx |
Index of personality in model's personalities list. |
|
assets |
The wealth/assets/motivation of the agent. |
Source code in src/agents/vote_agent.py
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 | |
ask_for_participation(area)
Decide whether to participate in the given area's election.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Area
|
The area in which the election takes place. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the agent decides to participate, False otherwise |
Source code in src/agents/vote_agent.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
compute_assumed_opt_dist(area)
Computes a color distribution that the agent assumes to be an optimal choice in any election (regardless of whether it exists as a real option to vote for or not). It takes "altruistic" concepts into consideration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Area
|
The area in which the election takes place. |
required |
Returns:
| Type | Description |
|---|---|
array
|
np.array: The assumed optimal color distribution (normalized). |
Source code in src/agents/vote_agent.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
decide_altruism_factor(area)
Uses a trained decision tree to decide on the altruism factor.
Returns:
| Type | Description |
|---|---|
float
|
float |
Source code in src/agents/vote_agent.py
150 151 152 153 154 155 156 157 158 159 160 161 | |
estimate_real_distribution(area)
The agent estimates the real color distribution in the area based on her own knowledge (self.known_cells).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Area
|
The area the agent uses to estimate. |
required |
Returns:
| Type | Description |
|---|---|
tuple[array, float]
|
tuple[np.array, float]: (distribution, confidence) |
Source code in src/agents/vote_agent.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
update_known_cells(area)
This method is to update the list of known cells before casting a vote.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Area
|
The area that holds the pool of cells in question |
required |
Source code in src/agents/vote_agent.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
vote(area)
The agent votes in the election of a given area,
i.e., she returns a preference ranking vector over all options.
(Ranking: index = option, value proportional to rank)
The available options are set in the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Area
|
The area in which the election takes place. |
required |
Source code in src/agents/vote_agent.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |