Example #1
0
    def get_mazpairs(self, omaz, dmaz, attribute):
        """
        look up attribute values of maz od pairs in sparse maz_to_maz df

        Parameters
        ----------
        omaz: array-like list of omaz zone_ids
        dmaz: array-like list of omaz zone_ids
        attribute: str name of attribute column in maz_to_maz_df

        Returns
        -------
        Numpy.ndarray: list of attribute values for od pairs
        """

        # # this is slower
        # s = pd.merge(pd.DataFrame({'OMAZ': omaz, 'DMAZ': dmaz}),
        #              self.maz_to_maz_df,
        #              how="left")[attribute]

        # synthetic index method i : omaz_dmaz
        i = np.asanyarray(omaz) * self.maz_ceiling + np.asanyarray(dmaz)
        s = util.quick_loc_df(i, self.maz_to_maz_df, attribute)

        # FIXME - no point in returning series?
        return np.asanyarray(s)
Example #2
0
    def get_maztappairs(self, maz, tap, attribute):

        # synthetic i method : maz_tap
        i = np.asanyarray(maz) * self.maz2tap_cardinality + np.asanyarray(tap)
        s = quick_loc_df(i, self.maz2tap_df, attribute)

        # FIXME - no point in returning series? unless maz and tap have sme index?
        return np.asanyarray(s)
Example #3
0
    def get_mazpairs(self, omaz, dmaz, attribute):

        # # this is slower
        # s = pd.merge(pd.DataFrame({'OMAZ': omaz, 'DMAZ': dmaz}),
        #              self.maz2maz_df,
        #              how="left")[attribute]

        # synthetic index method i : omaz_dmaz
        i = np.asanyarray(omaz) * self.maz2maz_cardinality + np.asanyarray(dmaz)
        s = quick_loc_df(i, self.maz2maz_df, attribute)

        # FIXME - no point in returning series? unless maz and tap have same index?
        return np.asanyarray(s)
Example #4
0
    def tour_available(self, window_row_ids, tdds):
        """
        test whether time window allows tour with specific tdd alt's time window

        Parameters
        ----------
        row_ids : pandas Series
            series of window_row_ids indexed by tour_id
        tdds : pandas series
            series of tdd_alt ids, index irrelevant

        Returns
        -------
        available : pandas Series of bool
            with same index as window_row_ids.index (presumably tour_id, but we don't care)
        """

        assert len(window_row_ids) == len(tdds)

        # t0 = tracing.print_elapsed_time()

        # numpy array with one tdd_footprints_df row for tdds
        tour_footprints = util.quick_loc_df(
            tdds, self.tdd_footprints_df).as_matrix()

        # t0 = tracing.print_elapsed_time("tour_footprints", t0, debug=True)
        # assert (tour_footprints == self.tdd_footprints_df.loc[tdds].as_matrix()).all

        # numpy array with one windows row for each person
        windows = self.slice_windows_by_row_id(window_row_ids)

        # t0 = tracing.print_elapsed_time("slice_windows_by_row_id", t0, debug=True)

        x = tour_footprints + (windows << I_BIT_SHIFT)

        available = ~np.isin(x, COLLISION_LIST).any(axis=1)
        available = pd.Series(available, index=window_row_ids.index)

        # t0 = tracing.print_elapsed_time("available", t0, debug=True)

        return available
Example #5
0
 def get_maz(self, maz_list, attribute):
     return quick_loc_df(maz_list, self.maz_df, attribute)
Example #6
0
 def get_tap(self, tap_list, attribute):
     return quick_loc_df(tap_list, self.tap_df, attribute)