OPTIMIZING ELECTRICITY TRANSMISSION COST USING PYTHON

Reia Natu
Analytics Vidhya

--

PROBLEM STATEMENT

Powerco has 3 electric power plants that supply the needs of 4 cities as shown in the table below. The costs of sending 1 million kwh of electricity from a plant to a city depend on the distance the electricity must travel.

The peak power demands in these cities occur at the same time (2 P.M).

Objective: To obtain the optimal cost of meeting each city’s peak power demand.

PROPOSED SOLUTION:

Firstly, the problem at hand is a ‘Transportation Problem (TP)’ which is a special type of linear programming problem (LPP) wherein the objective is to minimize the cost of distributing a product (in our study it is the electricity transmitted) from a number of sources (power plants) to a number of destinations (cities).

We will be solving this TP by implementing the Gurobi Optimizer in Python as follows:

The process of the proposed solution begins with identifying the sets from the problem statement. Plants 0, 1, 2 and Cities (0, 1, 2, 3) are the identified sets which can be modelled as follows:

Next, we will input the data we have- this includes the cost matrix, the demand at each of the cities and the supply by each of the power plants as:

Now the TP Model can be described as an LPP as:

It is important to note that we do not have information about the number of (million) kwh produced and then supplied by a plant i which is further sent to a city j.

Thereby, let us now declare a variable:

This can be fed into the LP model by declaring it as below:

Further, mathematically, the optimal solution for the problem at hand would mean calculating the minimum cost associated with transmitting electricity from a plant to a city keeping in mind the supply and demand requirements.

The mathematical formulation of the objective would be:

This can be incorporated in the TP using the Gurobi Optimizer as:

Having specified all this, we will now include the constraints. This problem identifies 3 types of constraints- the demand constraint, the supply constraint and the non-negativity constraint. Out of these three, the non-negativity constraint is written as:

This constraint stresses on the fact that at any point, the number of kwh transmitted would be a positive amount. However, this is just written in theory and taken care of at the back-end by Gurobi.

The remaining 2 constraints can be explained as follows:

  1. Demand Constraint

2. Supply Constraint

These constraints can be modelled using Gurobi in Python as:

Our model has been now been formulated; let us print the optimized cost calculated by the Gurobi Optimizer.

The output below suggests that the optimized cost to transmit electricity from the plants to the cities while abiding by the constraints comes to $1190.

Further, let’s get some insight into the proposed plan to see if we have satisfied all the conditions to arrive at the optimized cost by performing Sensitivity Analysis.

The output above proves that the demand for each city is met without exceeding the supply of any of the plants, say for instance- For City 0, the demand is 45 million kwh which is supplied using 5 million kwh from Plant 0, and 20 million kwh each from the other 2 plants; this still does not exhaust the maximum capacity supplied by each plant and the aggregate supplied by each of the plants to any of the cities stays within the supply limit for the overall model. This proves that the cost $1190 is the optimum cost of transmission.

In a nutshell, a snapshot of the supply meets demand transmission plan for $1190 can be viewed as:

--

--

Reia Natu
Analytics Vidhya

Data Scientist | 15K+ Data Science Family on Instagram @datasciencebyray | LinkedIn- https://in.linkedin.com/in/reia-natu-59638b31a |