(
        lcm, choosers, alternatives, alt_segmenter,
        clip_change_low, clip_change_high, multiplier_func=None)
return alts_muliplier, multiplier, finished
Calculate adjustments to prices to compensate for
    supply and demand effects.

    Parameters
    ----------
    lcm : LocationChoiceModel
        Used to calculate the probability of agents choosing among
        alternatives. Must be fully configured and fitted.
    choosers : pandas.DataFrame
    alternatives : pandas.DataFrame
    alt_segmenter : pandas.Series
        Will be used to segment alternatives and probabilities to do
        comparisons of supply and demand by submarket.
    clip_change_low : float
        The minimum amount by which to multiply prices each iteration.
    clip_change_high : float
        The maximum amount by which to multiply prices each iteration.
    multiplier_func : function (returns Series, boolean)
        A function which takes separate demand and supply Series
        and returns a tuple where the first item is a Series with the
        ratio of new price to old price (all indexes should be the same) -
        by default the ratio of demand to supply is the ratio of the new
        price to the old price.  The second return value is a
        boolean which when True tells this module to stop looping (that
        convergence has been satisfied)

    Returns
    -------
    alts_muliplier : pandas.Series
        Same index as `alternatives`, values clipped to `clip_change_low`
        and `clip_change_high`.
    submarkets_multiplier : pandas.Series
        Index is unique values from `alt_segmenter`, values are the ratio
        of demand / supply for each segment in `alt_segmenter`.
    finished : boolean
        boolean indicator that this adjustment should be considered the
        final adjustment (if True).  If false, the iterative algorithm
        should continue.
Calculate adjustments to prices to compensate for
    supply and demand effects.
Calculate adjustments to prices to compensate for supply and demand effects .
def _calculate_adjustment(
        lcm, choosers, alternatives, alt_segmenter,
        clip_change_low, clip_change_high, multiplier_func=None):
    """
    Calculate adjustments to prices to compensate for
    supply and demand effects.

    Parameters
    ----------
    lcm : LocationChoiceModel
        Used to calculate the probability of agents choosing among
        alternatives. Must be fully configured and fitted.
    choosers : pandas.DataFrame
    alternatives : pandas.DataFrame
    alt_segmenter : pandas.Series
        Will be used to segment alternatives and probabilities to do
        comparisons of supply and demand by submarket.
    clip_change_low : float
        The minimum amount by which to multiply prices each iteration.
    clip_change_high : float
        The maximum amount by which to multiply prices each iteration.
    multiplier_func : function (returns Series, boolean)
        A function which takes separate demand and supply Series
        and returns a tuple where the first item is a Series with the
        ratio of new price to old price (all indexes should be the same) -
        by default the ratio of demand to supply is the ratio of the new
        price to the old price.  The second return value is a
        boolean which when True tells this module to stop looping (that
        convergence has been satisfied)

    Returns
    -------
    alts_muliplier : pandas.Series
        Same index as `alternatives`, values clipped to `clip_change_low`
        and `clip_change_high`.
    submarkets_multiplier : pandas.Series
        Index is unique values from `alt_segmenter`, values are the ratio
        of demand / supply for each segment in `alt_segmenter`.
    finished : boolean
        boolean indicator that this adjustment should be considered the
        final adjustment (if True).  If false, the iterative algorithm
        should continue.

    """
    logger.debug('start: calculate supply and demand price adjustment ratio')
    # probabilities of agents choosing * number of agents = demand
    demand = lcm.summed_probabilities(choosers, alternatives)
    # group by submarket
    demand = demand.groupby(alt_segmenter.loc[demand.index].values).sum()

    # number of alternatives
    supply = alt_segmenter.value_counts()

    if multiplier_func is not None:
        multiplier, finished = multiplier_func(demand, supply)
    else:
        multiplier, finished = (demand / supply), False
    multiplier = multiplier.clip(clip_change_low, clip_change_high)

    # broadcast multiplier back to alternatives index
    alts_muliplier = multiplier.loc[alt_segmenter]
    alts_muliplier.index = alt_segmenter.index

    logger.debug(
        ('finish: calculate supply and demand price adjustment multiplier '
         'with mean multiplier {}').format(multiplier.mean()))
    return alts_muliplier, multiplier, finished
def _calculate_adjustment ( lcm , choosers , alternatives , alt_segmenter , clip_change_low , clip_change_high , multiplier_func = None ) : logger . debug ( 'start: calculate supply and demand price adjustment ratio' ) # probabilities of agents choosing * number of agents = demand demand = lcm . summed_probabilities ( choosers , alternatives ) # group by submarket demand = demand . groupby ( alt_segmenter . loc [ demand . index ] . values ) . sum ( ) # number of alternatives supply = alt_segmenter . value_counts ( ) if multiplier_func is not None : multiplier , finished = multiplier_func ( demand , supply ) else : multiplier , finished = ( demand / supply ) , False multiplier = multiplier . clip ( clip_change_low , clip_change_high ) # broadcast multiplier back to alternatives index alts_muliplier = multiplier . loc [ alt_segmenter ] alts_muliplier . index = alt_segmenter . index logger . debug ( ( 'finish: calculate supply and demand price adjustment multiplier ' 'with mean multiplier {}' ) . format ( multiplier . mean ( ) ) ) return alts_muliplier , multiplier , finished