matlab improved whale algorithm for path optimization

Posted by ee12csvt on Thu, 11 Nov 2021 19:21:09 +0100

Overview of whale optimization algorithm

Whale Optimization Algorithm (WOA) is a meta heuristic algorithm based on humpback whale hunting method proposed by Mirjalili in 2016. It has been successfully applied to various complex discrete optimization problems, such as resource scheduling problem, construction site workflow planning, location and path planning, neural network training and so on. In terms of algorithm improvement and application, Yan Xu et al. Proposed a hybrid stochastic quantum Whale Optimization Algorithm to solve TSP problem; Teng Deyun and others improved Whale Optimization Algorithm by combining Whale Optimization Algorithm with topology to solve multi-objective reactive power optimization scheduling problem; Tu Chunmei et al. Proposed chaotic feedback adaptive optimization algorithm; Liu zhusong et al. Proposed positive co chaotic double string optimization algorithm (CSCWOA); Zhong Minghui et al. Proposed an efficient optimization algorithm for randomly adjusting control parameters


WOA can be used to solve continuity optimization problems. Therefore, by investigating the express delivery situation of several express companies in Jinzhou City, it is found that customer satisfaction and distribution efficiency are not ideal, mainly because each customer point has different time periods for receiving express mail, resulting in the back and forth of couriers and unnecessary time waiting, which not only greatly reduces the distribution efficiency of couriers, At the same time, it also greatly reduces customer satisfaction. Therefore, this paper introduces the greedy exchange mechanism into the whale optimization algorithm, establishes the express terminal distribution path model with time window based on the greedy whale optimization algorithm (GWOA), and solves the example. The results show that GWOA has better convergence speed and better local optimization ability.

Express terminal distribution

Description of routing problem the express terminal distribution routing problem can be described as: the courier starts from the distribution center (express distribution network), sends the customer's goods to each customer point along a specific route, and then needs to return to the starting point (express distribution network point) before a fixed time. During this period, couriers can choose short distance and time-saving routes to complete express delivery according to their own experience, or give priority to some customers according to their special needs. The premise is to ensure that all customer points are served before the specified time and can only be served once. Therefore, the express terminal distribution path should be reasonably planned to achieve the shortest distribution time, shortest distribution route distance, lowest distribution cost and maximum customer satisfaction under the constraints of meeting customer time window, customer demand, load limit of distribution vehicles and maximum driving distance of express vehicles.

%% use importdata This function reads the file
%% Extract data information
vertexs=data(:,2:3);                %Coordinates of all points x and y
customer=vertexs(2:end,:);          %Customer coordinates
cusnum=size(customer,1);            %Number of customers
v_num=3;                            %Initial number of vehicles used
demands=data(2:end,4);              %requirement
dist=squareform(h);                 %Distance matrix
%% Whale optimization algorithm parameters
NIND=100;                           %Population number
MAXGEN=300;                         %Maximum number of iterations
N=cusnum+v_num-1;                   %Whale individual length=Number of customers+Maximum number of vehicles used-1
belta=10;                           %Penalty function coefficient for violation of load constraint
%% Population initialization
init_vc=init(cusnum,demands,cap,dist);          %structure OVRP Initial solution
%% Route and total distance of output random solution
disp('Optimal individual in initial population:')
[currVC,NV,TD,violate_num,violate_cus]=decode(population(min_index,:),cusnum,cap,demands,dist);       %Initial decoding
disp(['Number of vehicles used:',num2str(NV),',Total vehicle distance:',num2str(TD),',Number of constraint violation paths:',num2str(violate_num),',Number of customers violating constraints:',num2str(violate_cus)]);
%% Main cycle
gen=1;                              %Counter initialization
bestInd=population(min_index,:);    %Initialize global optimal individual
bestObj=min_obj;                    %Initial global optimal individual objective function value
BestPop=zeros(MAXGEN,N);            %Record the global optimal individual in each iteration
BestObj=zeros(MAXGEN,1);            %Record the objective function value of the globally optimal individual in each iteration
BestTD=zeros(MAXGEN,1);             %Record the total distance of the globally optimal individual in each iteration
while gen<=MAXGEN
    %% Update whale population location
    for i=1:NIND
        p=rand;        %0~1 Random number between
        if p<0.5
        elseif p>=0.5
    %% Local search operation
    %% Calculate the objective function value of the current whale population
    %% Update the global optimal individual
    if min_obj<bestObj
    %% Displays the distribution scheme information decoded by the current global optimal individual
    disp(['The first',num2str(gen),'Generation global optimal solution:'])
    disp(['Number of vehicles used:',num2str(bestNV),',Total vehicle distance:',num2str(bestTD),',Number of constraint violation paths:',num2str(best_vionum),',Number of customers violating constraints:',num2str(best_viocus)]);
    %% Update calculator
%% Print the total cost change trend of the global optimal solution of each iteration of the outer loop
title('Variation trend of individual objective function value of global optimal whale')
xlabel('Number of iterations');
ylabel('Objective function value');
%% Print the global optimal solution roadmap. 1 means satisfied and 0 means dissatisfied

Topics: MATLAB Algorithm Machine Learning