function varargout = yichuan1(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @yichuan1_OpeningFcn, ...
'gui_OutputFcn', @yichuan1_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 yichuan1 is made visible.
function yichuan1_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 yichuan1 (see VARARGIN)
% Choose default command line output for yichuan1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes yichuan1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = yichuan1_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 button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
global d;
d(1)=str2double(get(handles.edit1,'String'));
d(2)=str2double(get(handles.edit2,'String'));
d(3)=str2double(get(handles.edit3,'String'));
d(4)=str2double(get(handles.edit4,'String'));
d(5)=str2double(get(handles.edit5,'String'));
d(6)=str2double(get(handles.edit6,'String'));
d(7)=str2double(get(handles.edit7,'String'));
d(8)=str2double(get(handles.edit8,'String'));
d(9)=str2double(get(handles.edit9,'String'));
d(10)=str2double(get(handles.edit10,'String'));
d=sort(d);
axes(handles.axes1)
for i=1:11
for j=1:11
gx((i-1)*11+j)=j-1;
gy((i-1)*11+j)=11-i;
end
end
for i=1:10
for j=1:10
gbh((i-1)*10+j,:)=[(i-1)*11+j,(i-1)*11+j+1,i*11+j+1,i*11+j];
end
end
hold on
for i=1:length(d)
fill(gx(gbh(d(i)+1,:)),gy(gbh(d(i)+1,:)),'b')
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit3_Callback(hObject, eventdata, handles)
function edit3_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit4_Callback(hObject, eventdata, handles)
function edit4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit5_Callback(hObject, eventdata, handles)
function edit5_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit6_Callback(hObject, eventdata, handles)
function edit6_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles)
function edit7_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit8_Callback(hObject, eventdata, handles)
function edit8_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit9_Callback(hObject, eventdata, handles)
function edit9_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit10_Callback(hObject, eventdata, handles)
function edit10_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global d;
G=2000;
popsize=50;
poplength=18;
pc=1;
pm=1;
pop=yichuaninitialize(popsize,poplength);
for i=1:G
pop=yichuancrossover(pop,poplength,pc);
pop=yichuanmuate(pop,pm);
pop=yichuanroulette(pop,popsize,poplength);
end
[a,b]=sort(pop(:,poplength+1));
bestroad=pop(b(popsize),:);
t=0;
for i=1:poplength
if(bestroad(i)~=0)
t=t+1;
end
end
disp(bestroad(1:t))
disp(t)
set(handles.edit11,'String',bestroad(1:t));
set(handles.edit12,'String',t);
axes(handles.axes2);
cla reset
axes(handles.axes2)
for i=1:11
for j=1:11
gx((i-1)*11+j)=j-1;
gy((i-1)*11+j)=11-i;
end
end
for i=1:10
for j=1:10
gbh((i-1)*10+j,:)=[(i-1)*11+j,(i-1)*11+j+1,i*11+j+1,i*11+j];
end
end
hold on
for i=1:length(d)
fill(gx(gbh(d(i)+1,:)),gy(gbh(d(i)+1,:)),'b')
end
for i=1:100
plot(gx(gbh(i,1:2)),gy(gbh(i,1:2)))
plot(gx(gbh(i,2:3)),gy(gbh(i,2:3)))
plot(gx(gbh(i,3:4)),gy(gbh(i,3:4)))
plot(gx(gbh(i,4:1)),gy(gbh(i,4:1)))
text(sum(gx(gbh(i,:)))/4,sum(gy(gbh(i,:)))/4,...
num2str(i-1),'Color','White','Fontsize',10)%序号尺寸
end
for i=1:t
ljx(i)=sum(gx(gbh((bestroad(i)+1),:)))/4;
ljy(i)=sum(gy(gbh((bestroad(i)+1),:)))/4;
end
ljx=[0.5 ljx];
ljy=[9.5 ljy];
% plot(ljx,ljy,'linewidth',3)
for i=1:length(ljx)-1
plot(ljx(i:i+1),ljy(i:i+1),'linewidth',3)%线宽
pause(0.2)
end
function edit11_Callback(hObject, eventdata, handles)
function edit11_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit12_Callback(hObject, eventdata, handles)
function edit12_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
gui遗传算法.zip_gui求遗传算法_路径规划GUI_遗传算法 _遗传算法gui实现_遗传规划
版权申诉
4星 · 超过85%的资源 122 浏览量
2022-07-15
01:44:20
上传
评论
收藏 16KB ZIP 举报
钱亚锋
- 粉丝: 90
- 资源: 1万+
最新资源
- CLShanYanSDKDataList.sqlite
- android应用商店
- btstack协议栈实战篇-HFP HF - Hands-Free
- MSFRosslerAll (2).for
- vs2022安装包在线安装包
- 项目实战:基于ASP.NET技术的网上图书订阅管理系统的设计与开发(程序源代码+毕业文档)
- Microsoft C++ 生成工具
- 基于SpringMVC+Bootstrap在线图书销售系统(PC端+server端源码+数据库SQL+演示讲解+毕业论文)
- 74LS190实现10以内、100以内十进制加/减计数器-由multisim软件电路仿真设计
- 毕业项目:网上图书订阅管理系统的设计与开发(ASP.NET技术+程序源代码+毕业文档)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论3