【问题标题】:Algorithm for market clearing市场出清算法
【发布时间】:2017-07-20 09:46:12
【问题描述】:

我有供需的离散阶跃函数。我正在寻找一种算法来找到均衡价格,数据在下面R,但是任何语言(或伪代码)的解决方案都是可以接受的。

demand = data.frame(volume = c(8,2,3,1,1), price=c(1,2,3,4,5))
supply = data.frame(volume = c(3,2,4,2,3), price=c(5,4,3,2,1))

demand$volume <- cumsum(demand$volume)
supply$volume <- cumsum(supply$volume)

plot(demand, type="s")
lines(supply, type="s", col=3)

【问题讨论】:

  • 我没有看到 qd=qs 的点。我不是真正的经济学人,但我记得 qd=qs 是平衡点。上述案例的输出应该是什么?
  • @Vidor Vistrom 你是对的,我已经修好了

标签: algorithm optimization discrete-mathematics economics


【解决方案1】:

您需要从价格范围的两端获取部分 cumsum 交易量。

demand_cum = (15, 7, 5,  2,  1)
supply_cum = ( 3, 5, 9, 11, 14)

这向您显示每个价格的总、累积需求和供应。 现在你能找到平衡点了吗?

【讨论】:

    【解决方案2】:

    我正在研究一个类似的问题,发现这个很好的描述:https://www.youtube.com/watch?v=FYfbM56L-mE&ab_channel=31761-Renewablesinelectricitymarkets

    您可以针对您的问题进行类似的分析。考虑一个 LP 公式。给定对偶解,您可以找到市场出清价格如下:

    demand = data.frame(Type = "demand",Q = c(8,2,3,1,1), P=c(1,2,3,4,5))
    supply = data.frame(Type = "supply",Q = c(3,2,4,2,3), P=c(5,4,3,2,1))
    ds <- rbind(supply,demand)
    

    通过表示来自 LP 的问题,执行以下操作:

    ds[ds$Type == "demand","Q"] <- ds[ds$Type == "demand","Q"]
    ds[ds$Type == "supply","Q"] <- ds[ds$Type == "supply","Q"]
    
    P_s <- ds[ds$Type == "supply","P"]
    P_d <- ds[ds$Type == "demand","P"]
    Q_s <- ds[ds$Type == "supply","Q"]
    Q_d <- ds[ds$Type == "demand","Q"]
    c_vec <- c(P_s,-P_d)
    A_mat <- diag(length(c_vec))
    b_vec <- c(Q_s,Q_d)
    dir_1 <- rep("<=",length(b_vec))
    
    A2_mat <- c(rep(1,length(Q_s)),rep(-1,length(Q_d)))
    b2_vec <- 0
    
    A_mat <- rbind(A_mat,A2_mat)
    b_vec <- c(b_vec,b2_vec)
    dir_1 <- c(dir_1,"=")
    
    library(lpSolve)
    sol <- lp ("min", c_vec, A_mat, dir_1, b_vec, compute.sens=TRUE)
    price_mc <- sol$duals[nrow(ds) + 1] # extracts the dual, which corresponds to the price
    

    在您的示例中,市场清算价格为 2 美元。

    【讨论】:

      猜你喜欢
      • 2019-10-16
      • 1970-01-01
      • 2014-02-25
      • 1970-01-01
      • 2023-03-03
      • 2013-10-18
      • 2020-09-20
      • 2013-01-25
      • 1970-01-01
      相关资源
      最近更新 更多