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

📄 antsgui.asv

📁 使用蚂蚁算法解决商旅问题(TSP) Matlab GUI 编程
💻 ASV
📖 第 1 页 / 共 2 页
字号:
%        str2double(get(hObject,'String')) returns contents of PheromCoe as a double% --- Executes during object creation, after setting all properties.function DistCoe_CreateFcn(hObject, eventdata, handles)% hObject    handle to DistCoe (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction DistCoe_Callback(hObject, eventdata, handles)% hObject    handle to DistCoe (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 DistCoe as text%        str2double(get(hObject,'String')) returns contents of DistCoe as a double% --- Executes during object creation, after setting all properties.function PhoremEvapCoe_CreateFcn(hObject, eventdata, handles)% hObject    handle to PhoremEvapCoe (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction PhoremEvapCoe_Callback(hObject, eventdata, handles)% hObject    handle to PhoremEvapCoe (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 PhoremEvapCoe as text%        str2double(get(hObject,'String')) returns contents of PhoremEvapCoe as a double% --- Executes during object creation, after setting all properties.function PheromAddCoe_CreateFcn(hObject, eventdata, handles)% hObject    handle to PheromAddCoe (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction PheromAddCoe_Callback(hObject, eventdata, handles)% hObject    handle to PheromAddCoe (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 PheromAddCoe as text%        str2double(get(hObject,'String')) returns contents of PheromAddCoe as a double% --- Executes on button press in StartAnts.function StartAnts_Callback(hObject, eventdata, handles)% hObject    handle to StartAnts (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)
global AntsCod
global bContinue
EditEnable = 'on';
if bContinue ~=  1
    bContinue = 1;
    EditEnable = 'off';
else
    EditEnable = 'on';
    bContineu = 0;
end
 set(handles.AntsNum,'Enable',EditEnable)
set(handles.AntsColonyNum,'Enable',EditEnable)
set(handles.PheromCoe,'Enable',EditEnable)
set(handles.DistCoe,'Enable',EditEnable)
set(handles.PhoremEvapCoe,'Enable',EditEnable)
set(handles.PheromAddCoe,'Enable',EditEnable)
if bContinue == 1
    CityNum = str2num(get(handles.CityNum,'String'));
    AntsNum =  str2num(get(handles.AntsNum,'String'));
    AntsColonyNum =str2num(get(handles.AntsColonyNum,'String'));
    PheromCoe = str2num(get(handles.PheromCoe,'String'));
    DistCoe =  str2num(get(handles.DistCoe,'String'));
    PhoremEvapCoe =str2num(get(handles.PhoremEvapCoe,'String'));
    PheromAddCoe =str2num(get(handles.PheromAddCoe,'String'));
    set(handles.StartAnts,'String','Stop')
    ACATSP(AntsCod,AntsColonyNum,CityNum,DistCoe,PheromCoe,PhoremEvapCoe,PheromAddCoe,handles); 
    EditEnable = 'on';
    set(handles.AntsNum,'Enable',EditEnable)
set(handles.AntsColonyNum,'Enable',EditEnable)
set(handles.PheromCoe,'Enable',EditEnable)
set(handles.DistCoe,'Enable',EditEnable)
set(handles.PhoremEvapCoe,'Enable',EditEnable)
set(handles.PheromAddCoe,'Enable',EditEnable)
else
    set(handles.StartAnts,'String','Start')
end
% --- If Enable == 'on', executes on mouse press in 5 pixel border.% --- Otherwise, executes on mouse press in 5 pixel border or over Reset.function Reset_ButtonDownFcn(hObject, eventdata, handles)% hObject    handle to Reset (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- If Enable == 'on', executes on mouse press in 5 pixel border.% --- Otherwise, executes on mouse press in 5 pixel border or over StartAnts.function StartAnts_ButtonDownFcn(hObject, eventdata, handles)% hObject    handle to StartAnts (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes during object creation, after setting all properties.function StepNum_CreateFcn(hObject, eventdata, handles)% hObject    handle to StepNum (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction StepNum_Callback(hObject, eventdata, handles)% hObject    handle to StepNum (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 StepNum as text%        str2double(get(hObject,'String')) returns contents of StepNum as a double% --- Executes during object creation, after setting all properties.function MinDistance_CreateFcn(hObject, eventdata, handles)% hObject    handle to MinDistance (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction MinDistance_Callback(hObject, eventdata, handles)% hObject    handle to MinDistance (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 MinDistance as text%        str2double(get(hObject,'String')) returns contents of MinDistance as a double% --- Executes during object creation, after setting all properties.function ElapsedTime_CreateFcn(hObject, eventdata, handles)% hObject    handle to ElapsedTime (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction ElapsedTime_Callback(hObject, eventdata, handles)% hObject    handle to ElapsedTime (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 ElapsedTime as text%        str2double(get(hObject,'String')) returns contents of ElapsedTime as a double% --- Executes during object creation, after setting all properties.function AvgTime_CreateFcn(hObject, eventdata, handles)% hObject    handle to AvgTime (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction AvgTime_Callback(hObject, eventdata, handles)% hObject    handle to AvgTime (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 AvgTime as text%        str2double(get(hObject,'String')) returns contents of AvgTime as a double

⌨️ 快捷键说明

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