Skip to content

Domain

Domain

The idea is that the world is divided in domains, which are just collections of super areas with people living/working/doing leisure in them.

If we think as domains as sets, then world is the union of all domains, and each domain can have a non-zero intersection with other domains (some people can work and live in different domains).

Domains are sent to MPI core to perform calculation, and communication between the processes is required to transfer the infection status of people.

In non-MPI mode, there is only one domain containing all super areas.

Source code in june/domains/domain.py
 9
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
class Domain:
    """The idea is that the world is divided in domains, which are just collections of super areas with
    people living/working/doing leisure in them.

    If we think as domains as sets, then world is the union of all domains, and each domain can have
    a non-zero intersection with other domains (some people can work and live in different domains).

    Domains are sent to MPI core to perform calculation, and communication between the processes is
    required to transfer the infection status of people.

    In non-MPI mode, there is only one domain containing all super areas.

    """

    _id = count()

    def __init__(self, id: int = None):
        if id is None:
            self.id = next(self._id)
        else:
            self.id = id
        self.movable_people = MovablePeople()  # Initialise MovablePeople for either mode

    def __iter__(self):
        return iter(self.super_areas)

    @classmethod
    def from_hdf5(
        cls,
        domain_id,
        super_areas_to_domain_dict: dict,
        hdf5_file_path: str,
        interaction_config: str = None,
        super_areas_to_region_dict: dict = None,
    ):
        """Load a domain from an HDF5 file.

        Args:
            domain_id (int): The ID of the domain to load.
            super_areas_to_domain_dict (dict): Mapping of super areas to domain IDs.
            hdf5_file_path (str): Path to the HDF5 file.
            interaction_config (str, optional): Path to the interaction configuration file. (Default value = None)
            super_areas_to_region_dict (dict, optional): (Default value = None)

        Returns:
            Domain: The domain object loaded from the HDF5 file.

        """
        # Retrieve the global disease configuration
        disease_config = GlobalContext.get_disease_config()

        # Generate the domain
        domain = generate_domain_from_hdf5(
            domain_id=domain_id,
            super_areas_to_domain_dict=super_areas_to_domain_dict,
            file_path=hdf5_file_path,
            interaction_config=interaction_config,
            super_areas_to_region_dict=super_areas_to_region_dict
        )
        domain.id = domain_id
        return domain

from_hdf5(domain_id, super_areas_to_domain_dict, hdf5_file_path, interaction_config=None, super_areas_to_region_dict=None) classmethod

Load a domain from an HDF5 file.

Parameters:

Name Type Description Default
domain_id int

The ID of the domain to load.

required
super_areas_to_domain_dict dict

Mapping of super areas to domain IDs.

required
hdf5_file_path str

Path to the HDF5 file.

required
interaction_config str

Path to the interaction configuration file. (Default value = None)

None
super_areas_to_region_dict dict

(Default value = None)

None

Returns:

Name Type Description
Domain

The domain object loaded from the HDF5 file.

Source code in june/domains/domain.py
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
@classmethod
def from_hdf5(
    cls,
    domain_id,
    super_areas_to_domain_dict: dict,
    hdf5_file_path: str,
    interaction_config: str = None,
    super_areas_to_region_dict: dict = None,
):
    """Load a domain from an HDF5 file.

    Args:
        domain_id (int): The ID of the domain to load.
        super_areas_to_domain_dict (dict): Mapping of super areas to domain IDs.
        hdf5_file_path (str): Path to the HDF5 file.
        interaction_config (str, optional): Path to the interaction configuration file. (Default value = None)
        super_areas_to_region_dict (dict, optional): (Default value = None)

    Returns:
        Domain: The domain object loaded from the HDF5 file.

    """
    # Retrieve the global disease configuration
    disease_config = GlobalContext.get_disease_config()

    # Generate the domain
    domain = generate_domain_from_hdf5(
        domain_id=domain_id,
        super_areas_to_domain_dict=super_areas_to_domain_dict,
        file_path=hdf5_file_path,
        interaction_config=interaction_config,
        super_areas_to_region_dict=super_areas_to_region_dict
    )
    domain.id = domain_id
    return domain