⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 antinface.m

📁 蚁群算法采用matlab开发的仿真平台:算法实现
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = antinface(varargin)% ANTINFACE M-file for antinface.fig%      ANTINFACE, by itself, creates a new ANTINFACE or raises the existing%      singleton*.%%      H = ANTINFACE returns the handle to a new ANTINFACE or the handle to%      the existing singleton*.%%      ANTINFACE('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in ANTINFACE.M with the given input arguments.%%      ANTINFACE('Property','Value',...) creates a new ANTINFACE or raises the%      existing singleton*.  Starting from the left, property value pairs are%      applied to the GUI before antinface_OpeningFcn gets called.  An%      unrecognized property name or invalid value makes property application%      stop.  All inputs are passed to antinface_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 antinface% Last Modified by GUIDE v2.5 02-Jun-2008 10:29:35% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @antinface_OpeningFcn, ...                   'gui_OutputFcn',  @antinface_OutputFcn, ...                   'gui_LayoutFcn',  [] , ...                   'gui_Callback',   []);if nargin && ischar(varargin{1})    gui_State.gui_Callback = str2func(varargin{1});endif 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 antinface is made visible.function antinface_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 state (see GUIDATA)% varargin   command line arguments to antinface (see VARARGIN)% Choose default command line output for antinfacehandles.output = hObject;% Update handles structureguidata(hObject, handles);h=waitbar(0,'请等待......');for i=1:100    waitbar(i/100);enddelete(h);% UIWAIT makes antinface wait for user response (see UIRESUME)% uiwait(handles.handles);% --- Outputs from this function are returned to the command line.function varargout = antinface_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 state (see GUIDATA)% Get default command line output from handles structurevarargout{1} = handles.output;function edit_initao_Callback(hObject, eventdata, handles)% hObject    handle to edit_initao (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_initao as text%        str2double(get(hObject,'String')) returns contents of edit_initao as a double% --- Executes during object creation, after setting all properties.function edit_initao_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_initao (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit 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');endfunction edit_q_Callback(hObject, eventdata, handles)% hObject    handle to edit_q (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_q as text%        str2double(get(hObject,'String')) returns contents of edit_q as a double% --- Executes during object creation, after setting all properties.function edit_q_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_q (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit 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');endfunction edit_alpha_Callback(hObject, eventdata, handles)% hObject    handle to edit_alpha (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_alpha as text%        str2double(get(hObject,'String')) returns contents of edit_alpha as a double% --- Executes during object creation, after setting all properties.function edit_alpha_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_alpha (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit 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');endfunction edit_rou_Callback(hObject, eventdata, handles)% hObject    handle to edit_rou (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_rou as text%        str2double(get(hObject,'String')) returns contents of edit_rou as a double% --- Executes during object creation, after setting all properties.function edit_rou_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_rou (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit 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');endfunction edit_beta_Callback(hObject, eventdata, handles)% hObject    handle to edit_beta (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_beta as text%        str2double(get(hObject,'String')) returns contents of edit_beta as a double% --- Executes during object creation, after setting all properties.function edit_beta_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_beta (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit 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');endfunction edit_ncmax_Callback(hObject, eventdata, handles)% hObject    handle to edit_ncmax (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_ncmax as text%        str2double(get(hObject,'String')) returns contents of edit_ncmax as a double% --- Executes during object creation, after setting all properties.function edit_ncmax_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_ncmax (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit 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');endfunction edit_antsum_Callback(hObject, eventdata, handles)% hObject    handle to edit_antsum (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_antsum as text%        str2double(get(hObject,'String')) returns contents of edit_antsum as a double% --- Executes during object creation, after setting all properties.function edit_antsum_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_antsum (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit 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');endfunction edit_maxinfo_Callback(hObject, eventdata, handles)% hObject    handle to edit_maxinfo (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_maxinfo as text%        str2double(get(hObject,'String')) returns contents of edit_maxinfo as a double% --- Executes during object creation, after setting all properties.function edit_maxinfo_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_maxinfo (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit 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');endfunction edit_mininfo_Callback(hObject, eventdata, handles)% hObject    handle to edit_mininfo (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_mininfo as text%        str2double(get(hObject,'String')) returns contents of edit_mininfo as a double% --- Executes during object creation, after setting all properties.function edit_mininfo_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_mininfo (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit 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 openfile.function openfile_Callback(openfile, eventdata, handles)% hObject    handle to openfile (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)[filename,pathname,filterindex]=uigetfile('*.*','All Files(*.*)');set(handles.text_filename,'String',pathname);fid=fopen(filename,'r');if fid==-1;    warndlg('Can not open the file','WARN');    fclose(fid);end;%第一条路径[A0,COUNT]=fscanf(fid,'%g');B=reshape(A0,4,[]);%disp(B);ng=max(B(1,:));        %第一行最大数即为路径条数,为计算方便每条路径上的城市个数相等%disp(ng); n=COUNT/(4*ng);%disp(n);set(handles.edit_citysum,'String',n);fclose(fid);   disp('open file ok!');%disp(g);set(handles.openfile,'UserData',[A0]);  %把读取的数据保存到A0中。% --- Executes on selection change in selectmenu.function selectmenu_Callback(hObject, eventdata, handles)% hObject    handle to selectmenu (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: contents = get(hObject,'String') returns selectmenu contents as cell array%        contents{get(hObject,'Value')} returns selected item from selectmenu% --- Executes during object creation, after setting all properties.function selectmenu_CreateFcn(hObject, eventdata, handles)% hObject    handle to selectmenu (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: popupmenu 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');endfunction edit_citysum_Callback(hObject, eventdata, handles)% hObject    handle to edit_citysum (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_citysum as text%        str2double(get(hObject,'String')) returns contents of edit_citysum as a double% --- Executes during object creation, after setting all properties.function edit_citysum_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_citysum (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit 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');endfunction edit_calNO_Callback(hObject, eventdata, handles)% hObject    handle to edit_calNO (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user state (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_calNO as text%        str2double(get(hObject,'String')) returns contents of edit_calNO as a double% --- Executes during object creation, after setting all properties.function edit_calNO_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_calNO (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -