路径规划基于matlab GUI多种蚁群算法栅格地图路径规划含Matlab源码 650期
Posted 紫极神光
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了路径规划基于matlab GUI多种蚁群算法栅格地图路径规划含Matlab源码 650期相关的知识,希望对你有一定的参考价值。
一、简介
1 蚁群算法的提出
蚁群算法(ant colony optimization, ACO),又称蚂蚁算法,是一种用来寻找优化路径的机率型算法。它由Marco Dorigo于1992年在他的博士论文中提出,其灵感来源于蚂蚁在寻找食物过程中发现路径的行为。遗传算法在模式识别、神经网络、机器学习、工业优化控制、自适应控制、生物科学、社会科学等方面都得到应用。
2 算法的基本原理
二、源代码
function varargout = main_GUI_xu(varargin)
% MAIN_GUI_XU MATLAB code for main_GUI_xu.fig
% MAIN_GUI_XU, by itself, creates a new MAIN_GUI_XU or raises the existing
% singleton*.
%
% H = MAIN_GUI_XU returns the handle to a new MAIN_GUI_XU or the handle to
% the existing singleton*.
%
% MAIN_GUI_XU(\'CALLBACK\',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAIN_GUI_XU.M with the given input arguments.
%
% MAIN_GUI_XU(\'Property\',\'Value\',...) creates a new MAIN_GUI_XU or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before main_GUI_xu_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to main_GUI_xu_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE\'s Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help main_GUI_xu
% Last Modified by GUIDE v2.5 22-Mar-2017 15:58:57
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(\'gui_Name\', mfilename, ...
\'gui_Singleton\', gui_Singleton, ...
\'gui_OpeningFcn\', @main_GUI_xu_OpeningFcn, ...
\'gui_OutputFcn\', @main_GUI_xu_OutputFcn, ...
\'gui_LayoutFcn\', [] , ...
\'gui_Callback\', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before main_GUI_xu is made visible.
function main_GUI_xu_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to main_GUI_xu (see VARARGIN)
% Choose default command line output for main_GUI_xu
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes main_GUI_xu wait for user response (see UIRESUME)
% uiwait(handles.figure1);
init_all(handles)
set(handles.edit38,\'string\',\'先选择实验目的,默认选择目的一,即运行一种算法\');
% --- Outputs from this function are returned to the command line.
function varargout = main_GUI_xu_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,\'String\')) returns listbox1 contents as cell array
% contents{get(hObject,\'Value\')} returns selected item from listbox1
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,\'BackgroundColor\'), get(0,\'defaultUicontrolBackgroundColor\'))
set(hObject,\'BackgroundColor\',\'white\');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% 绘制栅格线和调用figure的屏幕回调函数
global barrier pushbutton1_userdata
pushbutton1_userdata = 1; % 控制设计障碍物按钮是否能够使用
set(handles.edit38,\'string\',\'障碍物设计完成后,请点击输出障碍物按钮,否则容易出错\');
axes(handles.axes1)
cla reset
n_barrier = str2double(get(handles.edit1,\'string\'));
barrier = zeros(n_barrier,n_barrier);
axes(handles.axes1);
s.hf = get(handles.axes1,\'parent\');
% 绘制栅格边线
for i=0:1:n_barrier
plot([0,n_barrier],[i,i],\'color\',\'k\');
hold on
axis([0,n_barrier,0,n_barrier])
for j=0:1:n_barrier
plot([i,i],[0,n_barrier],\'color\',\'k\') ;
hold on
axis([0,n_barrier,0,n_barrier])
end
end
% 设置figure的WindowButtonDownFcn属性
set(s.hf,\'WindowButtonDownFcn\',@figure1_windowbuttondownfcn)
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,\'String\')) returns popupmenu1 contents as cell array
% contents{get(hObject,\'Value\')} returns selected item from popupmenu1
global barrier_select start_select goal_select pushbutton1_userdata barrier start goal
barrier_value = get(handles.popupmenu1,\'value\');
cd(\'barrier\')
if barrier_value==2
barrier_select = xlsread(\'e_barrier\');
start_select = 20;
goal_select = 295;
pushbutton1_userdata = 0;
elseif barrier_value==3
barrier_select = xlsread(\'simple_e\');
start_select = 20;
goal_select = 295;
pushbutton1_userdata = 0;
elseif barrier_value==4
barrier_select = xlsread(\'u_barrier\');
start_select = 1;
goal_select = 400;
pushbutton1_userdata = 0;
elseif barrier_value==5
barrier_select = xlsread(\'light_u_barrier\');
start_select = 1;
goal_select = 400;
pushbutton1_userdata = 0;
elseif barrier_value==6
barrier_select = xlsread(\'right_u_barrier\');
start_select = 1;
goal_select = 400;
pushbutton1_userdata = 0;
elseif barrier_value==7
barrier_select = xlsread(\'z_barrier\');
start_select = 49;
goal_select = 369;
pushbutton1_userdata = 0;
elseif barrier_value==8
barrier_select = xlsread(\'complex_z\');
start_select = 47;
goal_select = 367;
pushbutton1_userdata = 0;
elseif barrier_value==9
barrier_select = xlsread(\'complex_1\');
start_select = 1;
goal_select = 400;
pushbutton1_userdata = 0;
elseif barrier_value==10
barrier_select = xlsread(\'complex_2\');
start_select = 1;
goal_select = 400;
pushbutton1_userdata = 0;
elseif barrier_value==11
barrier_select = xlsread(\'complex_30\');
start_select = 1;
goal_select = 890;
pushbutton1_userdata = 0;
elseif barrier_value==12
barrier_select = xlsread(\'complex_50_1\');
start_select = 1;
goal_select = 2500;
elseif barrier_value==13
barrier_select = xlsread(\'complex_50_2\');
start_select = 1;
goal_select = 2500;
pushbutton1_userdata = 0;
elseif barrier_value==14
barrier_select = xlsread(\'complex_50_3\');
start_select = 1;
goal_select = 2500;
pushbutton1_userdata = 0;
elseif barrier_value==15
barrier_select = xlsread(\'barrier_tmp\');
set(handles.edit18,\'string\',\'请选择起点和终点\')
pushbutton1_userdata = 0;
start = 0;
goal = 0;
end
三、运行结果
四、备注
版本:2014a
完整代码或代写加1564658423
以上是关于路径规划基于matlab GUI多种蚁群算法栅格地图路径规划含Matlab源码 650期的主要内容,如果未能解决你的问题,请参考以下文章
路径规划基于matlab蚁群算法栅格地图路径规划及避障含Matlab源码 2088期
路径规划基于matlab蚁群算法栅格地图路径规划及避障含Matlab源码 2088期
路径规划基于matlab蚁群算法求解机器人栅格地图最短路径规划问题含Matlab源码 1618期