点赞发Nature
关注中Science

最近在想怎么用python实现非径向距离函数

之前用了pyDEA包https://pypi.org/project/pyDEA/,那个包比较简陋,只有普通的CCR BCC模型。

另一方面,MaxDEA因为是打包好的嘛,所以不够灵活。所以想自己做一个NDDF的模型出来。

所以用pyDEA的初始代码进行了一些改造,直接上代码:

import numpy as np
import pandas as pd
import pulpclass DEAProblem:def __init__(self, inputs, outputs, weight_vector, directional_factor=None, returns='CRS',in_weights=[0, None], out_weights=[0, None]):self.inputs = inputsself.outputs = outputsself.returns = returnsself.weight_vector = weight_vector # weight vector in directional distance function      self.J, self.I = self.inputs.shape  # no of DMUs, inputs_, self.R = self.outputs.shape  # no of outputsself._i = range(self.I)  # inputsself._r = range(self.R)  # outputsself._j = range(self.J)  # DMUsif directional_factor == None:self.gx = self.inputsself.gy = self.outputselse:self.gx = directional_factor[:self.I]self.gy = directional_factor[-self.J:]self._in_weights = in_weights  # input weight restrictionsself._out_weights = out_weights  # output weight restrictions# creates dictionary of pulp.LpProblem objects for the DMUsself.dmus = self._create_problems()def _create_problems(self):"""Iterate over the DMU and create a dictionary of LP problems, onefor each DMU."""dmu_dict = {}for j0 in self._j:dmu_dict[j0] = self._make_problem(j0)return dmu_dictdef _make_problem(self, j0):"""Create a pulp.LpProblem for a DMU."""# Set up pulpprob = pulp.LpProblem("".join(["DMU_", str(j0)]), pulp.LpMaximize)self.weights = pulp.LpVariable.dicts("Weight", (self._j),lowBound=self._in_weights[0])self.betax = pulp.LpVariable.dicts("scalingFactor_x", (self._i),lowBound=0)self.betay = pulp.LpVariable.dicts("scalingFacotr_y", (self._r),lowBound=0)# Set returns to scaleif self.returns == "VRS":prob += pulp.lpSum([weight for weight in self.weights]) == 1# Set up objective function      prob += pulp.lpSum([(self.weight_vector[i]*self.betax[i]) for i in self._i]+[(self.weight_vector[self.I+r]*self.betay[r]) for r in self._r])# Set up constraintsfor i in self._i:prob += pulp.lpSum([(self.weights[j0]*self.inputs.values[j0][i]) for j0 in self._j]) <= self.inputs.values[j0][i]-self.betax[i]*self.gx.values[j0][i]for r in self._r:prob += pulp.lpSum([(self.weights[j0]*self.outputs.values[j0][r]) for j0 in self._j]) >= self.outputs.values[j0][r]+self.betay[r]*self.gy.values[j0][r]return probdef solve(self):"""Iterate over the dictionary of DMUs' problems, solve them, and collatethe results into a pandas dataframe."""sol_status = {}sol_weights = {}sol_efficiency = {}for ind, problem in list(self.dmus.items()):problem.solve()sol_status[ind] = pulp.LpStatus[problem.status]sol_weights[ind] = {}for v in problem.variables():sol_weights[ind][v.name] = v.varValuesol_efficiency[ind] = pulp.value(problem.objective)return sol_status, sol_efficiency, sol_weightssolve = DEAProblem(X, y, weight).solve()


该模块依据了这个公式:

文章是张宁老师13年发表在RESR上的综述,

该模块可以自行设定投入X, 产出Y, 方向向量g, 以及权重向量w

后续还得考虑把undesirable output也加入进去。

我在编程的时候发现产出扩张系数是有可能大于1的,我以前一直以为扩张系数就是无效率值,发现还是有些不一样的。

——————update——————
考虑非期望产出的NDDF
考虑强\弱处置性的非期望产出NDDF

Cite the work

Yang, F.; Choi, Y.: Lee, H. Life-cycle data envelopment analysis to measure efficiency and cost-effectiveness of environmental regulation in China’s transport sector. Ecological indicators 2021
Choi, Y.; Yang, F.; Lee, H. On the Unbalanced Atmospheric Environmental Performance of Major Cities in China. Sustainability 2020, 12, 5391. https://doi.org/10.3390/su12135391

————————
我是仁荷大学的博士生(我的google scholar, 我的Github),关注能源转型过程中的环境、经济问题。

专注于分享利用python科研的技巧,欢迎一起交流、学习、合作。

关于我的博客内容、其他相关的研究问题,有问题可以下方

python DEA: 非径向距离函数(non-radial directional distance function)相关推荐

  1. python DEA:强/弱处置性假设下的考虑非期望产出的非径向距离函数

    点赞发Nature 关注中Science Matlab DEA 程序包 pyDEA安装 非径向距离函数 考虑非期望产出的非径向距离函数 这一版更新比较简单,增加了强处置性假设下的非径向距离函数(NDD ...

  2. python DEA: 考虑非期望产出的非径向距离函数NDDF

    点赞发Nature 关注中Science 上一版非径向距离函数在这 普通非径向距离函数 现在很多研究在测度效率时要考虑非期望产出,如环境技术中CO2排放,银行业中的不良贷款等,这里我写了一个考虑非期望 ...

  3. python DEA: 基于非径向距离NDDF的Malmquist-Luenberger 指数及其分解

    点赞发Nature 关注中Science Malmquist-Lenberger指数(ML指数)是距离函数与DEA计算中常用的指数,ML指数可以进一步分解为技术进步technological prog ...

  4. python DEA: 零和数据包络分析zero-sum gain Data envelopment analysis

    点赞发Nature 关注中Science 在生产可能集中的资源再分配是在环境约束的生产过程中的一个新的研究课题.ZSG-DEA方法是解决资源分配问题的一个新兴方法.ZSG方法假设整个经济中的资源是固定 ...

  5. 2D基本图形的Sign Distance Function (SDF)详解(上)

    前言 符号距离函数(sign distancefunction),简称SDF,又可以称为定向距离函数(oriented distance function),在空间中的一个有限区域上确定一个点到区域边 ...

  6. 2D基本图形的Sign Distance Function (SDF)详解(下)

       符号距离函数(sign distancefunction),简称SDF,又可以称为定向距离函数(oriented distance function),在空间中的一个有限区域上确定一个点到区域边 ...

  7. Truncated Signed Distance Function: Experiments on Voxel Size

    论文:Truncated Signed Distance Function: Experiments on Voxel Size 简称:TSDF 作者:Diana Werner等 时间:2014 相关 ...

  8. Python中类(class)与函数(function)的区别

    分享知识  传递快乐 在 Python 中一直以来都以为函数(function)和方法(method)是一个东西,但后来发现两者是不一样的,那么两者之间有什么区别呢?先看段代码: 代码1: def f ...

  9. Python编程基础:第二十节 函数Function

    第二十节 函数Function 前言 实践 前言 目前为止,我们已经学习了常见的数据类型以及逻辑结构.但是代码都只能运行一次,如果想多次运行该段代码就得重复写多次.为了避免书写冗余的代码,我们需要引入 ...

  10. Python核心:5. 容器类型和6.函数function

    5. 容器类型 5.1 通用操作 5.1.1 数学运算符 运算符 说明 + 用于拼接两个容器 += 用原容器与右侧容器拼接,并重新绑定变量 * 重复生成容器元素 *= 用原容器生成重复元素, 并重新绑 ...

最新文章

  1. 围棋棋盘上的波粒二象性
  2. pyecharts官方文档_中国疫情地图pyecharts
  3. mysql数据库通过二进制 -【恢复数据记录】
  4. [App Store Connect帮助]八、维护您的 App(4.2)查看评分与评论
  5. TextRank、BM25算法提取关键字、文章自动摘要优秀文章保存
  6. 如何用Pygame写游戏(二十一)
  7. 极简风格的响应式简历模板
  8. 2017.9.24 三色二叉树 思考记录
  9. pandas_空值填充|重复数据|异常数据
  10. HDU 2825 AC自动机+状压dp
  11. vivado sata ip (phy)配置
  12. mkfs.ext3 快速格式化_求救!固态硬盘格式化不了!
  13. 『 云原生·Docker』Docker镜像分层与Docker镜像操作(二)
  14. python查找第k大的数_寻找数组中第K大的数
  15. windows11 取消windows登录密码 共享文件夹 输入法 去掉屏保广告 右键恢复原样
  16. 枚举---枚举的其他应用
  17. ps grep 不包括grep本身
  18. Python作业day2购物车
  19. 18岁误入网站_是市场驱动的技术领先现代医学误入歧途
  20. android图片加载过程,教你写Android ImageLoader框架之图片加载与加载策略

热门文章

  1. 23个热门python爬虫项目,爬虫仍需谨慎,牢饭不是很香!!!
  2. 如何让研发薪酬更具有吸引力?华为、阿里、腾讯的方法值得借鉴
  3. 使用Tftpd64收集交换机日志
  4. php商家商城,PHP红色小京东多商家入驻商城带移动端运营版
  5. Glide框架加载gif动态图优化
  6. 自媒体文章采集工具,采集多个平台的文章
  7. (7) PyQt 设计并实现【工厂扫码装箱系统】- Python代码实现BarTender自动化打印条码标签
  8. Jmeter基础篇(01):如何进行post接口压力测试
  9. web网页设计期末课程大作业 基于HTML仿淘宝电商网站项目的设计与实现 企业网站制作
  10. Tensorflow中PRelu实现细节