mfrm.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:RevPy 作者: flix-tech 项目源码 文件源码
def demand_mass_balance_c(host_odemand, class_odemand, avail, host_recapture):
    """Solve Demand Mass Balance equation for class-level

    Parameters
    ----------
    host_odemand: int
        Observerd host demand
    class_odemand: int
        Observed class demand
    avail: dict
        Availability of demand open during period considered
    host_recapture: float
        Estimated host level recapture

    Returns
    -------
    tuple
        Estimated demand, spill and recapture
    """

    # if observed demand of a class is 0 demand mass balance can't
    # estimate demand and spill alone without additioanl information
    demand = spill = recapture = 0
    if class_odemand:
        recapture = host_recapture * class_odemand / host_odemand

        # availability of demand closed during period considered
        k = 1 - avail
        A = np.array([[1, -1], [-k, 1]])
        B = np.array([class_odemand - recapture, 0])
        demand, spill = solve(A, B)

    return demand, spill, recapture
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号