Code covered by the BSD License  

Highlights from
Traveling Salesman Problem (TSP) using Simulated Annealing

image thumbnail
from Traveling Salesman Problem (TSP) using Simulated Annealing by Aravind Seshadri
A GUI for sovling TSP's using Simulated Annealing

stsp_v61_export(varargin)
function varargout = stsp_v61_export(varargin)
% STSP_V61_EXPORT M-file for stsp_v61_export.fig
%      STSP_V61_EXPORT, by itself, creates a new STSP_V61_EXPORT or raises the existing
%      singleton*.
%
%      H = STSP_V61_EXPORT returns the handle to a new STSP_V61_EXPORT or the handle to
%      the existing singleton*.
%
%      STSP_V61_EXPORT('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in STSP_V61_EXPORT.M with the given input arguments.
%
%      STSP_V61_EXPORT('Property','Value',...) creates a new STSP_V61_EXPORT or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before stsp_v61_export_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to stsp_v61_export_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 stsp_v61_export

% Last Modified by GUIDE v2.5 22-Mar-2006 20:15:26

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @stsp_v61_export_OpeningFcn, ...
                   'gui_OutputFcn',  @stsp_v61_export_OutputFcn, ...
                   'gui_LayoutFcn',  @stsp_v61_export_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 stsp_v61_export is made visible.
function stsp_v61_export_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 stsp_v61_export (see VARARGIN)

% Choose default command line output for stsp_v61_export
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes stsp_v61_export wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = stsp_v61_export_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;



function initial_temperature_Callback(hObject, eventdata, handles)
% hObject    handle to initial_temperature (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 initial_temperature as text
%        str2double(get(hObject,'String')) returns contents of initial_temperature as a double
s = str2double(get(hObject,'String'));
if isnan(s)
    set(hObject,'String','1000')
end
if s < 0 | s > 10000
    set(hObject,'String','1000')
end

% --- Executes during object creation, after setting all properties.
function initial_temperature_CreateFcn(hObject, eventdata, handles)
% hObject    handle to initial_temperature (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



function maximum_iterations_Callback(hObject, eventdata, handles)
% hObject    handle to maximum_iterations (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 maximum_iterations as text
%        str2double(get(hObject,'String')) returns contents of maximum_iterations as a double
s = str2double(get(hObject,'String'));
if isnan(s)
    set(hObject,'String','10000')
end
if s < 1000 | s > 1000000
    set(hObject,'String','10000')
end

% --- Executes during object creation, after setting all properties.
function maximum_iterations_CreateFcn(hObject, eventdata, handles)
% hObject    handle to maximum_iterations (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 slider movement.
function cooling_rate_Callback(hObject, eventdata, handles)
% hObject    handle to cooling_rate (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
s = sprintf('Cooling Rate : %0.3f',get(hObject,'Value'));
set(handles.cooling_rate_display, 'String', s);
% --- Executes during object creation, after setting all properties.
function cooling_rate_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cooling_rate (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function cities_to_swap_Callback(hObject, eventdata, handles)
% hObject    handle to cities_to_swap (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
s = sprintf('Cities to swap : %d',get(hObject,'Value'));
set(handles.cities_to_swap_display,'String',s)

% --- Executes during object creation, after setting all properties.
function cities_to_swap_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cities_to_swap (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end




% --- Executes during object creation, after setting all properties.
function cooling_rate_display_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cooling_rate_display (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called




% --- Executes during object creation, after setting all properties.
function cities_to_swap_display_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cities_to_swap_display (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called




% --- Executes on button press in start_button.
function start_button_Callback(hObject, eventdata, handles)
% hObject    handle to start_button (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
selection = get(handles.select_data_set, 'Value');
switch selection
    case 2
        data_file;
    case 3
        loadbays29;
    case 4
        loadatt48;
    case 5
        loadst70;
    case 6
        loadpr76;
    case 7
        loadgr96;
    case 8
        loadeil101;
    case 9
        loadpcb442;
    case 10
        loadeil535;
end
if selection ~= 1
    set(handles.initial_temperature, 'Enable', 'Off')
    set(handles.cooling_rate, 'Enable', 'Off')
    set(handles.maximum_iterations, 'Enable', 'Off')
    set(handles.cities_to_swap, 'Enable', 'Off')
    set(handles.start_button, 'Enable', 'Off')
    set(handles.select_data_set, 'Enable', 'Off')
    cities = load ('cities.mat');
    cities = cities.cities;
    simulatedannealing(cities,...
        str2double(get(handles.initial_temperature,'String')),...
        get(handles.cooling_rate,'Value'),...
        str2double(get(handles.maximum_iterations,'String')),...
        get(handles.cities_to_swap,'Value'));
    set(handles.initial_temperature, 'Enable', 'On')
    set(handles.cooling_rate, 'Enable', 'On')
    set(handles.maximum_iterations, 'Enable', 'On')
    set(handles.cities_to_swap, 'Enable', 'On')
    set(handles.start_button, 'Enable', 'On')
    set(handles.select_data_set, 'Enable', 'On')
end

% --- Executes on selection change in select_data_set.
function select_data_set_Callback(hObject, eventdata, handles)
% hObject    handle to select_data_set (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 select_data_set contents as cell array
%        contents{get(hObject,'Value')} returns selected item from select_data_set

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




% --- Creates and returns a handle to the GUI figure. 
function h1 = stsp_v61_export_LayoutFcn(policy)
% policy - create a new figure or use a singleton. 'new' or 'reuse'.

persistent hsingleton;
if strcmpi(policy, 'reuse') & ishandle(hsingleton)
    h1 = hsingleton;
    return;
end

appdata = [];
appdata.GUIDEOptions = struct(...
    'active_h', 171.095825195313, ...
    'taginfo', struct(...
    'figure', 2, ...
    'pushbutton', 3, ...
    'slider', 5, ...
    'uipanel', 2, ...
    'text', 7, ...
    'edit', 5, ...
    'axes', 2, ...
    'popupmenu', 2), ...
    'override', 0, ...
    'release', 13, ...
    'resize', 'none', ...
    'accessibility', 'callback', ...
    'mfile', 1, ...
    'callbacks', 1, ...
    'singleton', 1, ...
    'syscolorfig', 1, ...
    'blocking', 0, ...
    'lastSavedFile', 'C:\Aravind\Personal Stuffs\COURSES\Intelligent Systems\Simulated Annealing\SA_TSP\stsp_v61_export.m');
appdata.lastValidTag = 'figure1';
appdata.GUIDELayoutEditor = [];

h1 = figure(...
'Units','characters',...
'Color',[0.925490196078431 0.913725490196078 0.847058823529412],...
'Colormap',[0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0],...
'IntegerHandle','off',...
'InvertHardcopy',get(0,'defaultfigureInvertHardcopy'),...
'MenuBar','none',...
'Name','Simulated Annealing (MATLAB V6.1 Compatible)',...
'NumberTitle','off',...
'PaperPosition',get(0,'defaultfigurePaperPosition'),...
'Position',[103.8 23.5384615384616 150.4 37.9230769230769],...
'Resize','off',...
'HandleVisibility','callback',...
'Tag','figure1',...
'UserData',[],...
'Behavior',get(0,'defaultfigureBehavior'),...
'Visible','on',...
'CreateFcn', {@local_CreateFcn, '', appdata} );

appdata = [];
appdata.lastValidTag = 'start_button';

h2 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','stsp_v61_export(''start_button_Callback'',gcbo,[],guidata(gcbo))',...
'Position',[9.8 3.30769230769232 30.2 3.92307692307692],...
'String','Start',...
'Tag','start_button',...
'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

appdata = [];
appdata.lastValidTag = 'plot_axis';

h3 = axes(...
'Parent',h1,...
'Units','characters',...
'Position',[49.8 3.15384615384617 90.2 30.8461538461538],...
'Box','on',...
'CameraPosition',[0.5 0.5 9.16025403784439],...
'CameraPositionMode',get(0,'defaultaxesCameraPositionMode'),...
'Color',get(0,'defaultaxesColor'),...
'ColorOrder',get(0,'defaultaxesColorOrder'),...
'LooseInset',[19.552 4.17153846153846 14.288 2.84423076923077],...
'XColor',get(0,'defaultaxesXColor'),...
'YColor',get(0,'defaultaxesYColor'),...
'ZColor',get(0,'defaultaxesZColor'),...
'Tag','plot_axis',...
'Behavior',get(0,'defaultaxesBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

h4 = get(h3,'title');

set(h4,...
'Parent',h3,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',10,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[0.5 1.01620947630923 1.00005459937205],...
'Rotation',0,...
'String','',...
'Interpreter','tex',...
'VerticalAlignment','bottom',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey','',...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag','',...
'UserData',[],...
'Behavior',struct(),...
'Visible','on',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'Clipping','off');

h5 = get(h3,'xlabel');

set(h5,...
'Parent',h3,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',10,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[0.497782705099778 -0.0586034912718203 1.00005459937205],...
'Rotation',0,...
'String','',...
'Interpreter','tex',...
'VerticalAlignment','cap',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey','',...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag','',...
'UserData',[],...
'Behavior',struct(),...
'Visible','on',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'Clipping','off');

h6 = get(h3,'ylabel');

set(h6,...
'Parent',h3,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',10,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[-0.0631929046563193 0.497506234413965 1.00005459937205],...
'Rotation',90,...
'String','',...
'Interpreter','tex',...
'VerticalAlignment','bottom',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey','',...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag','',...
'UserData',[],...
'Behavior',struct(),...
'Visible','on',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'Clipping','off');

h7 = get(h3,'zlabel');

set(h7,...
'Parent',h3,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',10,...
'FontWeight','normal',...
'HorizontalAlignment','right',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[-0.553215077605322 1.12344139650873 1.00005459937205],...
'Rotation',0,...
'String','',...
'Interpreter','tex',...
'VerticalAlignment','middle',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey','',...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag','',...
'UserData',[],...
'Behavior',struct(),...
'Visible','off',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'Clipping','off');

appdata = [];
appdata.lastValidTag = 'text1';

h8 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'FontSize',10,...
'FontWeight','bold',...
'ForegroundColor',[0 0.250980392156863 0.501960784313725],...
'HorizontalAlignment','left',...
'Position',[12.8 31.3076923076923 27 1.53846153846154],...
'String','Initial Temperature',...
'Style','text',...
'Tag','text1',...
'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

appdata = [];
appdata.lastValidTag = 'cooling_rate_display';

h9 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'FontSize',10,...
'FontWeight','bold',...
'ForegroundColor',[0 0.250980392156863 0.501960784313725],...
'HorizontalAlignment','left',...
'Position',[12.8 26.1538461538462 27 1.53846153846154],...
'String','Cooling Rate : 0.970',...
'Style','text',...
'CreateFcn', {@local_CreateFcn, 'stsp_v61_export(''cooling_rate_display_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','cooling_rate_display',...
'Behavior',get(0,'defaultuicontrolBehavior'));

appdata = [];
appdata.lastValidTag = 'text3';

h10 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'FontSize',10,...
'FontWeight','bold',...
'ForegroundColor',[0 0.250980392156863 0.501960784313725],...
'HorizontalAlignment','left',...
'Position',[12.8 21.4615384615385 27 1.53846153846154],...
'String','Maximum Iterations',...
'Style','text',...
'Tag','text3',...
'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

appdata = [];
appdata.lastValidTag = 'cities_to_swap_display';

h11 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'FontSize',10,...
'FontWeight','bold',...
'ForegroundColor',[0 0.250980392156863 0.501960784313725],...
'HorizontalAlignment','left',...
'Position',[12.8 16.3076923076923 27 1.53846153846154],...
'String','Cities to swap : 2',...
'Style','text',...
'CreateFcn', {@local_CreateFcn, 'stsp_v61_export(''cities_to_swap_display_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','cities_to_swap_display',...
'Behavior',get(0,'defaultuicontrolBehavior'));

appdata = [];
appdata.lastValidTag = 'initial_temperature';

h12 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'BackgroundColor',[1 1 1],...
'Callback','stsp_v61_export(''initial_temperature_Callback'',gcbo,[],guidata(gcbo))',...
'FontSize',14,...
'FontWeight','bold',...
'ForegroundColor',[1 0 0],...
'Position',[12.8 28.5384615384615 23 2],...
'String','2000',...
'Style','edit',...
'Value',2000,...
'CreateFcn', {@local_CreateFcn, 'stsp_v61_export(''initial_temperature_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','initial_temperature',...
'Behavior',get(0,'defaultuicontrolBehavior'));

appdata = [];
appdata.lastValidTag = 'maximum_iterations';

h13 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'BackgroundColor',[1 1 1],...
'Callback','stsp_v61_export(''maximum_iterations_Callback'',gcbo,[],guidata(gcbo))',...
'FontSize',14,...
'FontWeight','bold',...
'ForegroundColor',[1 0 0],...
'Position',[12.8 18.6923076923077 23 2],...
'String','2000',...
'Style','edit',...
'Value',2000,...
'CreateFcn', {@local_CreateFcn, 'stsp_v61_export(''maximum_iterations_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','maximum_iterations',...
'Behavior',get(0,'defaultuicontrolBehavior'));

appdata = [];
appdata.lastValidTag = 'cooling_rate';

h14 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'BackgroundColor',[0.9 0.9 0.9],...
'Callback','stsp_v61_export(''cooling_rate_Callback'',gcbo,[],guidata(gcbo))',...
'Min',0.5,...
'Position',[12.8 23.8461538461539 23 1.53846153846154],...
'String','',...
'Style','slider',...
'SliderStep',[0.005 0.1],...
'Value',0.97,...
'CreateFcn', {@local_CreateFcn, 'stsp_v61_export(''cooling_rate_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','cooling_rate',...
'Behavior',get(0,'defaultuicontrolBehavior'));

appdata = [];
appdata.lastValidTag = 'cities_to_swap';

h15 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'BackgroundColor',[0.9 0.9 0.9],...
'Callback','stsp_v61_export(''cities_to_swap_Callback'',gcbo,[],guidata(gcbo))',...
'Max',10,...
'Min',2,...
'Position',[12.8 14 23 1.53846153846154],...
'String','',...
'Style','slider',...
'SliderStep',[0.125 0.1],...
'Value',2,...
'CreateFcn', {@local_CreateFcn, 'stsp_v61_export(''cities_to_swap_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','cities_to_swap',...
'Behavior',get(0,'defaultuicontrolBehavior'));

appdata = [];
appdata.lastValidTag = 'text6';

h16 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'FontSize',10,...
'FontWeight','bold',...
'ForegroundColor',[0 0.250980392156863 0.501960784313725],...
'HorizontalAlignment','left',...
'Position',[13 11.6153846153846 27 1.53846153846154],...
'String','Select data set',...
'Style','text',...
'CreateFcn', {@local_CreateFcn, 'stsp_v61_export(''cities_to_swap_display_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','text6',...
'Behavior',get(0,'defaultuicontrolBehavior'));

appdata = [];
appdata.lastValidTag = 'select_data_set';

h17 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'BackgroundColor',[1 1 1],...
'Callback','stsp_v61_export(''select_data_set_Callback'',gcbo,[],guidata(gcbo))',...
'Position',[13 9.46153846153847 23.8 1.76923076923077],...
'String',{  'Select TSPLIB data'; '20 cities'; '29 cities'; '48 cities'; '70 cities'; '76 cities'; '96 cities'; '101 cities'; 'PCB 442'; '532 cities' },...
'Style','popupmenu',...
'Value',1,...
'CreateFcn', {@local_CreateFcn, 'stsp_v61_export(''select_data_set_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','select_data_set',...
'Behavior',get(0,'defaultuicontrolBehavior'));


hsingleton = h1;


% --- Set application data first then calling the CreateFcn. 
function local_CreateFcn(hObject, eventdata, createfcn, appdata)

if ~isempty(appdata)
   names = fieldnames(appdata);
   for i=1:length(names)
       name = char(names(i));
       setappdata(hObject, name, getfield(appdata,name));
   end
end

if ~isempty(createfcn)
   eval(createfcn);
end


% --- Handles default GUIDE GUI creation and callback dispatch
function varargout = gui_mainfcn(gui_State, varargin)


%   GUI_MAINFCN provides these command line APIs for dealing with GUIs
%
%      STSP_V61_EXPORT, by itself, creates a new STSP_V61_EXPORT or raises the existing
%      singleton*.
%
%      H = STSP_V61_EXPORT returns the handle to a new STSP_V61_EXPORT or the handle to
%      the existing singleton*.
%
%      STSP_V61_EXPORT('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in STSP_V61_EXPORT.M with the given input arguments.
%
%      STSP_V61_EXPORT('Property','Value',...) creates a new STSP_V61_EXPORT or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before untitled_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to untitled_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".

%   Copyright 1984-2005 The MathWorks, Inc.
%   $Revision: 1.4.6.12 $ $Date: 2005/06/21 19:41:16 $

gui_StateFields =  {'gui_Name'
                    'gui_Singleton'
                    'gui_OpeningFcn'
                    'gui_OutputFcn'
                    'gui_LayoutFcn'
                    'gui_Callback'};
gui_Mfile = '';
for i=1:length(gui_StateFields)
    if ~isfield(gui_State, gui_StateFields{i})
        error('Could not find field %s in the gui_State struct in GUI M-file %s', gui_StateFields{i}, gui_Mfile);        
    elseif isequal(gui_StateFields{i}, 'gui_Name')
        gui_Mfile = [gui_State.(gui_StateFields{i}), '.m'];
    end
end

numargin = length(varargin);

if numargin == 0
    % STSP_V61_EXPORT
    % create the GUI
    gui_Create = 1;
elseif isequal(ishandle(varargin{1}), 1) && ispc && iscom(varargin{1}) && isequal(varargin{1},gcbo)
    % STSP_V61_EXPORT(ACTIVEX,...)    
    vin{1} = gui_State.gui_Name;
    vin{2} = [get(varargin{1}.Peer, 'Tag'), '_', varargin{end}];
    vin{3} = varargin{1};
    vin{4} = varargin{end-1};
    vin{5} = guidata(varargin{1}.Peer);
    feval(vin{:});
    return;
elseif ischar(varargin{1}) && numargin>1 && isequal(ishandle(varargin{2}), 1)
    % STSP_V61_EXPORT('CALLBACK',hObject,eventData,handles,...)
    gui_Create = 0;
else
    % STSP_V61_EXPORT(...)
    % create the GUI and hand varargin to the openingfcn
    gui_Create = 1;
end

if gui_Create == 0
    varargin{1} = gui_State.gui_Callback;
    if nargout
        [varargout{1:nargout}] = feval(varargin{:});
    else
        feval(varargin{:});
    end
else
    if gui_State.gui_Singleton
        gui_SingletonOpt = 'reuse';
    else
        gui_SingletonOpt = 'new';
    end
    
    % Open fig file with stored settings.  Note: This executes all component
    % specific CreateFunctions with an empty HANDLES structure.
    
    % Do feval on layout code in m-file if it exists
    if ~isempty(gui_State.gui_LayoutFcn)
        gui_hFigure = feval(gui_State.gui_LayoutFcn, gui_SingletonOpt);
        % openfig (called by local_openfig below) does this for guis without
        % the LayoutFcn. Be sure to do it here so guis show up on screen.
        movegui(gui_hFigure,'onscreen')
    else
        gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt);            
        % If the figure has InGUIInitialization it was not completely created
        % on the last pass.  Delete this handle and try again.
        if isappdata(gui_hFigure, 'InGUIInitialization')
            delete(gui_hFigure);
            gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt);            
        end
    end
    
    % Set flag to indicate starting GUI initialization
    setappdata(gui_hFigure,'InGUIInitialization',1);

    % Fetch GUIDE Application options
    gui_Options = getappdata(gui_hFigure,'GUIDEOptions');
    
    if ~isappdata(gui_hFigure,'GUIOnScreen')
        % Adjust background color
        if gui_Options.syscolorfig 
            set(gui_hFigure,'Color', get(0,'DefaultUicontrolBackgroundColor'));
        end

        % Generate HANDLES structure and store with GUIDATA. If there is
        % user set GUI data already, keep that also.
        data = guidata(gui_hFigure);
        handles = guihandles(gui_hFigure);
        if ~isempty(handles)
            if isempty(data)
                data = handles;
            else
                names = fieldnames(handles);
                for k=1:length(names)
                    data.(char(names(k)))=handles.(char(names(k)));
                end
            end
        end
        guidata(gui_hFigure, data);
    end
    
    % If user specified 'Visible','off' in p/v pairs, don't make the figure
    % visible.
    gui_MakeVisible = 1;
    for ind=1:2:length(varargin)
        if length(varargin) == ind
            break;
        end
        len1 = min(length('visible'),length(varargin{ind}));
        len2 = min(length('off'),length(varargin{ind+1}));
        if ischar(varargin{ind}) && ischar(varargin{ind+1}) && ...
                strncmpi(varargin{ind},'visible',len1) && len2 > 1
            if strncmpi(varargin{ind+1},'off',len2)
                gui_MakeVisible = 0;
            elseif strncmpi(varargin{ind+1},'on',len2)
                gui_MakeVisible = 1;
            end
        end
    end
    
    % Check for figure param value pairs
    for index=1:2:length(varargin)
        if length(varargin) == index || ~ischar(varargin{index})
            break;
        end
        try set(gui_hFigure, varargin{index}, varargin{index+1}), catch break, end
    end

    % If handle visibility is set to 'callback', turn it on until finished
    % with OpeningFcn
    gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
    if strcmp(gui_HandleVisibility, 'callback')
        set(gui_hFigure,'HandleVisibility', 'on');
    end
    
    feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
    
    if ishandle(gui_hFigure)
        % Update handle visibility
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);
        
        % Make figure visible
        if gui_MakeVisible
            set(gui_hFigure, 'Visible', 'on')
            if gui_Options.singleton 
                setappdata(gui_hFigure,'GUIOnScreen', 1);
            end
        end

        % Done with GUI initialization
        rmappdata(gui_hFigure,'InGUIInitialization');
    end
    
    % If handle visibility is set to 'callback', turn it on until finished with
    % OutputFcn
    if ishandle(gui_hFigure)
        gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
        if strcmp(gui_HandleVisibility, 'callback')
            set(gui_hFigure,'HandleVisibility', 'on');
        end
        gui_Handles = guidata(gui_hFigure);
    else
        gui_Handles = [];
    end
    
    if nargout
        [varargout{1:nargout}] = feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
    else
        feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
    end
    
    if ishandle(gui_hFigure)
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);
    end
end    

function gui_hFigure = local_openfig(name, singleton)

% this application data is used to indicate the running mode of a GUIDE
% GUI to distinguish it from the design mode of the GUI in GUIDE.
setappdata(0,'OpenGuiWhenRunning',1);

% openfig with three arguments was new from R13. Try to call that first, if
% failed, try the old openfig.
try 
    gui_hFigure = openfig(name, singleton, 'auto');
catch
    % OPENFIG did not accept 3rd input argument until R13,
    % toggle default figure visible to prevent the figure
    % from showing up too soon.
    gui_OldDefaultVisible = get(0,'defaultFigureVisible');
    set(0,'defaultFigureVisible','off');
    gui_hFigure = openfig(name, singleton);
    set(0,'defaultFigureVisible',gui_OldDefaultVisible);
end
rmappdata(0,'OpenGuiWhenRunning');

Contact us at files@mathworks.com