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

📄 path_choose.asv

📁 任意给出两城市
💻 ASV
📖 第 1 页 / 共 2 页
字号:
            if handles.d2(k)==1
                set(handles.h(k),'color',[1 0 0],'linewidth',handles.width+1);
            else
                set(handles.h(k),'color',[0,0,1],'linewidth',handles.width);
            end
        end
    else
        for k=1:45
            set(handles.h(k),'color',[0,0,1],'linewidth',handles.width);
        end
    end
end
handles.v4=zeros(1,30);
guidata(hObject, handles);




% --- Executes on button press in ok2.
function ok2_Callback(hObject, eventdata, handles)
% hObject    handle to ok2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.start_point=get(handles.Start_point,'value');
handles.end_point=get(handles.End_point,'value');
handles.load=str2double(get(handles.Load,'string'));
handles.V12=zeros(1,30);
handles.V22=zeros(1,30);
handles.V32=zeros(1,30);
handles.V42=zeros(1,30);
handles.D12=zeros(1,45);
handles.D22=zeros(1,45);
handles.V12(handles.start_point)=1;
for k=1:29
    length=handles.total_length;
    t=0;
    for l=1:45
        if handles.road_load(l)>=handles.load
            if handles.V12(handles.road_start_end(1,l))+handles.V12(handles.road_start_end(2,l))==1
                if handles.V12(handles.road_start_end(1,l))==1
                    if handles.V22(handles.road_start_end(1,l))+handles.road_length(l)<length
                        length=handles.V22(handles.road_start_end(1,l))+handles.road_length(l);
                        t=l;
                    end
                else
                    if handles.V22(handles.road_start_end(2,l))+handles.road_length(l)<length
                        length=handles.V22(handles.road_start_end(2,l))+handles.road_length(l);
                        t=l;
                    end
                end
            end
        end
    end
    if t==0
        break;
    end
    handles.D12(t)=1;
    if handles.V12(handles.road_start_end(1,t))==1
        handles.V12(handles.road_start_end(2,t))=1;
        handles.V22(handles.road_start_end(2,t))=length;
        handles.V32(handles.road_start_end(2,t))=handles.V32(handles.road_start_end(1,t))+1;
        if handles.road_start_end(2,t)==handles.end_point
            break;
        end
    else
        handles.V12(handles.road_start_end(1,t))=1;
        handles.V22(handles.road_start_end(1,t))=length;
        handles.V32(handles.road_start_end(1,t))=handles.V32(handles.road_start_end(2,t))+1;
        if handles.road_start_end(1,t)==handles.end_point
            break;
        end
    end
end
if handles.V12(handles.end_point)==0
    for k=1:45
        set(handles.h(k),'color',[0,0,1],'linewidth',handles.width);
    end
    legend('没有满足载重量要求的路线',3);
else
    legend(strcat('从',handles.city_name(handles.start_point,:),'到',handles.city_name(handles.end_point,:),'满足允许载重量大于',...
        int2str(round(handles.load)),'吨的最短距离为',int2str(round(handles.V22(handles.end_point))),'公里'),3);
    handles.V42(handles.end_point)=1;
    for k=0:handles.V32(handles.end_point)-1
        for l=1:45
            if handles.D12(l)==1
                if handles.V42(handles.road_start_end(1,l))+handles.V42(handles.road_start_end(2,l))==1
                    if (handles.V32(handles.road_start_end(1,l))+handles.V32(handles.road_start_end(2,l))==2*(handles.V32(handles.end_point)-k)-1)&&...
                (handles.V32(handles.road_start_end(1,l))*handles.V32(handles.road_start_end(2,l))==(handles.V32(handles.end_point)-k)*...
                (handles.V32(handles.end_point)-k-1))
                        handles.D22(l)=1;
                        if handles.V42(handles.road_start_end(1,l))==1
                            handles.V42(handles.road_start_end(2,l))=1;
                        else
                            handles.V42(handles.road_start_end(1,l))=1;
                        end
                        break;
                    end
                end
            end
        end
    end
    for l=0:10
        pause(0.2);
        if rem(l,2)==0
            for k=1:45
                if handles.D22(k)==1
                    set(handles.h(k),'color',[1 0 0],'linewidth',handles.width+1);
                else
                    set(handles.h(k),'color',[0,0,1],'linewidth',handles.width);
                end
            end
        else
            for k=1:45
                set(handles.h(k),'color',[0,0,1],'linewidth',handles.width);
            end
        end
    end
    handles.V42=zeros(1,30);
end
guidata(hObject, handles);




% --- Executes on button press in close.
function close_Callback(hObject, eventdata, handles)
% hObject    handle to close (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close;


% --------------------------------------------------------------------
function problem_Callback(hObject, eventdata, handles)
% hObject    handle to problem (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function problem_description_Callback(hObject, eventdata, handles)
% hObject    handle to problem_description (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
winopen('problem_description.rtf');


% --------------------------------------------------------------------
function model_description_Callback(hObject, eventdata, handles)
% hObject    handle to model_description (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
winopen('model_description.rtf');


% --------------------------------------------------------------------
function arithmetic_description_Callback(hObject, eventdata, handles)
% hObject    handle to arithmetic_description (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function setting_Callback(hObject, eventdata, handles)
% hObject    handle to setting (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function help_Callback(hObject, eventdata, handles)
% hObject    handle to help (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 Start_point_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Start_point (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in Start_point.
function Start_point_Callback(hObject, eventdata, handles)
% hObject    handle to Start_point (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns Start_point contents as cell array
%        contents{get(hObject,'Value')} returns selected item from Start_point


% --- Executes during object creation, after setting all properties.
function End_point_CreateFcn(hObject, eventdata, handles)
% hObject    handle to End_point (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in End_point.
function End_point_Callback(hObject, eventdata, handles)
% hObject    handle to End_point (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns End_point contents as cell array
%        contents{get(hObject,'Value')} returns selected item from End_point


% --- Executes during object creation, after setting all properties.
function Load_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Load (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'));
end



function Load_Callback(hObject, eventdata, handles)
% hObject    handle to Load (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 Load as text
%        str2double(get(hObject,'String')) returns contents of Load as a double


function a=min(x,y)
if x>y
    a=y;
else
    a=x;
end% --------------------------------------------------------------------function line_width_Callback(hObject, eventdata, handles)% hObject    handle to line_width (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function width1_Callback(hObject, eventdata, handles)% hObject    handle to width1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)
handles.width=1;
set(handles.width1,'checked','on');
set(handles.width2,'checked','off');
f
% --------------------------------------------------------------------function width2_Callback(hObject, eventdata, handles)% hObject    handle to width2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)

⌨️ 快捷键说明

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