上面为GUI界面和源码,下载后若还存在这2副png图,后缀和空格去掉。
代码优化前后的时间相差很明显。可以给初学优化算法的学生在程序结构和算法流程设计上
有个很好的认识。
to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% Choose default command line output for TspACA
= hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes TspACA wait for user response (see UIRESUME)
% uiwait();
global AntsCod
global bContinue
global Change
bContinue = 0;
Change =0;
CityNum = str2num(get(,'String'));
AntsCod =round(100*rand(CityNum,2));
%if MapIndex == 1
%AntsCod(:,1) = (unidrnd(100,1,CityNum) - 1)';
%AntsCod(:,2) = (unidrnd(100,1,CityNum) - 1)';
plot(AntsCod(:,1),AntsCod(:,2),'mo','LineWidth',,'MarkerEdgeColor','r','MarkerFaceColor','b','Parent',);
% --- Outputs from this function are returned to the command line.
function varargout = TspACA_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} = ;
function CityNumber_Callback(hObject, eventdata, handles)
% hObject handle to CityNumber (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of CityNumber as text
% str2double(get(hObject,'String')) returns contents of CityNumber as a double
% --- Executes during object creation, after setting all properties.
function CityNumber_Cre
蚁群优化算法 来自淘豆网m.daumloan.com转载请标明出处.