Agent
This class constructs and represents an agent within the population
Source code in titan/agent.py
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 180 181 182 183 184 185 186 |
|
__init__(sex_type, age, race, drug_use, location, id=None)
Initialize an agent based on given properties
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
Optional[int]
|
Unique agent ID |
None
|
sex_type |
str
|
Name of defined sex type (e.g. MSM) [params.classes.sex_types] |
required |
age |
int
|
Agents initialization age |
required |
race |
str
|
Race of agent [params.classes.races] |
required |
drug_use |
str
|
Drug use flag [params.classes.drug_types] |
required |
Source code in titan/agent.py
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 |
|
__repr__()
Repr formatting of agent object
Returns:
Type | Description |
---|---|
str
|
agent ID as str |
Source code in titan/agent.py
94 95 96 97 98 99 100 101 |
|
__str__()
String formatting of agent object
Returns:
Type | Description |
---|---|
str
|
String formatted tab-deliminated agent properties |
Source code in titan/agent.py
82 83 84 85 86 87 88 89 90 91 92 |
|
get_num_partners(bond_types=None)
Get the number of partners an agent has, optionally filtered by bond type
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bond_types |
Optional[Iterable[str]]
|
list of bond types which will filter the partners, otherwise total number of partners returned |
None
|
Returns:
Type | Description |
---|---|
int
|
the number of partners the agent has |
Source code in titan/agent.py
176 177 178 179 180 181 182 183 184 185 186 |
|
get_partners(bond_types=None)
Get all of an agents partners or those with specific bond types
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bond_types |
Optional[Iterable[str]]
|
list of bond types which will filter the partners, otherwise all partners returned |
None
|
Returns:
Type | Description |
---|---|
Set[Agent]
|
set of agent's partners |
Source code in titan/agent.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
has_partners()
Determine whether an agent has any partners
Returns:
Type | Description |
---|---|
bool
|
whether an agent has at least one partner |
Source code in titan/agent.py
132 133 134 135 136 137 138 139 |
|
is_msm()
Determine whether an agent is a man who can have sex with men
Returns:
Type | Description |
---|---|
bool
|
if agent is MSM |
Source code in titan/agent.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
iter_partners()
Get an iterator over an agent's partners
Returns:
Type | Description |
---|---|
Iterator[Agent]
|
iterator of agent partners |
Source code in titan/agent.py
121 122 123 124 125 126 127 128 129 130 |
|