Skip to content
rubae edited this page Oct 3, 2013 · 7 revisions

A Household Class is defined grouping the basic information on household composition.

class Household(object):
    __init__(self, name, composition, **kwargs):
        self.name = name
        self.composition = composition
        self.cluster = self.__allocate__(composition)
        # defining also:
        self.__occdict__ = {"home":1, "sleeping":2, "absent":3}
        self.__wknd__ = [ ]

Instantiation of the Household class includes declaration of the object attributes self.name equal to the given name, self.composition equal to the given composition and self.cluster internally assigning the household members to certain clusters.

Two internal functions are declared for the Household class:

    def __random__(self):
        return composition, appliances
    def __allocate__(self, composition)
        return clusters

which allow the definition of a random Household object if ["random"] is given as composition, and which allocate the the defined composition to respective clusters determined from time use survey data.

##Simulation

A simulate function is included in the Household class

Household.simulate()

which is the main function. This function uses data from objects of the Appliance class, Drawoff class and the StateSpace class defined in the description of data.py for easily loading, writing and storing input data. The simulate function includes models for occupancy, appliance use, lighting loads, hot water tappings and space heating settings.

1. Nested occupancy simulation

An occupancy simulation is nested in the simulate function as

def __occupancy__(self):
    self.occ = [ ]

which defines household.occ as the typical weekprofile of the household members. Here, two internal functions are used: the dayrun function simulates a single day based on the clustering data from time use surveys and which is looped over all days and household mmebers, whereas the check function controls the results of the latter function requiring a re-run if incorrect.

    def dayrun(start, cluster):
        # as long as the results are not correct according to check(#)
        while check == False:
            # for 144 time bins in a day
            while tbin < 143:
                tbin += 1
                if dt == 0:
                    occs[tbin] = transition( )
                    dt = duration( )
                else:
                    occss[tbin] = occss[tbin-1]
                    dt += -1
        # and return the results
        return occs
    def check(day, cluster):
        # Both the shape of the results as well as the length of shortest sequences are checked.
        return Boolean
Clone this wiki locally