def clean_aggregate_schedules(args):
    data = args[0]
    seed = args[1]
    activityAttribs = args[2]
    dailyStatusAttribs = args[3]
    dependencyAttribs = args[4]
        
    t = time.time()
    data["actobjects"] = data.apply(lambda x: return_act(x,  activityAttribs),  axis=1)
    
    pschedulesGrouped = data.groupby(level=[0,1], sort=False)
    
    print "Size is %d and time taken to run the df apply - %.4f" %(data.shape[0], time.time()-t)
    
    t = time.time()
    actList = []
    for (hid,pid), pidSchedules in pschedulesGrouped:
        #print workStatus_df[(hid, pid)]
        personObject = Person(hid, pid)
        
        activityList = list(pidSchedules["actobjects"].values)
        personObject.add_episodes(activityList)
        
        reconciledSchedules = personObject.clean_schedules_for_in_home_episodes()

        actList += reconciledSchedules
    print "Time taken to loop through all schedules - %.4f" %(time.time()-t)
    return actList
def clean_aggregate_schedules(args):
    data = args[0]
    seed = args[1]
    activityAttribs = args[2]
    dailyStatusAttribs = args[3]
    dependencyAttribs = args[4]

    t = time.time()
    data["actobjects"] = data.apply(lambda x: return_act(x, activityAttribs),
                                    axis=1)

    pschedulesGrouped = data.groupby(level=[0, 1], sort=False)

    print "Size is %d and time taken to run the df apply - %.4f" % (
        data.shape[0], time.time() - t)

    t = time.time()
    actList = []
    for (hid, pid), pidSchedules in pschedulesGrouped:
        #print workStatus_df[(hid, pid)]
        personObject = Person(hid, pid)

        activityList = list(pidSchedules["actobjects"].values)
        personObject.add_episodes(activityList)

        reconciledSchedules = personObject.clean_schedules_for_in_home_episodes(
        )

        actList += reconciledSchedules
    print "Time taken to loop through all schedules - %.4f" % (time.time() - t)
    return actList
def reconcile_schedules(args):
    data = args[0]
    seed = args[1]
    activityAttribs = args[2]
    
    t = time.time()
    data["actobjects"] = data.apply(lambda x: return_act(x,  activityAttribs),  axis=1)
    
    pschedulesGrouped = data.groupby(level=[0,1], sort=False)    
    print "Size is %d and time taken to run the df apply - %.4f" %(data.shape[0], time.time()-t)
    
    t = time.time()
    actList = []
    for (hid,pid), pidSchedules in pschedulesGrouped:
        personObject = Person(hid, pid)
        
        activityList = list(pidSchedules["actobjects"].values)
        personObject.add_episodes(activityList)

        reconciledSchedules = personObject.reconcile_activity_schedules(seed)

        if not personObject._check_for_conflicts():
            raise Exception, "THE SCHEDULES ARE STILL MESSED UP"

        actList += reconciledSchedules

    print "Time taken to loop through all schedules - %.4f" %(time.time()-t)
    return actList
Example #4
0
def process_dependency(args):
    data = args[0]
    seed = args[1]
    activityAttribs = args[2]
    dailyStatusAttribs = args[3]
    dependencyAttribs = args[4]
    specification = args[5]

    t = time.time()
    data["actobjects"] = data.apply(lambda x: return_act(x, activityAttribs),
                                    axis=1)

    hschedulesGrouped = data.groupby(level=0, sort=False)
    pschedulesGrouped = data.groupby(level=[0, 1], sort=False)

    workStatus_df = pschedulesGrouped[dailyStatusAttribs.workStatusName].min()
    schoolStatus_df = pschedulesGrouped[
        dailyStatusAttribs.schoolStatusName].min()
    childDependency_df = pschedulesGrouped[
        dependencyAttribs.childDependencyName].min()

    #print workStatus_df.shape
    #print workStatus_df
    print "Size is %d and time taken to run the df apply - %.4f" % (
        data.shape[0], time.time() - t)

    t = time.time()
    actList = []
    for hid, hidSchedules in hschedulesGrouped:
        householdObject = Household(hid)
        for pid, pidSchedules in hidSchedules.groupby(level=1, axis=0):
            personObject = Person(hid, pid)

            activityList = list(pidSchedules["actobjects"].values)
            personObject.add_episodes(activityList)

            workStatus = workStatus_df[(hid, pid)]
            schoolStatus = schoolStatus_df[(hid, pid)]
            childDependency = childDependency_df[(hid, pid)]
            personObject.add_status_dependency(workStatus, schoolStatus,
                                               childDependency)
            householdObject.add_person(personObject)

        if specification.terminalEpisodesAllocation:
            householdObject.allocate_terminal_dependent_activities(seed)
        elif specification.childDepProcessingType == 'Allocation':
            householdObject.allocate_dependent_activities(seed)
        elif specification.childDepProcessingType == 'Resolution':
            householdObject.lineup_activities(seed)
        elif specification.childDepProcessingType == 'Fix Trip Purpose':
            householdObject.fix_trippurpose(seed)
        elif specification.childDepProcessingType == 'Extract Tour Attributes':
            householdObject.extract_tripattributes(seed)

        reconciledSchedules = householdObject._collate_results()
        actList += reconciledSchedules
    print "Time taken to loop through all schedules - %.4f" % (time.time() - t)
    return actList
def process_dependency(args):
    data = args[0]
    seed = args[1]
    activityAttribs = args[2]
    dailyStatusAttribs = args[3]
    dependencyAttribs = args[4]
    specification = args[5]    

    t = time.time()
    data["actobjects"] = data.apply(lambda x: return_act(x,  activityAttribs),  axis=1)
    
    hschedulesGrouped = data.groupby(level=0, sort=False)
    pschedulesGrouped = data.groupby(level=[0,1], sort=False)
    
    workStatus_df = pschedulesGrouped[dailyStatusAttribs.workStatusName].min()
    schoolStatus_df = pschedulesGrouped[dailyStatusAttribs.schoolStatusName].min()
    childDependency_df = pschedulesGrouped[dependencyAttribs.childDependencyName].min()
    
    #print workStatus_df.shape
    #print workStatus_df
    print "Size is %d and time taken to run the df apply - %.4f" %(data.shape[0], time.time()-t)

    t = time.time()
    actList = []
    for hid,  hidSchedules in hschedulesGrouped:
        householdObject = Household(hid)
        for pid,  pidSchedules in hidSchedules.groupby(level=1, axis=0):
            personObject = Person(hid, pid)                

            activityList = list(pidSchedules["actobjects"].values)
            personObject.add_episodes(activityList)
            
            workStatus = workStatus_df[(hid, pid)]
            schoolStatus = schoolStatus_df[(hid, pid)]
            childDependency = childDependency_df[(hid, pid)]
            personObject.add_status_dependency(workStatus, schoolStatus,
                                                    childDependency)
            householdObject.add_person(personObject)

        if specification.terminalEpisodesAllocation:
            householdObject.allocate_terminal_dependent_activities(seed)
        elif specification.childDepProcessingType == 'Allocation':
            householdObject.allocate_dependent_activities(seed)
        elif specification.childDepProcessingType == 'Resolution':
            householdObject.lineup_activities(seed)
        elif specification.childDepProcessingType == 'Fix Trip Purpose':
            householdObject.fix_trippurpose(seed)
        elif specification.childDepProcessingType == 'Extract Tour Attributes':
            householdObject.extract_tripattributes(seed)            

        reconciledSchedules = householdObject._collate_results()
        actList += reconciledSchedules
    print "Time taken to loop through all schedules - %.4f" %(time.time()-t)
    return actList
Example #6
0
def clean_schedules(args):
    data = args[0]
    seed = args[1]
    activityAttribs = args[2]
    dailyStatusAttribs = args[3]
    dependencyAttribs = args[4]

    t = time.time()
    data["actobjects"] = data.apply(lambda x: return_act(x, activityAttribs),
                                    axis=1)

    pschedulesGrouped = data.groupby(level=[0, 1], sort=False)

    workStatus_df = pschedulesGrouped[dailyStatusAttribs.workStatusName].min()
    schoolStatus_df = pschedulesGrouped[
        dailyStatusAttribs.schoolStatusName].min()
    childDependency_df = pschedulesGrouped[
        dependencyAttribs.childDependencyName].min()

    #print workStatus_df.shape
    #print workStatus_df
    print "Size is %d and time taken to run the df apply - %.4f" % (
        data.shape[0], time.time() - t)

    t = time.time()
    actList = []
    for (hid, pid), pidSchedules in pschedulesGrouped:
        #print workStatus_df[(hid, pid)]
        personObject = Person(hid, pid)

        activityList = list(pidSchedules["actobjects"].values)
        personObject.add_episodes(activityList)

        workStatus = workStatus_df[(hid, pid)]
        schoolStatus = schoolStatus_df[(hid, pid)]
        childDependency = childDependency_df[(hid, pid)]
        personObject.add_status_dependency(workStatus, schoolStatus,
                                           childDependency)

        reconciledSchedules = personObject.clean_schedules()

        actList += reconciledSchedules
    print "Time taken to loop through all schedules - %.4f" % (time.time() - t)
    return actList
def clean_schedules(args):
    data = args[0]
    seed = args[1]
    activityAttribs = args[2]
    dailyStatusAttribs = args[3]
    dependencyAttribs = args[4]

    t = time.time()
    data["actobjects"] = data.apply(lambda x: return_act(x, activityAttribs), axis=1)

    pschedulesGrouped = data.groupby(level=[0, 1], sort=False)

    workStatus_df = pschedulesGrouped[dailyStatusAttribs.workStatusName].min()
    schoolStatus_df = pschedulesGrouped[dailyStatusAttribs.schoolStatusName].min()
    childDependency_df = pschedulesGrouped[dependencyAttribs.childDependencyName].min()

    # print workStatus_df.shape
    # print workStatus_df
    print "Size is %d and time taken to run the df apply - %.4f" % (data.shape[0], time.time() - t)

    t = time.time()
    actList = []
    for (hid, pid), pidSchedules in pschedulesGrouped:
        # print workStatus_df[(hid, pid)]
        personObject = Person(hid, pid)

        activityList = list(pidSchedules["actobjects"].values)
        personObject.add_episodes(activityList)

        workStatus = workStatus_df[(hid, pid)]
        schoolStatus = schoolStatus_df[(hid, pid)]
        childDependency = childDependency_df[(hid, pid)]
        personObject.add_status_dependency(workStatus, schoolStatus, childDependency)

        reconciledSchedules = personObject.clean_schedules()

        actList += reconciledSchedules
    print "Time taken to loop through all schedules - %.4f" % (time.time() - t)
    return actList