services.py¶
services_infrastructure
¶
Provides infrastructure to inialize and store services.
Attributes:
Name | Type | Description |
---|---|---|
services_parameters |
dict |
Parameters dictionary used for services initialization. |
service |
dict |
Dict where services can be accessed by name. |
all_services |
list |
List with all services indexed by id. |
assign_visitors(self, service_param, comm)
¶
Compute closest service per individual in population.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_param |
dict |
Parameters for current service |
required |
Returns:
Type | Description |
---|---|
np.array |
chosen services id for all population |
Source code in
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
|
assign_work(self, service_param, comm)
¶
Prepare workers to be assigned to services, This method ramdomly pools workers from population.workersAvailable and assign them workplaces and shifts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_param |
dict |
Parameters for the service |
required |
Source code in
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 |
|
close_or_open_services(self)
¶
Close or opens services according to the decision and time series set.
Source code in
87 88 89 90 91 92 93 94 95 96 97 |
|
services_visit(self)
¶
Executes visitation dynamics for services. The order in which the services are processed is shuffled, so that the mean visitation period is respected for many time steps, independently on the order in which particles are assigned to visit a service.
Source code in
72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
service
¶
Class for services implementation.
Attributes:
Name | Type | Description |
---|---|---|
name |
sting |
Name of the service. |
id |
int |
Id of this service. |
number |
int |
Number of instances of this service. |
rooms |
int |
List of rooms in this service. |
chosen_instance |
np.ndarray |
List of the preferred instance of this service for all population (-1 particle will not go to this service). |
visit_period |
float |
Normal period for visitation in days. |
base_visit_probab |
float |
Normal base visitation probability per step of simulation. |
visit_probab |
float |
Current visitation probability per step of simulation. |
isol_period |
float |
Period for visitation for particles in lockdowns. |
isol_probab |
float |
Base visitation probability for particles in lockdown. |
visit_duration |
float |
Duration of visitation in hours. |
return_probab |
float |
Probability for the end of an visitation. |
guest_ids |
list |
List to store temporary guests (not visitors, currently only used to hospitalized particles). |
workers_ids |
np.ndarray |
Id of the workers for this service. |
mask_workers |
np.ndarray |
Boolean mask of the population that identifies workers of this service. |
workers_instance |
np.ndarray |
Instance each worker is assigned, follows workers_ids order. |
workers_shift_start |
np.ndarray |
Time the shift of each worker start, follows workers_ids order. |
workers_shift_end |
np.ndarray |
Time the shift of each worker end, follows workers_ids order. |
workers_room |
np.ndarray |
Room each worker is assigned, follows workers_ids order. |
workers_types |
np.ndarray |
Type of worker for each worker, follows workers_ids order. |
workers_parameters |
list |
Original parameters used on the assignment of the workers. |
working_hours |
list |
Working hours for this service: [opening, closing]. |
placement |
int |
Placement tag for use in this service. |
close |
bool |
Stores if service closes with interventions. |
service_is_closed |
bool |
Stores if service is closed. |
centersAddress |
list |
Address of the center point for all instances of this service (used with distance mechanics). |
limits |
list |
Limits for all instances of this service (used with distance mechanics). |
service_address |
np.ndarray |
Preferred address for visitation/work for all particles (used with distance mechanics). |
grids |
list |
List with the internal grids addresses for all instances of this service (used with distance mechanics). |
grid_address |
np.ndarray |
Addresses inside internal grids for all particles used when fixed point in grid is active for this service (used with distance mechanics). |
controlledAccess |
bool |
If false particles can walk inside service (only relevant with distance mechanics) |
net_type |
int |
Type of net generator to be used in this service (used with networks mechanics). |
net_par |
dict |
Parameters for the network generator (used with networks mechanics). |
allocate_guests(self, new_guest_id)
¶
Add particles to the list of guests.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_guest_id |
np.ndarray |
List of the ids to be added. |
required |
Source code in
631 632 633 634 635 636 637 638 |
|
close_service(self)
¶
Closes a service.
Source code in
606 607 608 |
|
deallocate_guests(self, remove_guests_ids)
¶
Removes particles from the list of guests.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
remove_guests_ids |
np.ndarray |
List of ids to be removed. |
required |
Source code in
640 641 642 643 644 645 646 647 648 649 |
|
open_service(self)
¶
Opens a service.
Source code in
602 603 604 |
|
return_home(self)
¶
Get particles back home after visitation.
Source code in
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 |
|
visit(self)
¶
Randomly chooses free particles to go to their service during business hours.
Source code in
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
|
work(self)
¶
Gets particles to work and return them home.
Source code in
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 |
|
DEFAULTS
¶
Default service settings.
HOSPITALS
¶
Default settings for hospitals
HOTELS
¶
A place to isolate all particles.
MARKETS
¶
Default settings for markets
RESTAURANTS
¶
Default settings for restaurants
SCHOOLS
¶
Default settings for schools
STREET_MARKETS
¶
Default settings for street markets