AgentSet
Container for agents into heirarchical sets (e.g. all_agents > hiv_agents)
Source code in titan/agent.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
|
__contains__(item)
Is an agent a member of this agent set
example
if agent in agent_set:
# do something
Returns:
Type | Description |
---|---|
bool
|
whether agent is part of set |
Source code in titan/agent.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
|
__init__(id, parent=None)
Constructor of an AgentSet
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
str
|
name of the set |
required |
parent |
Optional[AgentSet]
|
the set this set is a subset of |
None
|
Source code in titan/agent.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
|
__iter__()
Iterate over the memers in the set
example
for agent in agent_set:
# do something with agent
Returns:
Type | Description |
---|---|
Iterator[Agent]
|
iterator over member agents |
Source code in titan/agent.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
|
add_agent(agent)
Adds an agent to the set and any parent sets
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent |
Agent
|
agent to add |
required |
Source code in titan/agent.py
416 417 418 419 420 421 422 423 424 425 426 |
|
add_subset(subset)
Adds a new AgentSet to the current sets subset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subset |
AgentSet
|
subset to add to this set |
required |
Source code in titan/agent.py
451 452 453 454 455 456 457 458 459 |
|
clear_set()
Clears a set of any members and subsets
Source code in titan/agent.py
378 379 380 381 382 383 |
|
iter_subset()
Iterate over the subsets of this agent set
Returns:
Type | Description |
---|---|
Iterator[AgentSet]
|
iterator of agent sets |
Source code in titan/agent.py
461 462 463 464 465 466 467 468 469 |
|
num_members()
Number of members in the set
Returns:
Type | Description |
---|---|
int
|
number of members |
Source code in titan/agent.py
442 443 444 445 446 447 448 449 |
|
print_subsets(printer=print)
Pretty print the subsets of this agent set
Source code in titan/agent.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
|
remove_agent(agent)
Removes agent from agent set if they are a member of the set. Also removes the agent from any subsets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent |
Agent
|
agent to remove |
required |
Source code in titan/agent.py
429 430 431 432 433 434 435 436 437 438 439 440 |
|