python DEA: 非径向距离函数(non-radial directional distance function)
点赞发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)相关推荐
- python DEA:强/弱处置性假设下的考虑非期望产出的非径向距离函数
点赞发Nature 关注中Science Matlab DEA 程序包 pyDEA安装 非径向距离函数 考虑非期望产出的非径向距离函数 这一版更新比较简单,增加了强处置性假设下的非径向距离函数(NDD ...
- python DEA: 考虑非期望产出的非径向距离函数NDDF
点赞发Nature 关注中Science 上一版非径向距离函数在这 普通非径向距离函数 现在很多研究在测度效率时要考虑非期望产出,如环境技术中CO2排放,银行业中的不良贷款等,这里我写了一个考虑非期望 ...
- python DEA: 基于非径向距离NDDF的Malmquist-Luenberger 指数及其分解
点赞发Nature 关注中Science Malmquist-Lenberger指数(ML指数)是距离函数与DEA计算中常用的指数,ML指数可以进一步分解为技术进步technological prog ...
- python DEA: 零和数据包络分析zero-sum gain Data envelopment analysis
点赞发Nature 关注中Science 在生产可能集中的资源再分配是在环境约束的生产过程中的一个新的研究课题.ZSG-DEA方法是解决资源分配问题的一个新兴方法.ZSG方法假设整个经济中的资源是固定 ...
- 2D基本图形的Sign Distance Function (SDF)详解(上)
前言 符号距离函数(sign distancefunction),简称SDF,又可以称为定向距离函数(oriented distance function),在空间中的一个有限区域上确定一个点到区域边 ...
- 2D基本图形的Sign Distance Function (SDF)详解(下)
符号距离函数(sign distancefunction),简称SDF,又可以称为定向距离函数(oriented distance function),在空间中的一个有限区域上确定一个点到区域边 ...
- Truncated Signed Distance Function: Experiments on Voxel Size
论文:Truncated Signed Distance Function: Experiments on Voxel Size 简称:TSDF 作者:Diana Werner等 时间:2014 相关 ...
- Python中类(class)与函数(function)的区别
分享知识 传递快乐 在 Python 中一直以来都以为函数(function)和方法(method)是一个东西,但后来发现两者是不一样的,那么两者之间有什么区别呢?先看段代码: 代码1: def f ...
- Python编程基础:第二十节 函数Function
第二十节 函数Function 前言 实践 前言 目前为止,我们已经学习了常见的数据类型以及逻辑结构.但是代码都只能运行一次,如果想多次运行该段代码就得重复写多次.为了避免书写冗余的代码,我们需要引入 ...
- Python核心:5. 容器类型和6.函数function
5. 容器类型 5.1 通用操作 5.1.1 数学运算符 运算符 说明 + 用于拼接两个容器 += 用原容器与右侧容器拼接,并重新绑定变量 * 重复生成容器元素 *= 用原容器生成重复元素, 并重新绑 ...
最新文章
- 083 HBase的完全分布式的搭建与部署,以及多master
- c++中new和delete的使用方法
- npm升级package.json依赖包到最新版本号
- 【Party】现在只是一张普通的照片,以后可能就是历史。
- ceb文件在线查看_教你word、excel、ppt、pdf、ceb等格式免费转换,从此告别苦恼
- PE文件结构详解(六)重定位
- LeetCode 1051. 高度检查器
- 我和小美的撸码日记(1)之软件也需靠脸吃饭,带您做张明星脸(附后台经典框架 DEMO 下载)...
- 织梦dedecms模板--物流快递网站模板源码-带手机版数据同步
- 05-windows下SQL Developer连接Orcale
- 已有数据表的Mysql字符编码修改
- Spring Cloud与Docker微服务架构实战--阅读笔记
- sql server php删除,使用 SQL Server 添加删除修改查询储存过程
- esp8266控制ws2812b
- 转速双闭环matlab仿真,电流转速双闭环直流调速系统matlab仿真 实验.doc
- c#调用labview实现巴特沃斯滤波器
- 常用C++库及测试程序
- windows加载wim文件
- 【值得收藏】如此心机的老婆,不难教出一个优秀的女儿。谁娶了都是福。
- Modularity(模块化)