点赞发Nature
关注中Science

Matlab DEA 程序包
pyDEA安装
非径向距离函数
考虑非期望产出的非径向距离函数

这一版更新比较简单,增加了强处置性假设下的非径向距离函数(NDDF)计算。比较强\弱处置假设下的NDDF,可以计算相应的环境规制成本[ Technological Forecasting & Social Change 96 (2015) 62–70].

import numpy as np
import os
import pandas as pd
import pickle
import pulp
import timedef read_excel(iteration):dea_inout = pd.read_excel(os.path.join(dir_data, xls), sheet_name=str(iteration), header=0)return dea_inoutclass DEAProblem:def __init__(self, inputs, outputs, bad_outs, weight_vector,  disp='weak disposability', directional_factor=None, returns='CRS',in_weights=[0, None], out_weights=[0, None],badout_weights=[0, None]):self.inputs = inputsself.outputs = outputsself.bad_outs = bad_outsself.returns = returnsself.disp = dispself.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 outputs_, self.S = self.bad_outs.shape # no of bad outputsself._i = range(self.I)  # inputsself._r = range(self.R)  # outputsself._s = range(self.S)  # bad_outputself._j = range(self.J)  # DMUsif directional_factor == None:self.gx = self.inputsself.gy = self.outputsself.gb = self.bad_outselse:self.gx = directional_factor[:self.I]self.gy = directional_factor[self.I:(self.I+self.J)]self.gy = directional_factor[(self.I+self.J):]self._in_weights = in_weights  # input weight restrictionsself._out_weights = out_weights  # output weight restrictionsself._badout_weights = badout_weights # bad 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,upBound=1)self.betay = pulp.LpVariable.dicts("scalingFacotr_y", (self._r),lowBound=0)self.betab = pulp.LpVariable.dicts("scalingFacotr_b", (self._s),lowBound=0, upBound=1)# 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]+[(self.weight_vector[self.I+self.R+s]*self.betab[s]) for s in self._s])# 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]if  self.disp == "weak disposability":  for s in self._s:   # weak disposabilityprob += pulp.lpSum([(self.weights[j0]*self.bad_outs.values[j0][s]) for j0 in self._j]) == self.bad_outs.values[j0][s]-self.betab[s]*self.gb.values[j0][s]elif self.disp =="strong disposability":for s in self._s:prob += pulp.lpSum([(self.weights[j0]*self.bad_outs.values[j0][s]) for j0 in self._j]) >= self.bad_outs.values[j0][s]-self.betab[s]*self.gb.values[j0][s] 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_weightsdef inout_data(iteration, data_columnslist):dea_data = read_excel(iteration)data_df = dea_data.loc[:, data_columnslist]return data_dfdef results_df(inputs, outputs, undesirable_output, weight, names, disp):solve = DEAProblem(inputs, outputs, undesirable_output, weight,disp).solve()status = pd.DataFrame.from_dict(solve[0], orient="index", columns=["status"])efficiency = pd.DataFrame.from_dict(solve[1], orient="index", columns=["efficiency"])weight = pd.DataFrame.from_dict(solve[2], orient="index")results = pd.concat([names, status, efficiency, weight], axis=1)return results.round(decimals=4)dir_data = r"~\Data_input"
xls = r"DEA_inout.xlsx"input_columns = ["a", "b", "c"]
output_columns = ["d"]
undesirable_outputs = ["e", "f"]
weight = [0, 0, 1 / 3, 1 / 3, 1 / 6, 1 / 6]
names = ["DMU name"]
iteration = 1000

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. https://doi.org/10.1016/j.ecolind.2021.107717
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:强/弱处置性假设下的考虑非期望产出的非径向距离函数相关推荐

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

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

  2. 绿色全要素生产率,python,采用全局生产技术的弱可处置性非径向方向距离函数(NDDF),可调方向权重,DDF,DEA

    文章目录 一.NDDF是什么? 1. 采用方法 2.具体参数解释 3.强弱可处置性 二.代码 1.参考与改进 1.1约束条件关键代码解释 2.示例 三.绿色指标 四.非全局生产技术的弱可处置性非径向方 ...

  3. 基于含有非期望产出的SBM模型的共同前沿和群组前沿的DEA效率测算

    今天介绍一个新的DEA模型,即基于含有非期望产出SBM模型测算群组前沿和共同前沿的DEA效率,在研究能源效率时常常用到. 由于各省之间的能源使用效率,受限于经济发展水平等诸多因素的限制,因此各省面对的 ...

  4. 带有非期望产出的SBM模型(python)

    文章目录 带有非期望产出的SBM模型(python实现) 1.原理 2.python代码 3.使用案例 带有非期望产出的SBM模型(python实现) from scipy.optimize impo ...

  5. EBM、DEA-SBM模型集合大全(普通的、非期望产出的、超效率的、CRS、VRS条件下的)

    CSDN里面几乎没有一个正确的该模型代码,本人分享代码的测算结果已发表在C刊.\n\nclc\n\nclear\n\nX =[];%投入指标数据\n\nY = [];%期望产出指标数据\n\nZ = ...

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

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

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

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

  8. VRS、CRS条件下非期望产出超效率SBM模型,以及普通SBM模型(可计算冗余度)

    之前更新了一个帖子是VRS条件下非径向非导向条件下超效率SBM模型,现如今更新出CRS条件下(两者可配合使用),一般CRS条件下测出来的结果更好分析(没有效率值忽高忽低现象):此外尽管现在众多期刊上的 ...

  9. Ionic3类的继承

    先上代码,后期后时间再分析. 父类不需要在任何module中进行引入.只需要在使用的子类头部import就能使用. 父类:base.ts import { ExxDbProvider } from ' ...

最新文章

  1. 数据库设计 之设计 表字段类型
  2. java 动态解析_Java 如何解析key为动态的json操作
  3. 分布式调用跟踪系统的设计和应用
  4. MongoDB在windows服务器安装部署及远程连接MongoDB
  5. oracle的all函数,oracle函数 MIN([distinct|all]x)
  6. postman接口测试和压力测试
  7. 特征选择算法java实现_relief算法特征选择
  8. HikariCP连接池配置
  9. static_cast、dynamic_cast、reinterpret_cast、const_cast[转]
  10. 图书管理系统jsp代码_【程序源代码】使用Java开发的图书管理系统
  11. AAAI 2018 论文 | 蚂蚁金服公开最新基于笔画的中文词向量算法
  12. Matlab 常用语法速记 1
  13. mysql 会话级别的参数_PostgreSQL的参数设置级别及查询各级别的参数值
  14. 微信小程序通用功能设计和实现
  15. java邮箱代码_java邮箱开发代码——发邮件
  16. hihocoder第233周
  17. 将图像转为特征值_用K均值进行图像分割
  18. Caffe 框架介绍
  19. php国际象棋棋盘奇行奇列,国际象棋怎么玩
  20. 用php语言说句情话,说给女朋友的感动情话50句

热门文章

  1. ThreeJS入门篇(1)开场扯淡
  2. MLX90632传感器调试
  3. 计算机X线摄影的英文表达是( ),计算机X线摄影(国外英文资料).doc
  4. 一维Burgers方程的学习——来自流沙公众号
  5. 等保:网络安全等级保护
  6. 前端vue项目,把某个div盒子或当前页面生成pdf文件并下载。
  7. 吴恩达机器学习笔记(四)
  8. VNote Markdown 工具 <ubuntu>
  9. android录像限制大小,uni-app 拍摄视频限制最大长度解决方案
  10. CloudFront CDN简介