Intelligent Charging Strategy of Electric Vehicle

(1 customer review)


Total downloads: 4

This repository of code optimize the charging schedule of EV and maximizes the profit by reducing the charging cost. It also charges the vehicle upto 95% SoC. We used Ant Lion optimization algorithm to optimize the multiobjective nonlinear constraint problem of charging using MATLAB.

This repository contains:

  • Complete MATLAB code

Note:  We don’t support to copy this code for your academic submission. This is to ease your pain to start writing code from scratch. We suggest modifying the code for your work. The Optimization algorithms are quite dynamic, so we don’t claim the same improved results in every trial.


In the present scenario, Electrical vehicle charging (EVC) has more scope in the research field. The main issue in charging of vehicle battery is charging time; if charging time is more than the cost of charging increases. The price of the electricity supply increases due to the large demand for electricity for the vehicle battery charging. To overcome these types of issues an intelligent approach of EV charging is used.  A heuristic optimization called Ant Lion Optimization (ALO) is followed to minimize the charging time. It is a global optimization technique and provides better performance than previous used algorithm GA. You are reading this article at

Problem Formulation

The smart charger of Electric vehicle has all information like the initial state of charge, the desired state of charge, departure time, plug in time etc. All this information is passed through the controller which estimate the charging time and adjust the cost of charging. As soon as electric vehicle connects with charger, the controller calculates maximum charging time for the desired SoC. If the SoCdesired is not attained in that charging time then the vehicle will not take part in the scheduling and it charges fully without pool till desired SoC for customer’s satisfaction.

Pipeline to Optimize the EV Charging Schedule - Free-thesis
Pipeline to Optimize the EV Charging Schedule – Free-thesis

We used ALO as intelligent charging scheduler of electric vehicles. The two objective functions are combined to a single objective function.

Objective function to minimize the charging cost

The charging cost of the electric vehicle depends on the load variance. The nature of the load affects the electricity requirement. For heavy loads high demand of electricity is required so, charging cost increases and vice-versa. The objective function for this is

Minimizing the load variance

The load variance minimization is necessary as cost minimization inserts the load peak in the grid which results in power losses. So load variation is defined as:

Multi-objective function converted to single objective

We converted this multi-objective problem into a single objective as:

This objective function is optimized with the help of ant lion optimization considering few constraints. The main constraint is maximum power provided to each electric vehicle which should not be greater than the power provided to the charger. Following constraints are

ALO control of charging controller

The intelligent charging of electric vehicle depends on the power supplied to the vehicle for the charging purpose at each time stamp. This power is optimally tuned by the Ant Lion Optimization algorithm (ALO). Ant lion optimization is available on The equilibrium betwen ALO and EV charging schedule is shown in figure 2.

System between ALO optimization and EV charging - Free-Thesis
System between ALO optimization and EV charging – Free-Thesis

As shown in the figure the ALO module gets the power for all EV at each time stamp for charging in the input and updated objective function as equation 3 in the output. This output of the objective function is fed back to ALO which affects the power of the charging and minimize the objective function value. It is an iterative process and in each iteration, the position of the Ant lion’s will be updated and forward to PHEV charging module which then computes the value of objective function.

We considered 50 electric vehicles for the time stamp of 24 hrs and it makes the tuning variables of dimension 50×24= 1200. Each set of tuning parameter represents the ant lion’s and ant’s position. The ALO optimization method converges to minima by setting these 1200 variables in the fitness function. In each iteration, the ant’s position is updated to satisfy the constraints above. For the first iteration, the position of all ants and lion ants are initialized randomly within the limits of maximum and minimum power. A new matrix is saved for the objective value in every iteration for all ants and lion ants. Minimum value index in the matrix is the best value so far which is further updated by ALO. After a few iterations, the saturation value of the objective function is reached and no more minimum value is obtained. This is the termination criteria of ALO optimization algorithm which indicates that the best power set of all-electric vehicle in each time stamp is achieved. Earlier is this convergence better is the optimization. The equivalent terminology of ALO with the PHEV charging schedule application is shown in table 1.

Table 1: Terminology for PHEV in ALO
ALO terminology Equivalent terminology in PHEV charging scheduling
Searching space of ants and ant lions Minimum and maximum constraint of charging power for each vehicle
Dimension of searching space Number of tuning variables which is equal to
Fitness value Objective function value

 Steps for controlling of EV charging

  • consider the input attributes like maximum/ minimum power, maximum /minimum SoC, number of electric vehicles etc.
  • initialise the ant’s and ant lion’s positions randomly which is the power applied to each vehicle for the charging.
  • this power applied is sent to objective function module which considers the electric load in summer and winter separately with corresponding TOU price.
  • The parking time of each EV is randomly decided between 1-8 hrs.
  • Based on the charging rate, charging of each EV during that parking time is calculated by the charging power received.
  • check the constraints of state of charge (SoC). If it violates the limit then change the violated value with either minimum or maximum boundary which keeps them at the boundary as a penalty.
  • calculate the cost of charging for the given charging power based on per unit price from the grid.
  • calculate the load variation in due to the all EV charging
  • combine both values in step 7 and step 8 using equation 4.3 and pass these values to ALO module.
  • ALO update the previous charging power to minimize the objective function value in step 9 using equations from 3.2 to 3.8.
  • The minimum values out of all iterations are considered as the best power set supplied to the EV which occurs the minimum cost on the customer with least load variation in supply and with EV charged till desired SoC.



1 review for Intelligent Charging Strategy of Electric Vehicle

  1. Kay (verified owner)

    A good code for skipping a whole bunch of stress to develop a charging system. The code guides through the basics of charging and also helps understand meta-heuristic algorithms.

Only logged in customers who have purchased this product may leave a review.