Skip to content

Private room

InteractivePrivateRoom

Bases: InteractiveGroup

Interactive version of PrivateRoom for disease modeling.

Source code in june/groups/private_room.py
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
class InteractivePrivateRoom(InteractiveGroup):
    """Interactive version of PrivateRoom for disease modeling."""

    def __init__(self, group: PrivateRoom, people_from_abroad=None):
        super().__init__(group=group, people_from_abroad=people_from_abroad)
        self.max_occupancy = group.max_occupancy

    def get_spec(self) -> str:
        """Override to return 'sexual_encounter' instead of 'private_room'.

        """
        return "sexual_encounter"

    def get_processed_contact_matrix(self, contact_matrix):
        """Process contact matrix for private rooms.
        Since private rooms typically have close contact, we use a single subgroup
        with high contact rates.

        Args:
            contact_matrix: 

        """
        # Private rooms have only one subgroup, so return the base contact matrix
        return contact_matrix

    def get_processed_beta(self, betas, beta_reductions):
        """Returns the processed contact intensity for private rooms.
        Private rooms are abstract spaces that don't follow venue rules or regional compliance.

        Args:
            betas: 
            beta_reductions: 

        """
        spec = "sexual_encounter"

        # Use sexual_encounter specific beta if available, otherwise use household beta
        if spec in betas:
            beta = betas[spec]
        else:
            beta = betas.get("household", 1.0)

        # Apply beta reductions (but no regional compliance since private rooms are abstract)
        if spec in beta_reductions:
            beta_reduction = beta_reductions[spec]
        else:
            beta_reduction = beta_reductions.get("household", 1.0)

        return beta * beta_reduction

get_processed_beta(betas, beta_reductions)

Returns the processed contact intensity for private rooms. Private rooms are abstract spaces that don't follow venue rules or regional compliance.

Parameters:

Name Type Description Default
betas
required
beta_reductions
required
Source code in june/groups/private_room.py
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
def get_processed_beta(self, betas, beta_reductions):
    """Returns the processed contact intensity for private rooms.
    Private rooms are abstract spaces that don't follow venue rules or regional compliance.

    Args:
        betas: 
        beta_reductions: 

    """
    spec = "sexual_encounter"

    # Use sexual_encounter specific beta if available, otherwise use household beta
    if spec in betas:
        beta = betas[spec]
    else:
        beta = betas.get("household", 1.0)

    # Apply beta reductions (but no regional compliance since private rooms are abstract)
    if spec in beta_reductions:
        beta_reduction = beta_reductions[spec]
    else:
        beta_reduction = beta_reductions.get("household", 1.0)

    return beta * beta_reduction

get_processed_contact_matrix(contact_matrix)

Process contact matrix for private rooms. Since private rooms typically have close contact, we use a single subgroup with high contact rates.

Parameters:

Name Type Description Default
contact_matrix
required
Source code in june/groups/private_room.py
150
151
152
153
154
155
156
157
158
159
160
def get_processed_contact_matrix(self, contact_matrix):
    """Process contact matrix for private rooms.
    Since private rooms typically have close contact, we use a single subgroup
    with high contact rates.

    Args:
        contact_matrix: 

    """
    # Private rooms have only one subgroup, so return the base contact matrix
    return contact_matrix

get_spec()

Override to return 'sexual_encounter' instead of 'private_room'.

Source code in june/groups/private_room.py
144
145
146
147
148
def get_spec(self) -> str:
    """Override to return 'sexual_encounter' instead of 'private_room'.

    """
    return "sexual_encounter"

PrivateRoom

Bases: Group

A private room that can hold people. Each private room has a single subgroup containing its owner (the person who has sexual partners).

Source code in june/groups/private_room.py
 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
 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
class PrivateRoom(Group):
    """A private room that can hold people. Each private room has a single subgroup
    containing its owner (the person who has sexual partners).

    """

    __slots__ = (
        "id",
        "owner_id",
        "max_occupancy",
        "area",
        "super_area",
    )

    def __init__(
        self,
        owner_id: int,
        max_occupancy: int = 1,
        area=None,
        super_area=None
    ):
        """
        Create a PrivateRoom.

        Parameters
        ----------
        owner_id : int
            The ID of the person who owns this private room
        max_occupancy : int, optional
            Maximum number of people that can be in this private room (default: 1)
        area : Area, optional
            The area where this private room is located (same as owner's area)
        super_area : SuperArea, optional
            The super area where this private room is located (same as owner's super area)
        """
        # Initialize the base Group class (creates one subgroup by default)
        super().__init__()

        self.owner_id = owner_id
        self.max_occupancy = max_occupancy
        self.area = area
        self.super_area = super_area

    def get_interactive_group(self, people_from_abroad=None):
        """Get an interactive version of this private room for disease modeling.

        Args:
            people_from_abroad: (Default value = None)

        """
        return InteractivePrivateRoom(self, people_from_abroad=people_from_abroad)

    def add(self, person):
        """Add a person to the private room.

        Args:
            person: 

        """
        if not self.is_full:
            super().add(person, subgroup_type=0, activity="sexual_encounter")
        else:
            logger.warning(f"Private room is full (max occupancy: {self.max_occupancy})")

    @property
    def is_full(self):
        """Check if the private room is at maximum capacity."""
        return len(self.occupants) >= self.max_occupancy

    @property
    def occupants(self):
        """Get all people in the private room."""
        return self.people

    @property
    def n_occupants(self):
        """Get the number of people in the private room."""
        return len(self.occupants)

    @property
    def owner(self):
        """Get the Person object who owns this private room."""
        from june.demography.person import Person
        return Person._persons.get(self.owner_id)

    def get_spec(self) -> str:
        """Override to return 'sexual_encounter' instead of 'private_room'.

        """
        return "sexual_encounter"

is_full property

Check if the private room is at maximum capacity.

n_occupants property

Get the number of people in the private room.

occupants property

Get all people in the private room.

owner property

Get the Person object who owns this private room.

__init__(owner_id, max_occupancy=1, area=None, super_area=None)

Create a PrivateRoom.

Parameters

owner_id : int The ID of the person who owns this private room max_occupancy : int, optional Maximum number of people that can be in this private room (default: 1) area : Area, optional The area where this private room is located (same as owner's area) super_area : SuperArea, optional The super area where this private room is located (same as owner's super area)

Source code in june/groups/private_room.py
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
def __init__(
    self,
    owner_id: int,
    max_occupancy: int = 1,
    area=None,
    super_area=None
):
    """
    Create a PrivateRoom.

    Parameters
    ----------
    owner_id : int
        The ID of the person who owns this private room
    max_occupancy : int, optional
        Maximum number of people that can be in this private room (default: 1)
    area : Area, optional
        The area where this private room is located (same as owner's area)
    super_area : SuperArea, optional
        The super area where this private room is located (same as owner's super area)
    """
    # Initialize the base Group class (creates one subgroup by default)
    super().__init__()

    self.owner_id = owner_id
    self.max_occupancy = max_occupancy
    self.area = area
    self.super_area = super_area

add(person)

Add a person to the private room.

Parameters:

Name Type Description Default
person
required
Source code in june/groups/private_room.py
63
64
65
66
67
68
69
70
71
72
73
def add(self, person):
    """Add a person to the private room.

    Args:
        person: 

    """
    if not self.is_full:
        super().add(person, subgroup_type=0, activity="sexual_encounter")
    else:
        logger.warning(f"Private room is full (max occupancy: {self.max_occupancy})")

get_interactive_group(people_from_abroad=None)

Get an interactive version of this private room for disease modeling.

Parameters:

Name Type Description Default
people_from_abroad

(Default value = None)

None
Source code in june/groups/private_room.py
54
55
56
57
58
59
60
61
def get_interactive_group(self, people_from_abroad=None):
    """Get an interactive version of this private room for disease modeling.

    Args:
        people_from_abroad: (Default value = None)

    """
    return InteractivePrivateRoom(self, people_from_abroad=people_from_abroad)

get_spec()

Override to return 'sexual_encounter' instead of 'private_room'.

Source code in june/groups/private_room.py
 96
 97
 98
 99
100
def get_spec(self) -> str:
    """Override to return 'sexual_encounter' instead of 'private_room'.

    """
    return "sexual_encounter"

PrivateRooms

Bases: Supergroup

A collection of private rooms.

Source code in june/groups/private_room.py
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
class PrivateRooms(Supergroup):
    """A collection of private rooms."""

    venue_class = PrivateRoom

    def __init__(self, private_rooms: List[PrivateRoom]):
        """
        Create a collection of private rooms.

        Parameters
        ----------
        private_rooms : List[PrivateRoom]
            List of private room instances
        """
        super().__init__(members=private_rooms)

    @property
    def n_occupants(self):
        """Get the total number of occupants across all private rooms."""
        return sum([room.n_occupants for room in self.members])

    @property
    def total_capacity(self):
        """Get the total capacity across all private rooms."""
        return sum([room.max_occupancy for room in self.members])

    @property
    def occupancy_rate(self):
        """Get the overall occupancy rate across all private rooms."""
        if self.total_capacity == 0:
            return 0.0
        return self.n_occupants / self.total_capacity

n_occupants property

Get the total number of occupants across all private rooms.

occupancy_rate property

Get the overall occupancy rate across all private rooms.

total_capacity property

Get the total capacity across all private rooms.

__init__(private_rooms)

Create a collection of private rooms.

Parameters

private_rooms : List[PrivateRoom] List of private room instances

Source code in june/groups/private_room.py
108
109
110
111
112
113
114
115
116
117
def __init__(self, private_rooms: List[PrivateRoom]):
    """
    Create a collection of private rooms.

    Parameters
    ----------
    private_rooms : List[PrivateRoom]
        List of private room instances
    """
    super().__init__(members=private_rooms)