Skip to content

Error in length of number of occupants #39

@c0nb4

Description

@c0nb4

Please describe the bug

Currently the flats are assigned like this:

def generate_number_occupants(self,area):
"""
Generate number of occupants for different building types.

    Parameters
    ----------
    random_nb : random number in [0,1).

    Returns
    -------
    None.
    """

    if self.building == "SFH":
        # choose random number of occupants (1-5) for single family houses  (assumption)
        probabilities = (0.245114, 0.402323, 0.154148, 0.148869, 0.049623) # Probabilities of having 1, 2, 3, 4 or 5 occupants in a single-family house, assuming a maximum of 5 occupants. Sources: https://www.destatis.de/DE/Themen/Gesellschaft-Umwelt/Wohnen/Tabellen/tabelle-wo2-mietwohnungen.html and https://www.destatis.de/DE/Themen/Gesellschaft-Umwelt/Wohnen/Tabellen/tabelle-wo2-eigentuemerwohnungen.html
        # loop over all flats of current single family house
        for k in range(self.nb_flats):
            random_nb = rd.random()  # picking random number in [0,1)
            j = 1  # staring with one occupant
            # the random number decides how many occupants are chosen (1-5)
            while j <= 5 :
                if random_nb < sum(probabilities[:j]) :
                    self.nb_occ.append(j)  # minimum is 1 occupant
                    break
                j += 1

    elif self.building == "TH":
        # choose random number of occupants (1-5) for terraced houses  (assumption)
        probabilities = (0.236817, 0.400092, 0.157261, 0.154371, 0.051457) # Probabilities of having 1, 2, 3, 4 or 5 occupants in a terraced house, assuming a maximum of 4 occupants. Sources: https://www.destatis.de/DE/Themen/Gesellschaft-Umwelt/Wohnen/Tabellen/tabelle-wo2-mietwohnungen.html and https://www.destatis.de/DE/Themen/Gesellschaft-Umwelt/Wohnen/Tabellen/tabelle-wo2-eigentuemerwohnungen.html
        # loop over all flats of current terraced house
        for k in range(self.nb_flats):
            random_nb = rd.random()  # picking random number in [0,1)
            j = 1  # staring with one occupant
            # the random number decides how many occupants are chosen (1-5)
            while j <= 5 :
                if random_nb < sum(probabilities[:j]) :
                    self.nb_occ.append(j)  # minimum is 1 occupant
                    break
                j += 1

    elif self.building == "MFH":
        # choose random number of occupants (1-5) for each flat in the multi family house  (assumption)
        probabilities = (0.490622, 0.307419, 0.101949, 0.074417, 0.024805) # Probabilities of having 1, 2, 3, 4 or 5 occupants in a flat, assuming a maximum of 4 occupants. Sources: https://www.destatis.de/DE/Themen/Gesellschaft-Umwelt/Wohnen/Tabellen/tabelle-wo2-mietwohnungen.html and https://www.destatis.de/DE/Themen/Gesellschaft-Umwelt/Wohnen/Tabellen/tabelle-wo2-eigentuemerwohnungen.html
        # loop over all flats of current multi family house
        for k in range(self.nb_flats):
            random_nb = rd.random()  # picking random number in [0,1)
            j = 1  # staring with one occupant
            # the random number decides how many occupants are chosen (1-5)
            while j <= 5 :
                if random_nb < sum(probabilities[:j]) :
                    self.nb_occ.append(j)  # minimum is 1 occupant
                    break
                j += 1

    elif self.building == "AB":
        # choose random number of occupants (1-5) for each flat in the apartment block  (assumption)
        probabilities = (0.490622, 0.307419, 0.101949, 0.074417, 0.024805) # Probabilities of having 1, 2, 3, 4 or 5 occupants in a flat, assuming a maximum of 4 occupants. Sources: https://www.destatis.de/DE/Themen/Gesellschaft-Umwelt/Wohnen/Tabellen/tabelle-wo2-mietwohnungen.html and https://www.destatis.de/DE/Themen/Gesellschaft-Umwelt/Wohnen/Tabellen/tabelle-wo2-eigentuemerwohnungen.html
        # loop over all flats of current apartment block
        for k in range(self.nb_flats):
            random_nb = rd.random()  # picking random number in [0,1)
            j = 1  # staring with one occupant
            # the random number decides how many occupants are chosen (1-5)
            while j <= 5 :
                if random_nb < sum(probabilities[:j]) :
                    self.nb_occ.append(j)  # minimum is 1 occupant
                    break
                j += 1

In large houses, with more than eight flats, this leads to an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions