# Efficiency Analysis 


## Objective and Prerequisites

How can mathematical optimization be used to measure the efficiency of an organization? Find out in this example, where you’ll learn how to formulate an Efficiency Analysis model as a linear programming problem using the Gurobi Python API and then generate an optimal solution with the Gurobi Optimizer.

This model is example 22 from the fifth edition of Model Building in Mathematical Programming by H. Paul Williams on pages 278-280 and 335-336.

This example is at the intermediate level, where we assume that you know Python and the Gurobi Python API and that you have some knowledge of building mathematical optimization models.

**Download the Repository** <br /> 
You can download the repository containing this and other examples by clicking [here](https://github.com/Gurobi/modeling-examples/archive/master.zip). 

**Gurobi License** <br /> 
In order to run this Jupyter Notebook properly, you must have a Gurobi license. If you do not have one, you can request an [evaluation license](https://www.gurobi.com/downloads/request-an-evaluation-license/?utm_source=3PW&utm_medium=OT&utm_campaign=WW-MU-MUI-OR-O_LEA-PR_NO-Q3_FY20_WW_JPME_Efficiency_Analysis_COM_EVAL_GitHub&utm_term=Efficiency%20Analysis&utm_content=C_JPM) as a *commercial user*, or download a [free license](https://www.gurobi.com/academia/academic-program-and-licenses/?utm_source=3PW&utm_medium=OT&utm_campaign=WW-MU-EDU-OR-O_LEA-PR_NO-Q3_FY20_WW_JPME_Efficiency_Analysis_COM_EVAL_GitHub&utm_term=Efficiency%20Analysis&utm_content=C_JPM) as an *academic user*.

## Background

 The Data Envelopment Analysis (DEA) is a nonparametric problem in operations research and economics whose solution is an estimation of production frontiers. It is used to empirically measure the productive efficiency of decision making units (DMUs). There are a number of linear programming formulations of the DEA problem. Fuller coverage of the subject can be found in Farrell (1957), Charnes et al. (1978) and Thanassoulis et al. (1987). The formulation given by H.P. Williams is described in Land (1991). This formulation is the dual model of a model  commonly used that relies on finding weighted ratios of outputs to inputs. We will use the formulation that is commonly used and can be found in Cooper et al. (2007).

The Data Envelopment Analysis has been used to evaluate the performance of many different kinds of entities engaged in many different activities, and in many different contexts in many different countries. Examples include the maintenance activities of U.S. Air Force bases in different geographic locations, or police forces in England and Wales as well as the performance of branch banks in Cyprus and Canada and the efficiency of universities in performing their education and research functions in the U.S., England and France. 

The DEA approach is concerned with evaluations of *efficiency*. The most common measure of efficiency takes the form of a ratio like the following one:

$$
\text{efficiency} = \frac{\text{output}}{\text{input}}
$$



## Model Formulation

Assume there is a set of DMUs. Some common input and output items for each of these DMUs are selected as follows:
1. Numerical data are available for each input and output, with the data assumed to be positive, for all DMUs.
2. The items (inputs, outputs and choice of DMUs) should reflect an analyst's or a manager's interest in the components that will enter into the relative efficiency evaluations of the DMUs.
3. In principle, smaller input amounts are preferable and larger output amounts are preferable so the efficiency scores should reflect these principles.
4. The measurement units of the different inputs and outputs do not need to be congruent. Some may involve a number of persons, or areas of floor space, money expended, etc.

### Fractional problem formulation
The proposed measure of the efficiency of a target DMU $k$ is obtained as the maximum of a ratio of weighted outputs to weighted inputs subject to the condition that the similar ratios for every DMU be less than or equal to one.

### Sets and indices

$j,k \in \text{DMUS}$: Indices and set of DMUs, where $k$ represents the target DMU.

$i \in \text{Inputs}$: Index and set of inputs.

$r \in \text{Outputs}$: Index and set of outputs.

### Parameters

$\text{invalue}_{i,j} > 0$: Value of input $i$ for DMU $j$.

$\text{outvalue}_{r,j} > 0$: Value of output $r$ for DMU $j$.

### Decision Variables

$u_{r} \geq 0$: Weight of output $r$.

$v_{i} \geq 0$: Weight of input  $i$.

### Objective function

**Target DMU Efficiency**: Maximize efficiency at the target DMU $k$.

$$
\text{Maximize} \quad E_k = 
\frac{\sum_{r \in \text{Outputs}} \text{outvalue}_{r,k}*u_{r}}{\sum_{i \in \text{Inputs}} \text{invalue}_{i,k}*v_{i}}
\tag{FP0}
$$


### Constraints

**Efficiency ratios**: The efficiency of a DMU is a number between $[0,1]$.

\begin{equation}
\frac{\sum_{r \in \text{Outputs}} \text{outvalue}_{r,j}*u_{r}}{\sum_{i \in \text{Inputs}} \text{invalue}_{i,j}*v_{i}}
 \leq 1 \quad \forall j \in \text{DMUS}
 \tag{FP1}
\end{equation}



### Linear programming problem formulation

This linear programming formulation can be found in the book by Cooper et al. (2007).

### Objective function

**Target DMU Efficiency**: Maximize efficiency at the target DMU $k$.

$$
\text{Maximize} \quad E_k = \sum_{r \in \text{Outputs}} \text{outvalue}_{r,k}*u_{r}
\tag{LP0}
$$


### Constraints

**Efficiency ratio**: The efficiency of a DMU is a number between $[0,1]$.

\begin{equation}
\sum_{r \in \text{Outputs}} \text{outvalue}_{r,j}*u_{r} -
\sum_{i \in \text{Inputs}} \text{invalue}_{i,k}*v_{i}
 \leq 0  \quad \forall j \in \text{DMUS}
\tag{LP1}
\end{equation}

**Normalization**: This constraint ensures that the denominator of the objective function of the fractional problem is equal to one.

\begin{equation}
\sum_{i \in \text{Inputs}} \text{invalue}_{i,k}*v_{i} = 1 
\tag{LP2}
\end{equation}

It is easy to verify that the fractional problem and the linear programming problem are equivalent. Let's assume that the denominator of the efficiency ratio constraints of the fractional problem is positive for all DMUs, then we can obtain the constraints $LP1$ by multiplying both sides of the constraints $FP1$ by the denominator. Next, we set the denominator of $FP0$ eqaul to 1 and define constraint $LP2$, and then maximize the numerator, resulting in the objective function $LP0$.

### Definition of efficiency

1. $DMU_k$ is efficient if the optimal objective function value $E_{k}^{*} = 1$.
2. Otherwise, $DMU_k$ is inefficient.

## Problem Description

A car manufacturer wants to evaluate the efficiencies of different garages that have been granted a license to sell its cars. Each garage has a certain number of measurable ‘inputs’:
* Staff 
* Showroom Space
* Population in category 1
* Population in category 2
* Enquiries Alpha model
* Enquiries Beta model

Each garage also has a certain number of measurable ‘outputs’:
* Number Sold of different brands of car 
* annual Profit

The following table gives the inputs and outputs for each of the 28 franchised garages. 




The goal is to identify efficient and inefficient garages and their input-output weights. In order to solve this problem, it is necessary to solve the LP model for each garage.

---
## Python Implementation

We import the Gurobi Python Module and other Python libraries.

### Helper Functions

* `solve_DEA` builds and solves the LP model.


```python
import numpy as np
import pandas as pd
from itertools import product

import gurobipy as gp
from gurobipy import GRB

# tested with Python 3.7.0 & Gurobi 9.1.0
```


```python
def solve_DEA(target, verbose=True):
    # input-output values for the garages
    inattr = ['staff', 'showRoom', 'Population1', 'Population2', 'alphaEnquiries', 'betaEnquiries']
    outattr = ['alphaSales', 'BetaSales', 'profit']
    
    dmus, inputs, outputs = gp.multidict({
        'Winchester': [{'staff': 7, 'showRoom': 8, 'Population1': 10, 'Population2': 12, 'alphaEnquiries': 8.5, 'betaEnquiries': 4}, {'alphaSales': 2, 'BetaSales': 0.6, 'profit': 1.5}],
        'Andover': [{'staff': 6, 'showRoom': 6, 'Population1': 20, 'Population2': 30, 'alphaEnquiries': 9, 'betaEnquiries': 4.5}, {'alphaSales': 2.3, 'BetaSales': 0.7, 'profit': 1.6}],
        'Basingstoke': [{'staff': 2, 'showRoom': 3, 'Population1': 40, 'Population2': 40, 'alphaEnquiries': 2, 'betaEnquiries': 1.5}, {'alphaSales': 0.8, 'BetaSales': 0.25, 'profit': 0.5}],
        'Poole': [{'staff': 14, 'showRoom': 9, 'Population1': 20, 'Population2': 25, 'alphaEnquiries': 10, 'betaEnquiries': 6}, {'alphaSales': 2.6, 'BetaSales': 0.86, 'profit': 1.9}],
        'Woking': [{'staff': 10, 'showRoom': 9, 'Population1': 10, 'Population2': 10, 'alphaEnquiries': 11, 'betaEnquiries': 5}, {'alphaSales': 2.4, 'BetaSales': 1, 'profit': 2}],
        'Newbury': [{'staff': 24, 'showRoom': 15, 'Population1': 15, 'Population2': 13, 'alphaEnquiries': 25, 'betaEnquiries': 1.9}, {'alphaSales': 8, 'BetaSales': 2.6, 'profit': 4.5}],
        'Portsmouth': [{'staff': 6, 'showRoom': 7, 'Population1': 50, 'Population2': 40, 'alphaEnquiries': 8.5, 'betaEnquiries': 3}, {'alphaSales': 2.5, 'BetaSales': 0.9, 'profit': 1.6}],
        'Alresford': [{'staff': 8, 'showRoom': 7.5, 'Population1': 5, 'Population2': 8, 'alphaEnquiries': 9, 'betaEnquiries': 4}, {'alphaSales': 2.1, 'BetaSales': 0.85, 'profit': 2}],
        'Salisbury': [{'staff': 5, 'showRoom': 5, 'Population1': 10, 'Population2': 10, 'alphaEnquiries': 5, 'betaEnquiries': 2.5}, {'alphaSales': 2, 'BetaSales': 0.65, 'profit': 0.9}],
        'Guildford': [{'staff': 8, 'showRoom': 10, 'Population1': 30, 'Population2': 35, 'alphaEnquiries': 9.5, 'betaEnquiries': 4.5}, {'alphaSales': 2.05, 'BetaSales': 0.75, 'profit': 1.7}],
        'Alton': [{'staff': 7, 'showRoom': 8, 'Population1': 7, 'Population2': 8, 'alphaEnquiries': 3, 'betaEnquiries': 2}, {'alphaSales': 1.9, 'BetaSales': 0.70, 'profit': 0.5}],
        'Weybridge': [{'staff': 5, 'showRoom': 6.5, 'Population1': 9, 'Population2': 12, 'alphaEnquiries': 8, 'betaEnquiries': 4.5}, {'alphaSales': 1.8, 'BetaSales': 0.63, 'profit': 1.4}],
        'Dorchester': [{'staff': 6, 'showRoom': 7.5, 'Population1': 10, 'Population2': 10, 'alphaEnquiries': 7.5, 'betaEnquiries': 4}, {'alphaSales': 1.5, 'BetaSales': 0.45, 'profit': 1.45}],
        'Bridport': [{'staff': 11, 'showRoom': 8, 'Population1': 8, 'Population2': 10, 'alphaEnquiries': 10, 'betaEnquiries': 6}, {'alphaSales': 2.2, 'BetaSales': 0.65, 'profit': 2.2}],
        'Weymouth': [{'staff': 4, 'showRoom': 5, 'Population1': 10, 'Population2': 10, 'alphaEnquiries': 7.5, 'betaEnquiries': 3.5}, {'alphaSales': 1.8, 'BetaSales': 0.62, 'profit': 1.6}],
        'Portland': [{'staff': 3, 'showRoom': 3.5, 'Population1': 3, 'Population2': 20, 'alphaEnquiries': 2, 'betaEnquiries': 1.5}, {'alphaSales': 0.9, 'BetaSales': 0.35, 'profit': 0.5}],
        'Chichester': [{'staff': 5, 'showRoom': 5.5, 'Population1': 8, 'Population2': 10, 'alphaEnquiries': 7, 'betaEnquiries': 3.5}, {'alphaSales': 1.2, 'BetaSales': 0.45, 'profit': 1.3}],
        'Petersfield': [{'staff': 21, 'showRoom': 12, 'Population1': 6, 'Population2': 6, 'alphaEnquiries': 15, 'betaEnquiries': 8}, {'alphaSales': 6, 'BetaSales': 0.25, 'profit': 2.9}],
        'Petworth': [{'staff': 6, 'showRoom': 5.5, 'Population1': 2, 'Population2': 2, 'alphaEnquiries': 8, 'betaEnquiries': 5}, {'alphaSales': 1.5, 'BetaSales': 0.55, 'profit': 1.55}],
        'Midhurst': [{'staff': 3, 'showRoom': 3.6, 'Population1': 3, 'Population2': 3, 'alphaEnquiries': 2.5, 'betaEnquiries': 1.5}, {'alphaSales': 0.8, 'BetaSales': 0.20, 'profit': 0.45}],
        'Reading': [{'staff': 30, 'showRoom': 29, 'Population1': 120, 'Population2': 80, 'alphaEnquiries': 35, 'betaEnquiries': 20}, {'alphaSales': 7, 'BetaSales': 2.5, 'profit': 8}],
        'Southampton': [{'staff': 25, 'showRoom': 16, 'Population1': 110, 'Population2': 80, 'alphaEnquiries': 27, 'betaEnquiries': 12}, {'alphaSales': 6.5, 'BetaSales': 3.5, 'profit': 5.4}],
        'Bournemouth': [{'staff': 19, 'showRoom': 10, 'Population1': 90, 'Population2': 22, 'alphaEnquiries': 25, 'betaEnquiries': 13}, {'alphaSales': 5.5, 'BetaSales': 3.1, 'profit': 4.5}],
        'Henley': [{'staff': 7, 'showRoom': 6, 'Population1': 5, 'Population2': 7, 'alphaEnquiries': 8.5, 'betaEnquiries': 4.5}, {'alphaSales': 1.2, 'BetaSales': 0.48, 'profit': 2}],
        'Maidenhead': [{'staff': 12, 'showRoom': 8, 'Population1': 7, 'Population2': 10, 'alphaEnquiries': 12, 'betaEnquiries': 7}, {'alphaSales': 4.5, 'BetaSales': 2, 'profit': 2.3}],
        'Fareham': [{'staff': 4, 'showRoom': 6, 'Population1': 1, 'Population2': 1, 'alphaEnquiries': 7.5, 'betaEnquiries': 3.5}, {'alphaSales': 1.1, 'BetaSales': 0.48, 'profit': 1.7}],
        'Romsey': [{'staff': 2, 'showRoom': 2.5, 'Population1': 1, 'Population2': 1, 'alphaEnquiries': 2.5, 'betaEnquiries': 1}, {'alphaSales': 0.4, 'BetaSales': 0.1, 'profit': 0.55}],
        'Ringwood': [{'staff': 2, 'showRoom': 3.5, 'Population1': 2, 'Population2': 2, 'alphaEnquiries': 1.9, 'betaEnquiries': 1.2}, {'alphaSales': 0.3, 'BetaSales': 0.09, 'profit': 0.4}]
    })
    
    ### Create LP model
    model = gp.Model('DEA')
    
    # Decision variables
    wout = model.addVars(outattr, name="outputWeight")
    win = model.addVars(inattr, name="inputWeight")

    # Constraints
    ratios = model.addConstrs( ( gp.quicksum(outputs[h][r]*wout[r] for r in outattr ) 
                                - gp.quicksum(inputs[h][i]*win[i] for i in inattr ) 
                                <= 0 for h in dmus ), name='ratios' )
    
    normalization = model.addConstr((gp.quicksum(inputs[target][i]*win[i] for i in inattr ) == 1 ),
                                    name='normalization')
    
    # Objective function
    
    model.setObjective( gp.quicksum(outputs[target][r]*wout[r] for r in outattr ), GRB.MAXIMIZE)
    
    # Run optimization engine
    if not verbose:
        model.params.OutputFlag = 0
    model.optimize()
    
    # Print results
    print(f"\nThe efficiency of target DMU {target} is {round(model.objVal,3)}") 
    
    print("__________________________________________________________________")
    print(f"The weights for the inputs are:")
    for i in inattr:
        print(f"For {i}: {round(win[i].x,3)} ") 
        
    print("__________________________________________________________________")
    print(f"The weights for the outputs are")
    for r in outattr:
        print(f"For {r} is: {round(wout[r].x,3)} ") 
    print("__________________________________________________________________\n\n")  
    
    return model.objVal
```

## Input Data
We define the list of garages.


```python
dmus = ['Winchester','Andover','Basingstoke', 'Poole', 'Woking','Newbury','Portsmouth','Alresford','Salisbury','Guildford','Alton','Weybridge', 'Dorchester', 'Bridport', 'Weymouth', 'Portland', 'Chichester', 'Petersfield', 'Petworth', 'Midhurst', 'Reading', 'Southampton', 'Bournemouth', 'Henley', 'Maidenhead', 'Fareham', 'Romsey', 'Ringwood']
```

---
## Output Report

We print out the efficiency score of each garage and its associated input and output weights.


```python
# Solving DEA model for each DMU

performance = {}
for h in dmus:    
    performance[h] = solve_DEA(h, verbose=False)

```

    Using license file c:\gurobi\gurobi.lic
    
    The efficiency of target DMU Winchester is 0.835
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.012 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.002 
    For alphaEnquiries: 0.095 
    For betaEnquiries: 0.02 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.113 
    For BetaSales is: 0.004 
    For profit is: 0.404 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Andover is 0.917
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.115 
    For showRoom: 0.03 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.014 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.399 
    For BetaSales is: 0.0 
    For profit is: 0.0 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Basingstoke is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.429 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.071 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 1.25 
    For BetaSales is: 0.0 
    For profit is: 0.0 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Poole is 0.864
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.019 
    For Population1: 0.0 
    For Population2: 0.001 
    For alphaEnquiries: 0.081 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.065 
    For BetaSales is: 0.0 
    For profit is: 0.366 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Woking is 0.845
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.015 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.001 
    For alphaEnquiries: 0.062 
    For betaEnquiries: 0.032 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.0 
    For BetaSales is: 0.218 
    For profit is: 0.314 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Newbury is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.0 
    For betaEnquiries: 0.526 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.0 
    For BetaSales is: 0.0 
    For profit is: 0.222 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Portsmouth is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.149 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.0 
    For betaEnquiries: 0.036 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.4 
    For BetaSales is: 0.0 
    For profit is: 0.0 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Alresford is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.002 
    For alphaEnquiries: 0.098 
    For betaEnquiries: 0.026 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.081 
    For BetaSales is: 0.005 
    For profit is: 0.413 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Salisbury is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.087 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.113 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.5 
    For BetaSales is: 0.0 
    For profit is: 0.0 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Guildford is 0.802
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.014 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.075 
    For betaEnquiries: 0.036 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.062 
    For BetaSales is: 0.0 
    For profit is: 0.397 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Alton is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.333 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.0 
    For BetaSales is: 1.429 
    For profit is: 0.0 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Weybridge is 0.854
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.149 
    For showRoom: 0.0 
    For Population1: 0.028 
    For Population2: 0.0 
    For alphaEnquiries: 0.0 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.379 
    For BetaSales is: 0.0 
    For profit is: 0.122 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Dorchester is 0.867
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.014 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.003 
    For alphaEnquiries: 0.118 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.11 
    For BetaSales is: 0.0 
    For profit is: 0.484 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Bridport is 0.982
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.002 
    For Population1: 0.0 
    For Population2: 0.002 
    For alphaEnquiries: 0.096 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.06 
    For BetaSales is: 0.0 
    For profit is: 0.387 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Weymouth is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.25 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.0 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.556 
    For BetaSales is: 0.0 
    For profit is: 0.0 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Portland is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.0 
    For Population1: 0.032 
    For Population2: 0.0 
    For alphaEnquiries: 0.452 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.0 
    For BetaSales is: 0.0 
    For profit is: 2.0 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Chichester is 0.825
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.011 
    For showRoom: 0.008 
    For Population1: 0.0 
    For Population2: 0.002 
    For alphaEnquiries: 0.125 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.098 
    For BetaSales is: 0.0 
    For profit is: 0.545 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Petersfield is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.019 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.04 
    For betaEnquiries: 0.021 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.167 
    For BetaSales is: 0.0 
    For profit is: 0.0 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Petworth is 0.988
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.156 
    For Population1: 0.058 
    For Population2: 0.013 
    For alphaEnquiries: 0.0 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.141 
    For BetaSales is: 0.0 
    For profit is: 0.501 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Midhurst is 0.889
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.018 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.011 
    For alphaEnquiries: 0.366 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.294 
    For BetaSales is: 0.047 
    For profit is: 1.431 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Reading is 0.984
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.001 
    For showRoom: 0.006 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.023 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.019 
    For BetaSales is: 0.0 
    For profit is: 0.106 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Southampton is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.005 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.028 
    For betaEnquiries: 0.012 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.0 
    For BetaSales is: 0.057 
    For profit is: 0.149 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Bournemouth is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.1 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.0 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.0 
    For BetaSales is: 0.323 
    For profit is: 0.0 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Henley is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.161 
    For Population1: 0.007 
    For Population2: 0.0 
    For alphaEnquiries: 0.0 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.0 
    For BetaSales is: 0.0 
    For profit is: 0.5 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Maidenhead is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.122 
    For Population1: 0.004 
    For Population2: 0.0 
    For alphaEnquiries: 0.0 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.0 
    For BetaSales is: 0.5 
    For profit is: 0.0 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Fareham is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 1.0 
    For alphaEnquiries: 0.0 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.0 
    For BetaSales is: 2.083 
    For profit is: 0.0 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Romsey is 1.0
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.0 
    For alphaEnquiries: 0.31 
    For betaEnquiries: 0.224 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.0 
    For BetaSales is: 0.0 
    For profit is: 1.818 
    __________________________________________________________________
    
    
    
    The efficiency of target DMU Ringwood is 0.908
    __________________________________________________________________
    The weights for the inputs are:
    For staff: 0.0 
    For showRoom: 0.0 
    For Population1: 0.0 
    For Population2: 0.013 
    For alphaEnquiries: 0.512 
    For betaEnquiries: 0.0 
    __________________________________________________________________
    The weights for the outputs are
    For alphaSales is: 0.299 
    For BetaSales is: 0.0 
    For profit is: 2.044 
    __________________________________________________________________
    
    


---
## Analysis

We identify which garages are efficient and which ones are inefficient, and provide the efficiency scores for each garage.


```python
# Identifying efficient and inefficient DMUs

# Sorting garages in descending efficiency number
sorted_performance = {k: v for k, v in sorted(performance.items(), key=lambda item: item[1], reverse = True)}

efficient = []
inefficient = []

for h in sorted_performance.keys():
    if sorted_performance[h] >= 0.9999999:
        efficient.append(h) 
    if sorted_performance[h] < 0.9999999:
        inefficient.append(h) 
        
print('____________________________________________')
print(f"The efficient DMUs are:")
for eff in efficient:
    print(f"The performance value of DMU {eff} is: {round(performance[eff],3)}") 
    
print('____________________________________________')
print(f"The inefficient DMUs are:")
for ine in inefficient:
    print(f"The performance value of DMU {ine} is: {round(performance[ine],3)}") 

```

    ____________________________________________
    The efficient DMUs are:
    The performance value of DMU Newbury is: 1.0
    The performance value of DMU Alresford is: 1.0
    The performance value of DMU Salisbury is: 1.0
    The performance value of DMU Alton is: 1.0
    The performance value of DMU Weymouth is: 1.0
    The performance value of DMU Petersfield is: 1.0
    The performance value of DMU Southampton is: 1.0
    The performance value of DMU Bournemouth is: 1.0
    The performance value of DMU Maidenhead is: 1.0
    The performance value of DMU Fareham is: 1.0
    The performance value of DMU Romsey is: 1.0
    The performance value of DMU Basingstoke is: 1.0
    The performance value of DMU Portsmouth is: 1.0
    The performance value of DMU Portland is: 1.0
    The performance value of DMU Henley is: 1.0
    ____________________________________________
    The inefficient DMUs are:
    The performance value of DMU Petworth is: 0.988
    The performance value of DMU Reading is: 0.984
    The performance value of DMU Bridport is: 0.982
    The performance value of DMU Andover is: 0.917
    The performance value of DMU Ringwood is: 0.908
    The performance value of DMU Midhurst is: 0.889
    The performance value of DMU Dorchester is: 0.867
    The performance value of DMU Poole is: 0.864
    The performance value of DMU Weybridge is: 0.854
    The performance value of DMU Woking is: 0.845
    The performance value of DMU Winchester is: 0.835
    The performance value of DMU Chichester is: 0.825
    The performance value of DMU Guildford is: 0.802


## References

H. Paul Williams, Model Building in Mathematical Programming, fifth edition.

Cooper, W. W, L. M. Seiford, K. Tone. (2007) Data Envelopment Analysis: A Comprehensive Text with Models, Applications, References and DEA-Solver Software. Second edition. Springer-Verlag US.

Land, A. (1991) Data envelopment analysis, Chapter 5, in Operations Research in Management (eds S.C. Littlechild and M.F. Shutler), Prentice Hall, London.

Farrell, M.J. (1957) The measurement of productive efficiency. Journal of the Royal Statistical Society, Series A, 120, 253–290.

Charnes, A., Cooper, W.W. and Rhodes, E. (1978) Measuring the efficiency of decision making units. European Journal of Operational Research, 2, 429–444.

Thanassoulis, E., Dyson, R.G. and Foster, M.J. (1987) Relative efficiency assessments using data envelopment analysis: an application to data on rates departments. Journal of the Operational Research Society, 5, 397–411.

Copyright © 2020 Gurobi Optimization, LLC

e4279e7528ba062671618e83ce5ac32405490f98
ipynb
Jupyter Notebook
efficiency_analysis/efficiency_analysis.ipynb
Maninaa/modeling-examples
51575a453d28e1e9435abd865432955b182ba577
Apache-2.0
2021-11-29T07:42:12.000Z
2021-11-29T07:42:12.000Z
efficiency_analysis/efficiency_analysis.ipynb
Maninaa/modeling-examples
51575a453d28e1e9435abd865432955b182ba577
Apache-2.0
efficiency_analysis/efficiency_analysis.ipynb
Maninaa/modeling-examples
51575a453d28e1e9435abd865432955b182ba577
Apache-2.0
2021-11-29T07:41:53.000Z
2021-11-29T07:41:53.000Z
Qwen/Qwen-72B
1. YES
2. YES