def test_retrieve_loop_ids(self):
        houseIdsCol = self.actSchedules.columns(['houseid']).data
        houseIdsUnique = unique(houseIdsCol)
        #print houseIdsUnique

        for hid in houseIdsUnique:
            schedulesRowsIndForHh = houseIdsCol == hid
            schedulesForHh = self.actSchedules.rowsof(schedulesRowsIndForHh)

            pIdsCol = schedulesForHh.columns(['personid']).data
            pIdsUnique = unique(pIdsCol)

            for pid in pIdsUnique:
                schedulesRowIndForPer = pIdsCol == pid
                schedulesForPerson = schedulesForHh.rowsof(
                    schedulesRowIndForPer)

                #print 'Raw schedules for hid:%s and pid:%s' %(hid, pid)
                #print schedulesForPerson

                activityList = []
                for sch in schedulesForPerson.data:
                    scheduleid = sch[2]
                    activitytype = sch[3]
                    locationid = sch[4]
                    starttime = sch[5]
                    endtime = sch[6]
                    duration = sch[7]

                    actepisode = ActivityEpisode(scheduleid, activitytype,
                                                 locationid, starttime,
                                                 endtime, duration)
                    activityList.append(actepisode)
                personObject = Person(hid, pid)
                personObject.add_and_reconcile_episodes(activityList)
def return_act(schedule, activityAttributes):
    hid = schedule[activityAttributes.hidName]
    pid = schedule[activityAttributes.pidName]

    scheduleid = schedule[activityAttributes.scheduleidName]
    activitytype = schedule[activityAttributes.activitytypeName]
    locationid = schedule[activityAttributes.locationidName]
    starttime = schedule[activityAttributes.starttimeName]
    endtime = schedule[activityAttributes.endtimeName]
    duration = schedule[activityAttributes.durationName]
    depPersonId = schedule[activityAttributes.dependentPersonName]

    act = ActivityEpisode(hid, pid, scheduleid, activitytype, locationid,
                          starttime, endtime, duration, depPersonId)
    return act
示例#3
0
    def return_activity_list_for_person(self, schedulesForPerson):
        # Updating activity list
        activityList = []
        for sched in schedulesForPerson.data:
            scheduleid = sched[self.schidCol]
            activitytype = sched[self.actTypeCol]
            locationid = sched[self.locidCol]
            starttime = sched[self.sttimeCol]
            endtime = sched[self.endtimeCol]
            duration = sched[self.durCol]
            depPersonId = sched[self.depPersonCol]

            actepisode = ActivityEpisode(scheduleid, activitytype, locationid,
                                         starttime, endtime, duration, depPersonId)
            activityList.append(actepisode)

        return activityList
    def return_activity_list_for_person(self, pidSchedules):
        # Updating activity list
        activityList = []
        for index, schedule in pidSchedules.iterrows():
            hid = schedule[self.hidName]
            pid = schedule[self.pidName]

            scheduleid = schedule[self.scheduleidName]
            activitytype = schedule[self.activitytypeName]
            locationid = schedule[self.locationidName]
            starttime = schedule[self.starttimeName]
            endtime = schedule[self.endtimeName]
            duration = schedule[self.durationName]
            depPersonId = schedule[self.dependentPersonName]

            actepisode = ActivityEpisode(hid, pid, scheduleid, activitytype,
                                         locationid, starttime, endtime,
                                         duration, depPersonId)
            activityList.append(actepisode)
        return activityList
示例#5
0
    def resolve_consistency(self, data, seed):
        actList = []
        data.sort([self.activityAttribs.hidName,
                   self.activityAttribs.pidName,
                   self.activityAttribs.scheduleidName])
        ti = time.time()
        # Create Index Matrix
        self.create_indices(data)

        print 'Indices created in %.4f' %(time.time()-ti)
        hidCol = data._colnames[self.activityAttribs.hidName]
        pidCol = data._colnames[self.activityAttribs.pidName]


        schidCol = data._colnames[self.activityAttribs.scheduleidName]
        actTypeCol = data._colnames[self.activityAttribs.activitytypeName]
        locidCol = data._colnames[self.activityAttribs.locationidName]
        sttimeCol = data._colnames[self.activityAttribs.starttimeName]
        endtimeCol = data._colnames[self.activityAttribs.endtimeName]
        durCol = data._colnames[self.activityAttribs.durationName]

        colNames = [self.activityAttribs.hidName,
                    self.activityAttribs.pidName,
                    self.activityAttribs.scheduleidName,
                    self.activityAttribs.activitytypeName,
                    self.activityAttribs.starttimeName,
                    self.activityAttribs.endtimeName,
                    self.activityAttribs.locationidName,
                    self.activityAttribs.durationName,
                    self.activityAttribs.dependentPersonName,
                    self.activityAttribs.tripCountName]



        row = 0

        for perIndex in self.indices:
            schedulesForPerson = data.data[perIndex[2]:perIndex[3],:]

            activityList = []
            for sched in schedulesForPerson:
                hid = sched[hidCol]
                pid = sched[pidCol]

                scheduleid = sched[schidCol]
                activitytype = sched[actTypeCol]
                locationid = sched[locidCol]
                starttime = sched[sttimeCol]
                endtime = sched[endtimeCol]
                duration = sched[durCol]

                actepisode = ActivityEpisode(hid, pid, scheduleid, activitytype, locationid,
                                             starttime, endtime, duration)
                activityList.append(actepisode)

            personObject = Person(perIndex[0], perIndex[1])
            personObject.add_episodes(activityList)
            personObject.reconcile_activity_schedules(seed)
            reconciledSchedules = personObject._collate_results_aslist()

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

            actList += reconciledSchedules
        return DataArray(actList, colNames)