[Path planning] Analysis of bus scheduling system based on matlab genetic algorithm [including Matlab source code 220 period]

1. Introduction

1 Background analysis of the bus scheduling system.
As the construction of urban traffic facilities lags behind the growth rate of traffic demand, urban traffic conditions are deteriorating day by day. Traffic jams occur to varying degrees at major traffic intersections and some roads with concentrated traffic. The problem has become a bottleneck restricting urban development.
The urban transportation system is an open and complex system composed of urban road networks, vehicles and management systems. There are many ways to solve urban traffic. For example, the current number restriction measures are one of the better methods. Through the number restriction operation, the number of people who take the bus on foot increases, so how to solve the problem of bus scheduling is particularly necessary. Reasonably solving the problem of public transportation scheduling system is a complex problem. It needs to consider complex factors such as people, vehicles, roads, etc. Therefore, it is necessary to use high-tech technical methods to better solve urban road traffic problems. Nowadays, intelligent transportation systems (ITS ) Has become one of the important ways to solve this problem.
The intelligent scheduling of operating vehicles is one of the typical problems that need to be solved in the intelligent dispatch of public transportation vehicles. In the context of Intelligent Transportation System (ITS), the formulation of bus schedules is the core content of urban public transportation dispatch and is the daily command of public transportation dispatch The important basis for the normal operation of vehicles is also the basic basis for the work of bus dispatchers and drivers. A reasonable bus schedule can help bus companies improve vehicle utilization efficiency, reduce operating costs and reduce passenger waiting time to improve service quality.
2 Vehicle driving model
Insert picture description here
3 Passenger boarding and disembarking model
Insert picture description here
4 Application steps of
genetic algorithm Genetic algorithm GA is a global optimization method based on evolution and genetic theory.
The basic steps of simple genetic algorithm to solve the problem are as follows:
(1) Initialization: randomly generate N individuals as the initial population P(0), which is a set of feasible solutions for the objective function. Set the evolution algebra counter to zero and set the maximum evolution algebra iter_max;
(2) Individual evaluation: Substitute the initial population into the objective function, and calculate the fitness of each population in the current population according to the fitness function;
(3) Judgment of termination conditions: Given termination conditions, determine whether the algorithm satisfies the termination conditions, and if so, go to (8);
(4) Selection operation: perform a selection operation on the initial group, good individuals are copied in large numbers, and poor quality Individuals are rarely copied or even eliminated;
(5) Crossover calculation: Crossover calculation is performed based on crossover probability;
(6) Mutation calculation: Crossover calculation is performed based on mutation probability;
(7) Group P(t) undergoes selection calculation and crossover calculation After the mutation operation, the next-generation population P(t+1) composed of N new individuals is obtained, then go to (2), otherwise go to (4);
(8) Continuous evolution will eventually get the objective function, adaptation The individual with the highest degree is output as the optimal solution or satisfactory solution of the problem, and the calculation is terminated.
Insert picture description here
Insert picture description here

Second, the source code

% 产生t(i)序列
clc,clear,close all
warning off
Tmin = 1;   % 表示相邻车辆间发车间隔的最小值(min)
Tmax = 10;  % 表示相邻车辆间发车间隔的最大值(min)
delta = 4;  % 表示相邻车辆发车间隔之差的限制值
m = 500;    % 表示总的发车次数(车次)
a = randi(10);  % t(1)第一个值的取值范围设定为1-10之间随机取值
t(1) = a;       % 赋值
maxt = 960;    % t(i)的最大值
% Loop
for i=2:m
    flag = 1;       % 标志变量
    while flag == 1
        % Tmin< t(i)-t(i-1) < Tmax
        a1 = randi(9);
        if a1>Tmin+2 && i==2
            t(i)=t(i-1)+a1; % Tmin < t(i)-t(i-1) < Tmax
            flag = 0;   % i 时间点计算完毕
        elseif a1>Tmin+2 && i>2  % |t(i+1)-2*t(i)+t(i-1)|<delta 
            t(i)=t(i-1)+a1; % Tmin < t(i)-t(i-1) < Tmax
            if abs( (t(i)-t(i-1)) -(t(i-1)-t(i-2)) )<delta
                flag = 0;  % i 时间点计算完毕
            end
        end
    end
    function flag=test(code)
% code       output: 染色体的编码值
global Tmin Tmax delta
x=code; %先解码
flag=1;
for i=3:length(x)
    else
        flag=0;
    end
end    
% 产生t(i)序列
function ret=Mutation(pmutation,lenchrom,chrom,sizepop,num,maxgen)
% 本函数完成变异操作
% pcorss                input  : 变异概率
% lenchrom              input  : 染色体长度
% chrom     input  : 染色体群
% sizepop               input  : 种群规模
% opts                  input  : 变异方法的选择
% pop                   input  : 当前种群的进化代数和最大的进化代数信息
% bound                 input  : 每个个体的上届和下届
% maxgen                input  :最大迭代次数
% num                   input  : 当前迭代次数
% ret                   output : 变异后的染色体
function t = pop_meet_conditions(maxt)
global Tmin Tmax delta m tt PP Q cita
% 输入变量说明:
% Tmin = 1;   % 表示相邻车辆间发车间隔的最小值(min)
% Tmax = 10;  % 表示相邻车辆间发车间隔的最大值(min)
% delta = 4;  % 表示相邻车辆发车间隔之差的限制值
% m = 500;    % 表示总的发车次数(车次)
% maxt = 960;    % t(i)的最大值

% 输出变量说明:
% t为满足条件的个体

a = randi(10);  % t(1)第一个值的取值范围设定为1-10之间随机取值
t(1) = a;       % 赋值

flag = 1;       % 标志变量
% Loop
while flag==1
    
    for i=2:m
        flag = 1;       % 标志变量
        while flag == 1
            % Tmin< t(i)-t(i-1) < Tmax
            a1 = randi(9);
            if a1>Tmin+2 && i==2
                t(i)=t(i-1)+a1; % Tmin < t(i)-t(i-1) < Tmax
                flag = 0;   % i 时间点计算完毕
            elseif a1>Tmin+2 && i>2  % |t(i+1)-2*t(i)+t(i-1)|<delta 
                t(i)=t(i-1)+a1; % Tmin < t(i)-t(i-1) < Tmax
                if abs( (t(i)-t(i-1)) -(t(i-1)-t(i-2)) )<delta
                    flag = 0;  % i 时间点计算完毕
                end
            end
        end
    end 

Three, running results

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Four, remarks

Add QQ1564658423 for complete code or writing.
Past review>>>>>>
[ VRP] Matlab genetic algorithm based vehicle routing problem with time window [including Matlab source code 002]
[Path planning] based on matlab A* algorithm to solve three-dimensional path planning problem [including Matlab source code 003 period]
[path] planning based on artificial bee colony matlab path planning with Matlab source code [004]
[path] to solve planning based on ant colony matlab multiple traveling salesman problem [with Matlab source MTSP 005]
[path] planning based on ant colony matlab Algorithm-based UAV path planning [including Matlab source code 008]
[Path planning] Matlab genetic algorithm to solve multiple VRP problems [including Matlab source code 010]
[Path planning] Matlab genetic algorithm-based multi-center VRP solution [including Matlab source code Issue 011]
[Path planning] Three-dimensional UAV path planning based on matlab particle swarm [Including Matlab source code 015]
[ Path planning] Based on matlab using genetic algorithm to compile an open vehicle routing problem with multiple logistics centers [Including Matlab source code 017 】
【Path planning】Robot grid path planning based on matlab particle swarm 【Include Matlab source code 018】
【Path planning】Based on matlab ant colony algorithm to solve the shortest path 【Include Matlab source code 019】
【Path planning】Based on matlab immune algorithm Logistics center location problem [Include Matlab source code 020 period]
[Path planning] Matlab artificial bee colony based UAV three-dimensional path planning [Include Matlab source code 021 period]
[Path planning] Robot optimal path planning based on matalb grid map-genetic algorithm [including Matlab source code 022]
[Path planning] Matlab grid map-genetic algorithm-based robot optimal path planning [including Matlab source code 027 period]
[path] planning based on ant colony matlab multi-UAV attacks scheduling with Matlab source code [034]
[path] three-dimensional path planning based on ant colony matlab matlab source with planning [043]
[path] planning based on particle matlab Colony optimization ant colony's shortest path solution [including Matlab source code 076]
[Path planning] based on matlab ant colony algorithm to solve multi-center VRP problem [including Matlab source code 111]
[path planning] based on matlab ant colony algorithm to solve with time windows Multi-center VRP problem [Including Matlab source code 112]
[Path planning] Based on matlab ant colony algorithm to solve multi-center VRP problem with time window [Including Matlab source code 113]
[Path planning] Multi-center VRP solution based on matalb genetic algorithm [ Contains Matlab source code 114]
[Path planning] Matlab simulated annealing to solve VRP problem [Contains Matlab source code 115]
[Path planning] Matlab A star-based raster path planning [Contains Matlab source code 116]
[Path planning] Based on matlab A two-way optimization particle swarm grid map path planning with cross factors [including Matlab source code 117]
[TSP] Based on matlab ant colony algorithm to solve traveling salesman TSP problem with GUI [including Matlab source code 118]
[Path planning] based Matlab ant colony algorithm grid map path planning [including Matlab source code 119]
[TSP problem] TSP problem based on matlab differential evolution [including matlab source code 131]
[Path planning] Matlab genetic algorithm-based traveling salesman TSP problem [including Matlab source code 135]
[path planning] Matlab simulated annealing algorithm based traveling salesman TSP problem [including Matlab source code 136 period]
[Path planning] Smart car path planning based on matlab ant colony algorithm [including Matlab source code 137 period]
[Path planning] Huawei Cup: Optimal use of UAVs in disaster relief [including Matlab Source code 138 period]
[Path planning] based on matlab RRT three-dimensional path planning [including Matlab source code 151]
[Path planning] based on matalb artificial potential field UAV formation path planning [including Matlab 155 period]
[VRP problem] based on matlab saving algorithm Solving TWVRP problem [including Matlab source code 156]
[VRP problem] Matlab saving algorithm to solve CVRP problem [including Matlab source code 157]
[VRP problem] Matlab tabu search algorithm to solve VRP problem [including Matlab source code 158]
[VRP problem 】Solve CVRP problem based on matlab simulated annealing [including Matlab source code 159]
[VRP problem] Solve VRP problem with time window based on matlab artificial fish school [including Matlab source code 161]
[VRP problem] Solve the problem with capacity based on matlab genetic algorithm VRP problem [including Matlab source code 162]
[Path planning] 3D path planning based on matlab wolf pack algorithm [including Matlab source code 167]
[Path planning] Matlab artificial potential field-based UAV 3D path planning [including Matlab source code 168 period】
[Path planning] Three-dimensional multi-UAV coordinated trajectory planning based on improved differences in matlab [including Matlab source code 169]
[Path planning] Matlab artificial bee colony-based multi-UAV three-dimensional path planning [including Matlab source code 170]
[ Path planning] 3D path planning for UAVs based on matlab sparrow search algorithm [including Matlab source code 171]
[Path planning] 3D path planning based on matlab ant colony algorithm [including Matlab source code 179]
[Path planning] Matlab immune algorithm The shortest path planning [including Matlab source code 194]

[Traveling Salesman Problem] Solving the traveling salesman problem based on matlab immune algorithm [including Matlab source code 195]

Guess you like

Origin blog.csdn.net/TIQCmatlab/article/details/113654878