No BSD License  

Highlights from
MatPlanWDM v0.5

image thumbnail

MatPlanWDM v0.5

by

 

29 Jan 2007 (Updated )

Educational network planning tool for the RWA problem in WDM networks (MILP and heuristic based)

WhatIfAnalysis(varargin)
function varargout = WhatIfAnalysis(varargin)


% MATPLANWDM Application M-file for matplanwdm.fig
%    FIG = matplanwdm2 launch matplanwdm2 GUI.
%    matplanwdm('callback_name', ...) invoke the named callback.

% Last Modified by GUIDE v2.5 14-Jul-2006 18:15:26

if nargin == 0  % LAUNCH GUI
    close all
    clear all
    clc

	fig = openfig(mfilename,'new');

	% Generate a structure of handles to pass to callbacks, and store it. 
	handles = guihandles(fig);
	guidata(fig, handles);
    
    
   	if nargout > 0
		varargout{1} = fig;
	end
    
    gui_ini(handles)
    

elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK

	try
		if (nargout)
			[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
		else
			feval(varargin{:}); % FEVAL switchyard
		end
	catch
		disp(lasterr);
	end

end

%set(fig,'Color',get(0,'DefaultUicontrolBackgroundColor'));

%| ABOUT CALLBACKS:
%| GUIDE automatically appends subfunction prototypes to this file, and 
%| sets objects' callback properties to call them through the FEVAL 
%| switchyard above. This comment describes that mechanism.
%|
%| Each callback subfunction declaration has the following form:
%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)
%|
%| The subfunction name is composed using the object's Tag and the 
%| callback type separated by '_', e.g. 'slider2_Callback',
%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.
%|
%| H is the callback object's handle (obtained using GCBO).
%|
%| EVENTDATA is empty, but reserved for future use.
%|
%| HANDLES is a structure containing handles of components in GUI using
%| tags as fieldnames, e.g. handles.figure1, handles.slider2. This
%| structure is created at GUI startup using GUIHANDLES and stored in
%| the figure's application data using GUIDATA. A copy of the structure
%| is passed to each callback.  You can store additional information in
%| this structure at GUI startup, and you can change the structure
%| during callbacks.  Call guidata(h, handles) after changing your
%| copy to replace the stored original so that subsequent callbacks see
%| the updates. Type "help guihandles" and "help guidata" for more
%| information.
%|
%| VARARGIN contains any extra arguments you have passed to the
%| callback. Specify the extra arguments by editing the callback
%| property in the inspector. By default, GUIDE sets the property to:
%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))
%| Add any extra arguments after the last argument, before the final
%| closing parenthesis.
%
%set(fig,'Color',get(0,'DefaultUicontrolBackgroundColor'));

% --------------------------------------------------------------------
% --------------------------------------------------------------------
% INITIALIZATION FUNCTION
% --------------------------------------------------------------------
% --------------------------------------------------------------------
function gui_ini(handles)

load_global;
imageUPCT=imread('upct_logo.jpg','jpg');
axes(handles.axes6);
image(imageUPCT);
axis off
set(handles.men1,'Checked','off');
set(handles.men2,'Checked','on');


%%HEURISTICS MENU BUILDING
h = dir(fullfile(pwd, 'algorithms/staticPlanning/*.m'));
priv_h = dir(fullfile(pwd, 'algorithms/private/staticPlanning/*.m'));

numberOfPublicHeuristicAlgorithms = length(h);
numberOfPrivateHeuristicAlgorithms = length(priv_h);

heuristicAlgorithms=cell(numberOfPublicHeuristicAlgorithms+numberOfPrivateHeuristicAlgorithms,1);
heuristicAlgorithms(1:numberOfPublicHeuristicAlgorithms) = {h.name}';
heuristicAlgorithms(numberOfPublicHeuristicAlgorithms+1:end) = {priv_h.name}';

numberOfHeuristicAlgorithms=length(heuristicAlgorithms);
methodsString=cell(numberOfHeuristicAlgorithms+2,1);
methodsString(1)={['Select desired']};
methodsString(2)={['Mixer-integer Linear Programming (MILP)']};
methodsString(3:length(methodsString))=heuristicAlgorithms;

set(handles.method_popupmenu,'String',methodsString);


% --------------------------------------------------------------------
% --------------------------------------------------------------------
% MENUs
% --------------------------------------------------------------------
% --------------------------------------------------------------------

% *********************************************************************
% *********************************************************************
% MENU 1 - FILE
% *********************************************************************
% *********************************************************************

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Quit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = Quit_Callback(h, eventdata, handles, varargin)

close
close all



% *********************************************************************
% *********************************************************************
% MENU 2 - MODE
% *********************************************************************
% *********************************************************************

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%mode1 - DESIGN LIGHTPATH LOGICAL NETWORK
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = mode1_Callback(h, eventdata, handles, varargin)

set(handles.men1,'Checked','on');
set(handles.men2,'Checked','off');
set(handles.men3,'Checked','off');
set(handles.men4,'Checked','off');

clear all
close
matplanwdm



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%mode2 - WHAT IF ANALYSIS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = modeWhatIf_Callback(h, eventdata, handles, varargin)

set(handles.men1,'Checked','off');
set(handles.men2,'Checked','on');
set(handles.men3,'Checked','off');
set(handles.men4,'Checked','off');

clear all
close
WhatIfAnalysis



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%mode3 - MULTIHOUR ANALYSIS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = modeMultiHour_Callback(h, eventdata, handles, varargin)

set(handles.men1,'Checked','off');
set(handles.men2,'Checked','off');
set(handles.men3,'Checked','on');
set(handles.men4,'Checked','off');

clear all
close
MultiHourAnalysis

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%mode4 - DYNAMIC ANALYSIS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = modeDynamic_Callback(h, eventdata, handles, varargin)

set(handles.men1,'Checked','off');
set(handles.men2,'Checked','off');
set(handles.men3,'Checked','off');
set(handles.men4,'Checked','on');

clear all
close
Dynamic






% *********************************************************************
% *********************************************************************
% MENU 3 - TOOLS
% *********************************************************************
% *********************************************************************

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Traffic Generation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = trafficGen_Callback(h, eventdata, handles, varargin)

% load_global;%Global variables are loaded 

trafficGenerationFigure=openfig('trafficGeneration.fig','reuse');
dataTrafficGenerationFigure=guihandles(trafficGenerationFigure);
guidata(trafficGenerationFigure,dataTrafficGenerationFigure);

numberOfNodes=0;

% *********************************************************************
% *********************************************************************
% MENU 4 - HELP
% *********************************************************************
% *********************************************************************

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%MatplanWDM HELP
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = matplanwdmHelp_Callback(h, eventdata, handles, varargin)

HelpPath =[pwd '\help\matplanwdmHelp.html'];
web(HelpPath,  '-helpbrowser')


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%About
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = about_Callback(h, eventdata, handles, varargin)

openfig('about.fig','new')






% --------------------------------------------------------------------
% --------------------------------------------------------------------
% GENERAL INPUT ARGUMENTS
% --------------------------------------------------------------------
% --------------------------------------------------------------------

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%openPhysFile_pushbutton - OPEN PHYS FILE BUTTON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = openPhysFile_pushbutton_Callback(h, eventdata, handles, varargin)

load_global_WhatIf;%Global variables are loaded
axes(handles.axes1);

%We open the file to read our 'Physical Topology File (*.phys)'
[filename, pathname] = uigetfile({'*.xml','Physical Topology File'},'Open Physical Topology File','data\physicalTopologies\');
topologyFilename=filename;
fullpathname=[pathname filename];
try
    [metadata, physFromFile] = io_readXML(fullpathname);
    checkPhys(physFromFile)
catch
    lastErrorMsg=lasterr;
    errordlg(lastErrorMsg,'Unexpected Error On Reading/Checking Physical Topology from the XML File!!!','modal');
    return
end

axes(handles.axes1);
hold off
plotTopology(physFromFile.nodesPlaceMatrix,physFromFile.linkTable,0,'',1)
axis('off');

% %We show the loaded file in the edit
physTextReport = physXMLfileTextReport(metadata , physFromFile);
previousText=get(handles.edit6,'String');
topologyReport=vertcat(previousText, {[' ']},{['######### PHYSICAL TOPOLOGY FILE  "',topologyFilename,'"  LOADED ##########']},{[' ']}, physTextReport) ;                      
set(handles.edit6,'String', topologyReport);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%openTraffFile_pushbutton - OPEN TRAFF FILE BUTTON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = openTraffFile_pushbutton_Callback(h, eventdata, handles, varargin)

load_global_WhatIf;%Global variables are loaded

%We open the file to read our 'Traffic File (*.traff)'
[filename, pathname] = uigetfile({'*.traff','Traffic File (*.traff)'},'Open Traffic File','data\traffics\');
trafficFilename=filename;
fullpathname=[pathname filename];
[traff_trafficMatrixFromFile, errmsg, errorFlag] = IO_readTraffFile(fullpathname);
if errorFlag==-1,
    errordlg(errmsg,'Error On Reading Traff File!!!','modal');
    return
else
    [traffString] = IO_writeTraffString(traff_trafficMatrixFromFile);
end

% %We show the loaded file in the edit
previousText=get(handles.edit6,'String');
trafficReport=vertcat(previousText, {[' ']},{['############### TRAFFIC FILE  "',trafficFilename,'"  LOADED ##############']},{[' ']}, {traffString});
set(handles.edit6,'String', trafficReport);




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FirstSweepParameter_popupmenu - POPUPMENU TO SELECT THE 1st SWEEP PARAMETER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = FirstSweepParameter_popupmenu_Callback(h, eventdata, handles, varargin)

load_global_WhatIf;%Global variables are loaded


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SecondSweepParameter_popupmenu - POPUPMENU TO SELECT THE 2nd SWEEP PARAMETER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = SecondSweepParameter_popupmenu_Callback(h, eventdata, handles, varargin)

load_global_WhatIf;%Global variables are loaded


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FirstSweepLowerLimit_edit - LOWER LIMIT OF THE FIRST SWEEP IN %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = FirstSweepLowerLimit_edit_Callback(h, eventdata, handles, varargin)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FirstSweepStep_edit - UPPER LIMIT OF THE FIRST SWEEP IN %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = FirstSweepStep_edit_Callback(h, eventdata, handles, varargin)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FirstSweepNrPoints_edit - NUMBER OF POINTS IN THE FIRST SWEEP 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = FirstSweepNrPoints_edit_Callback(h, eventdata, handles, varargin)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SecondSweepLowerLimit_edit - LOWER LIMIT OF THE SECOND SWEEP IN %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = SecondSweepLowerLimit_edit_Callback(h, eventdata, handles, varargin)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SecondSweepStep_edit - UPPER LIMIT OF THE SECOND SWEEP IN %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = SecondSweepStep_edit_Callback(h, eventdata, handles, varargin)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SecondSweepNrPoints_edit - NUMBER OF POINTS IN THE SECOND SWEEP 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = SecondSweepNrPoints_edit_Callback(h, eventdata, handles, varargin)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%secondSweep_checkbox - CHECKBOX TO ACTIVATE THE SECOND SWEEP PARAMETER 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout= secondSweep_checkbox(h, eventdata, handles, varargin)

if get(handles.secondSweep_checkbox,'Value')==1,
    set(handles.text40,'Enable','On')
    set(handles.text43,'Enable','On')
    set(handles.text44,'Enable','On')
    set(handles.text45,'Enable','On')
    set(handles.text48,'Enable','On')
    set(handles.SecondSweepParameter_popupmenu,'Enable','On')
    set(handles.SecondSweepLowerLimit_edit,'Enable','On')
    set(handles.SecondSweepStep_edit,'Enable','On')
    set(handles.SecondSweepNrPoints_edit,'Enable','On')   
else
    set(handles.text40,'Enable','Off')
    set(handles.text43,'Enable','Off')
    set(handles.text44,'Enable','Off')
    set(handles.text45,'Enable','Off')
    set(handles.text48,'Enable','Off')
    set(handles.SecondSweepParameter_popupmenu,'Enable','Off')
    set(handles.SecondSweepLowerLimit_edit,'Enable','Off')
    set(handles.SecondSweepStep_edit,'Enable','Off')
    set(handles.SecondSweepNrPoints_edit,'Enable','Off')  
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%POPUPMENU TO SELECTED METHODS FOR THE ANALYSIS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = method_popupmenu_Callback(h, eventdata, handles, varargin)



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%PUSHBUTTON TO DEFINE THE METHODS FOR THE ANALYSIS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = listOfMethods_pushbutton_Callback(h, eventdata, handles, varargin)
load_global_WhatIf;

methodSelection=get(handles.method_popupmenu,'Value')-1;
algorithmParameters=get(handles.AlgorithmParameters_edit, 'String');

%we catch the algorithm parameters 
switch methodSelection
    case 0
        errordlg('Incorrect Method Selection','Empty or Bad Input Data','modal');
        return;
    case 1 %MILP Method
        method='MILP';   
    otherwise%heuristics
        [pathstr,method,ext,versn]=fileparts(heuristicAlgorithms{methodSelection-1}); 
end

previousText=get(handles.listOfMethods_edit,'String');
numberOfMethods=numel(previousText)+1;

listOfMethodsString=vertcat(previousText, {[num2str(numberOfMethods),'. ' method ' - ' algorithmParameters]});                
set(handles.listOfMethods_edit,'String',listOfMethodsString)

if numberOfMethods > 1, %We deactivate the 2nd sweep
    set(handles.secondSweep_checkbox,'Enable','Off')
    set(handles.secondSweep_checkbox,'Value',0)
    set(handles.text40,'Enable','Off')
    set(handles.text43,'Enable','Off')
    set(handles.text44,'Enable','Off')
    set(handles.text45,'Enable','Off')
    set(handles.text48,'Enable','Off')
    set(handles.SecondSweepParameter_popupmenu,'Enable','Off')
    set(handles.SecondSweepLowerLimit_edit,'Enable','Off')
    set(handles.SecondSweepStep_edit,'Enable','Off')
    set(handles.SecondSweepNrPoints_edit,'Enable','Off') 
else
    set(handles.secondSweep_checkbox,'Enable','On')
end
    

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%PUSHBUTTON TO REMOVE METHODS FROM THE LIST OF METHODS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = RemoveMethod_pushbutton_Callback(h, eventdata, handles, varargin)

load_global_WhatIf;%Global variables are loaded

listOfMethodsString=get(handles.listOfMethods_edit,'String');
numberOfMethods=numel(listOfMethodsString);
if numberOfMethods>0,
    listOfMethodsString(end)=[];
    numberOfMethods=numberOfMethods-1;
end
set(handles.listOfMethods_edit,'String',listOfMethodsString)

if numberOfMethods > 1, %We deactivate the 2nd sweep
    set(handles.secondSweep_checkbox,'Enable','Off')
    set(handles.secondSweep_checkbox,'Value',0)
    set(handles.text40,'Enable','Off')
    set(handles.text43,'Enable','Off')
    set(handles.text44,'Enable','Off')
    set(handles.text45,'Enable','Off')
    set(handles.text48,'Enable','Off')
    set(handles.SecondSweepParameter_popupmenu,'Enable','Off')
    set(handles.SecondSweepLowerLimit_edit,'Enable','Off')
    set(handles.SecondSweepStep_edit,'Enable','Off')
    set(handles.SecondSweepNrPoints_edit,'Enable','Off') 
else
    set(handles.secondSweep_checkbox,'Enable','On')
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%metric_popupmenu - METRIC SELECTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
function varargout = metric_popupmenu_Callback(h, eventdata, handles, varargin)

load_global_WhatIf;%Global variables are loaded        
axes(handles.axes2);
metricSelection=get(handles.metric_popupmenu,'Value')-1;

switch metricSelection
    case 1
        yAxeYLabel =['Carried Traffic / Offered Traffic (%)'];
    case 2
        yAxeYLabel=['Number of Virtual Hops'];
    case 3
        yAxeYLabel=['Network Congestion (Gbps)'];
    case 4
        yAxeYLabel=['Single Hop Traffic / Offered Traffic (%)'];
    case 5
        yAxeYLabel=['Number of Lightpaths)'];
    case 6
        yAxeYLabel=['Number of Used Wavelengths Channels'];
    case 7
        yAxeYLabel=['Number of Lightpaths per Fiber Link'];
    case 8
        yAxeYLabel=['Message Propgation Delay (us)']; 
end
  
markers=['o' 'x' '+' '*' 's' 'd' 'v' '^' '<' '>' 'p' 'h'];
colors=['b' 'g' 'r' 'c' 'm' 'y' 'b' 'g' 'r' 'c' 'm' 'y'];

if secondSweepNrPoints>1,%there is second sweep
   SweepOfSecondParameterPrct=linspace(secondSweepLowerLimit, secondSweepUpperLimit, secondSweepNrPoints);
end

legendLabel=listOfMethodsString;

% if size(listOfMethodsString,1)>1,%there are severla methods
%    legendLabel=listOfMethodsString;
% end

h=0;
cla reset;
for j=1:secondSweepNrPoints, 
    for n=1:size(listOfMethodsString,1),
        h=h+1;
        if secondSweepNrPoints>1,%there is second sweep
           legendLabel(h)={[num2str(SweepOfSecondParameterPrct(h)), '%' ]};
        end

        hold on;
        SweepOfFirstParameterPrct=linspace(firstSweepLowerLimit, firstSweepUpperLimit, firstSweepNrPoints);
        plot(SweepOfFirstParameterPrct, SweepOfPlottingMetrics(metricSelection, : , j, n), cat(2,colors(h),markers(h),'-'));     
    end
end

xAxeXLabel = nameOfFirstSweepParameter;
xlabel(xAxeXLabel);
ylabel(yAxeYLabel); 
legend(legendLabel);

% metricsFigureHandle = gca
% metricsFigureHandle=handles.axes2
% legend(legendLabel,'boxoff');


metricsFigureHandle = figure(1);
h=0;
cla reset;
for j=1:secondSweepNrPoints, 
    for n=1:size(listOfMethodsString,1),
        h=h+1;
        if secondSweepNrPoints>1,%there is second sweep
           legendLabel(h)={[num2str(SweepOfSecondParameterPrct(h)), '%' ]};
        end

        hold on;
        SweepOfFirstParameterPrct=linspace(firstSweepLowerLimit, firstSweepUpperLimit, firstSweepNrPoints);
        plot(SweepOfFirstParameterPrct, SweepOfPlottingMetrics(metricSelection, : , j, n), cat(2,colors(h),markers(h),'-'));     
    end
end
xAxeXLabel = nameOfFirstSweepParameter;
xlabel(xAxeXLabel);
ylabel(yAxeYLabel); 
legend(legendLabel);
title([yAxeYLabel,' - Perfomance Curves '])

% --------------------------------------------------------------------
% --------------------------------------------------------------------
% EXECUTION CONTROLS
% --------------------------------------------------------------------
% --------------------------------------------------------------------


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Start_pushbutton - START BUTTON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = Start_pushbutton_Callback(h, eventdata, handles, varargin)

delete(statusbar);
load_global_WhatIf;%Global variables are loaded

%We clear the current curves of metrics perfomance
axes(handles.axes2);
cla reset;
% plot(0,0);
axis('off');
set(handles.metric_popupmenu,'Value',1);
set(handles.metric_popupmenu,'Enable','off');
set(handles.text23,'Enable','off');

%We save the phys structure and the traffic matrix loaded by the files.
phys=physFromFile;
traff_trafficMatrix=traff_trafficMatrixFromFile;

%CHECK INPUT DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We check that all the input data were entered are correct
if isempty(phys) 
    errordlg('Phys File Not Selected', 'Empty or Bad Input Data','modal');
    return;
elseif isempty(traff_trafficMatrix),
    errordlg('Traff File Not Selected','Empty or Bad Input Data','modal');
    return;
elseif size(phys.nodesPlaceMatrix,1)~=size(traff_trafficMatrix,1),
    errordlg('Phys File and Traff File does not match in the number of nodes','Bad Input Data','modal');
    return;
elseif isempty(listOfMethodsString),
    errordlg('None Method Selected','Empty or Bad Input Data','modal');
    return;    
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FIRST SWEEP 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%1.We select the first sweep parameter from the popupmenu and catch it from
%the input data
firstSweepParameterSelection=get(handles.FirstSweepParameter_popupmenu,'Value')-1;
switch firstSweepParameterSelection
    case 1
        firstSweepParameter=phys.numberTxPerNode;
    case 2
        firstSweepParameter=phys.numberRxPerNode;
    case 3
        firstSweepParameter=phys.numberTWCPerNode;
    case 4
        firstSweepParameter=phys.numberWavelengthPerFiber;
    case 5
        firstSweepParameter=phys.lightpathCapacity; 
    case 6
        firstSweepParameter=traff_trafficMatrix;
    otherwise
        firstSweepParameter=[];
        errordlg('The 1st Sweep Parameter was not selected','Incorrect Selection','modal');
        return;
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%2.Once the first sweep parameter is selected, we sweep it from the lower
%limit defined by the edit text as many times as the entered number of sim points 

%%%%%%%%%%%%%%%%1st SWEEP%%%%%%%%%%%%%%%%%%%
%%%%Lower Limit
auxFirstSweepLowerLimit=str2num(get(handles.FirstSweepLowerLimit_edit,'String'));
if isempty(auxFirstSweepLowerLimit),
    errordlg('The Lower Limit of the 1st Sweep must be a non-negative number','Incorrect Value','modal')
    return;
elseif auxFirstSweepLowerLimit < 0,
    errordlg('The Lower Limit of the 1st Sweep must be bigger than 0','Incorrect Value','modal')
    return;
else
    firstSweepLowerLimit=auxFirstSweepLowerLimit;
end

%%%%Sweep Step
auxFirstSweepStep=str2num(get(handles.FirstSweepStep_edit,'String'));
if isempty(auxFirstSweepStep),
    errordlg('The Step of the 1st Sweep must be a positive number','Incorrect Value','modal') 
    return;
elseif auxFirstSweepStep < 0,
    errordlg('The Step of the 1st Sweep must be bigger than 0','Incorrect Value','modal')
    return;
else
    firstSweepStep=auxFirstSweepStep;
end

%%%%Nr of Points
auxFirstSweepNrPoints=str2num(get(handles.FirstSweepNrPoints_edit,'String'));
if isempty(auxFirstSweepNrPoints),
    errordlg('The Number of Points of the 1st Sweep must be a positive number','Incorrect Value','modal') 
    return;
elseif auxFirstSweepNrPoints <= 0 | (abs(auxFirstSweepNrPoints)-abs(fix(auxFirstSweepNrPoints)) ~= 0),
    errordlg('The Number of Points of the 1st Sweep must be a positive integer number','Incorrect Value','modal')
    return;
else
    firstSweepNrPoints=auxFirstSweepNrPoints;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%3. When we have all the data to make the sweep, we define the simulation
%points of the 1st sweep

firstSweepUpperLimit = firstSweepLowerLimit + firstSweepStep*(firstSweepNrPoints-1);
firstSweepPrct = (firstSweepLowerLimit:firstSweepStep:firstSweepUpperLimit)/100;
[nrRows nrCols]=size(firstSweepParameter);
if nrRows==1 & nrCols==1,%firstSweepParameter is a scalar
    firstSweep = firstSweepPrct.*firstSweepParameter;
elseif nrRows==1 | nrCols==1,%firstSweepParameter is a vector
    firstSweep=zeros(length(firstSweepParameter),firstSweepNrPoints);
    for i=1:firstSweepNrPoints,
        firstSweep(:,i) = firstSweepPrct(i).*firstSweepParameter;
    end
elseif nrRows>1 & nrCols>1,%firstSweepParameter is a matrix
    firstSweep=zeros(nrRows,nrCols,firstSweepNrPoints);
    for i=1:firstSweepNrPoints,
        firstSweep(:,:,i) = firstSweepPrct(i).*firstSweepParameter;
    end
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SECOND SWEEP (IF SELECTED OF POSSIBLE)
%4.We check if the second sweep is activated, otherwise, we fix the number
%of points of the second sweep to 1 and the secondSweepParameterSelection
%to 0
if get(handles.secondSweep_checkbox,'Value')==0,
    secondSweepNrPoints=1;
    secondSweepParameterSelection=0;

else %if 2nd sweep is activated:

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %5.We select the second sweep parameter from the popupmenu and catch it from
    %the input data
    secondSweepParameterSelection=get(handles.SecondSweepParameter_popupmenu,'Value')-1;
    switch secondSweepParameterSelection
        case 1
            secondSweepParameter=phys.numberTxPerNode;
        case 2
            secondSweepParameter=phys.numberRxPerNode;
        case 3
            secondSweepParameter=phys.numberTWCPerNode;
        case 4
            secondSweepParameter=phys.numberWavelengthPerFiber;
        case 5
            secondSweepParameter=phys.lightpathCapacity; 
        case 6
            secondSweepParameter=traff_trafficMatrix;
        otherwise
            secondSweepParameter=[];
            errordlg('The 2nd Sweep Parameter was not selected','Incorrect Selection','modal');
            return;
    end

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %6.Once the second sweep parameter is selected, we sweep it from the lower
    %limit up to the upper limit defined by the edit texts as many times as the
    %entered number of points 

    %%%%%%%%%%%%%%%%2nd SWEEP%%%%%%%%%%%%%%%%%%%
    %%%%Lower Limit
    auxSecondSweepLowerLimit=str2num(get(handles.SecondSweepLowerLimit_edit,'String'));
    if isempty(auxSecondSweepLowerLimit),
        errordlg('The Lower Limit of the 2nd Sweep must be a non-negative number','Incorrect Value','modal') 
        return
    elseif auxSecondSweepLowerLimit < 0,
        errordlg('The Lower Limit of the 2nd Sweep must be bigger than 0','Incorrect Value','modal')
        return  
    else
        secondSweepLowerLimit=auxSecondSweepLowerLimit;
    end

    %%%%Sweep Step
    auxSecondSweepStep=str2num(get(handles.SecondSweepStep_edit,'String'));
    if isempty(auxSecondSweepStep),
        errordlg('The Step of the 2nd Sweep must be a positive number','Incorrect Value','modal') 
        return;
    elseif auxSecondSweepStep < 0,
        errordlg('The Step of the 2nd Sweep must be bigger than 0','Incorrect Value','modal')
        return;
    else
        secondSweepStep=auxSecondSweepStep;
    end

    %%%%Nr of Points
    auxSecondSweepNrPoints=str2num(get(handles.SecondSweepNrPoints_edit,'String'));
    if isempty(auxSecondSweepNrPoints),
        errordlg('The Number of Points of the 1st Sweep must be a positive number','Incorrect Value','modal') 
        return
    elseif auxSecondSweepNrPoints <= 0 | (abs(auxSecondSweepNrPoints)-abs(fix(auxSecondSweepNrPoints)) ~= 0),
        errordlg('The Number of Points of the 1st Sweep must be a positive number','Incorrect Value','modal')
        return
    else
        secondSweepNrPoints=auxSecondSweepNrPoints;
    end

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %7. When we have all the data to make the sweep, we define the simulation
    %points of the 2nd sweep
    secondSweepUpperLimit = secondSweepLowerLimit + secondSweepStep*(secondSweepNrPoints-1);
    secondSweepPrct = (secondSweepLowerLimit:secondSweepStep:secondSweepUpperLimit)/100;

    [nrRows nrCols]=size(secondSweepParameter);
    if nrRows==1 & nrCols==1,%secondSweepParameter is a scalar
        secondSweep = secondSweepPrct.*secondSweepParameter;
    elseif nrRows==1 | nrCols==1,%secondSweepParameter is a vector
        secondSweep=zeros(length(secondSweepParameter),secondSweepNrPoints);
        for i=1:secondSweepNrPoints,
            secondSweep(:,i) = secondSweepPrct(i).*secondSweepParameter;
        end
    elseif nrRows>1 & nrCols>1,%secondSweepParameter is a matrix
        secondSweep=zeros(nrRows,nrCols,secondSweepNrPoints);
        for i=1:secondSweepNrPoints,
            secondSweep(:,:,i) = secondSweepPrct(i).*secondSweepParameter;
        end
    end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%8.We define the sweep of the physical topology (SweepOfPhys) and the sweep of
%the traffic matrix (SweepOfTrafficMatrix)
SweepOfPhys=cell(firstSweepNrPoints, secondSweepNrPoints);
SweepOfTrafficMatrix=cell(firstSweepNrPoints, secondSweepNrPoints);

for i=1:firstSweepNrPoints,   
    switch firstSweepParameterSelection
        case 1
            phys.numberTxPerNode=round(firstSweep(:,i))';
            nameOfFirstSweepParameter=['Number of Transmitters per Node (%)'];
            SweepOfFirstParameter=phys.numberTxPerNode;
        case 2
            phys.numberRxPerNode=round(firstSweep(:,i))';
            nameOfFirstSweepParameter=['Number of Receivers per Node (%)'];
            SweepOfFirstParameter=phys.numberRxPerNode;
        case 3
            phys.numberTWCPerNode=round(firstSweep(:,i))';
            nameOfFirstSweepParameter=['Number of TWCs per Node (%)'];
            SweepOfFirstParameter=phys.numberTWCPerNode;
        case 4
            phys.numberWavelengthPerFiber=round(firstSweep(:,i))';
            nameOfFirstSweepParameter=['Number of Wavelengths per Fiber (%)'];
            SweepOfFirstParameter=phys.numberWavelengthPerFiber;
        case 5
            phys.lightpathCapacity=firstSweep(i);
            nameOfFirstSweepParameter=['Wavelength Channel Capacity (Gbps) (%)'];
            SweepOfFirstParameter=phys.lightpathCapacity;
        case 6
            traff_trafficMatrix=firstSweep(:,:,i);
            nameOfFirstSweepParameter=['Traffic Demand (%)'];
            SweepOfFirstParameter=traff_trafficMatrix;
    end  

    for j=1:secondSweepNrPoints,
        switch secondSweepParameterSelection
            case 1
                phys.numberTxPerNode=round(secondSweep(:,j))';
                nameOfSecondSweepParameter=['Number of Transmitters per Node (%)'];
                SweepOfSecondParameter=phys.numberTxPerNode;
            case 2
                phys.numberRxPerNode=round(secondSweep(:,j))';
                nameOfSecondSweepParameter=['Number of Receivers per Node (%)'];
                SweepOfSecondParameter=phys.numberRxPerNode;
            case 3
                phys.numberTWCPerNode=round(secondSweep(:,j))';
                nameOfSecondSweepParameter=['Number of TWCs per Node (%)'];
                SweepOfSecondParameter=phys.numberTWCPerNode;
            case 4
                phys.numberWavelengthPerFiber=round(secondSweep(:,j))';
                nameOfSecondSweepParameter=['Number of Wavelengths per Fiber (%)'];
                SweepOfSecondParameter=phys.numberWavelengthPerFiber;
            case 5
                phys.lightpathCapacity=secondSweep(j);
                nameOfSecondSweepParameter=['Wavelength Channel Capacity (%)'];
                SweepOfSecondParameter=phys.lightpathCapacity;
            case 6
                traff_trafficMatrix=secondSweep(:,:,j);
                nameOfSecondSweepParameter=['Traffic Demand (%)'];
                SweepOfSecondParameter=traff_trafficMatrix;
            otherwise %if second sweep is not activated
        end  
        SweepOfPhys(i,j)={phys};
        SweepOfTrafficMatrix(i,j)={traff_trafficMatrix};
    end

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%9. We compute the netState of each sweep point using the selected method

exitMsg=cell(firstSweepNrPoints, secondSweepNrPoints, size(listOfMethodsString,1));
exitFlag=zeros(firstSweepNrPoints, secondSweepNrPoints, size(listOfMethodsString,1));
SweepOfNetState=cell(firstSweepNrPoints, secondSweepNrPoints, size(listOfMethodsString,1));
SweepOfStatMetrics=cell(firstSweepNrPoints, secondSweepNrPoints, size(listOfMethodsString,1));
SweepOfPlottingMetrics=zeros(5, firstSweepNrPoints, secondSweepNrPoints, size(listOfMethodsString,1));

anyExitFlagIsNull=0;

f=statusbar('What If Analysis in progress ...');
k=0;
for n=1:size(listOfMethodsString,1),
    currentMethodString=listOfMethodsString{n};
    indecesOfSpaces=find(currentMethodString==' ');
    method=currentMethodString(indecesOfSpaces(1)+1:indecesOfSpaces(2)-1);
    algorithmParameters=currentMethodString(indecesOfSpaces(3)+1:end);
    
    %We sweep the parameters
    for i=1:firstSweepNrPoints,   
        for j=1:secondSweepNrPoints,
            if strcmp(method, 'MILP'),%MILP
                tic
                [exitMsg{i,j,n} exitFlag(i,j,n) SweepOfNetState{i,j,n}] = ...
                     MILP(cell2mat(SweepOfTrafficMatrix(i,j)), SweepOfPhys{i,j}, algorithmParameters); 
                designTime=toc;                    
            else%heuristic methods  
                try
                    tic
                    [exitMsg{i,j,n} exitFlag(i,j,n) SweepOfNetState{i,j,n}] = ...
                        feval(method, cell2mat(SweepOfTrafficMatrix(i,j)), SweepOfPhys{i,j}, algorithmParameters);
                    designTime=toc;
                catch
                    delete(f);
                    lastErrorMsg=lasterr;
                    errordlg(lastErrorMsg,'Unexpected Error in What If Analysis','modal')
                    return;
                end                
            end
                       
            if exitFlag(i,j,n) == 1;
                anyExitFlagIsNull = 1;
                SweepOfStatMetrics{i,j,n}=[];
                
               SweepOfPlottingMetrics(1,i,j,n)=NaN;
               SweepOfPlottingMetrics(2,i,j,n)=NaN;
               SweepOfPlottingMetrics(3,i,j,n)=NaN;
               SweepOfPlottingMetrics(4,i,j,n)=NaN;
               SweepOfPlottingMetrics(5,i,j,n)=NaN;
               SweepOfPlottingMetrics(6,i,j,n)=NaN;
               SweepOfPlottingMetrics(7,i,j,n)=NaN;
              
            else
               %Check netState correct
                try
                    flag_removeLoops=1;
                    flag_checkLpRoutingMatrix=1;
                    flag_lossesAllowed=1;
                    flag_checkLoops=1;
                    [flag_modifiedNetState SweepOfNetState{i,j,n}]= checkNetState(SweepOfNetState{i,j,n} , SweepOfPhys{i,j}, cell2mat(SweepOfTrafficMatrix(i,j)) , flag_checkLoops, flag_removeLoops , flag_checkLpRoutingMatrix , flag_lossesAllowed);

                catch
                    delete(f)
                    lastErrorMsg=lasterr;
                    errordlg(lastErrorMsg,'Unexpected Error on checking the planned design!!!','modal')
                    return;   
                end
                             
               SweepOfStatMetrics{i,j,n} = calculateStaticNetMetrics(SweepOfPhys{i,j}, SweepOfNetState{i,j,n});
                
               SweepOfPlottingMetrics(1,i,j,n)=(SweepOfStatMetrics{i,j,n}.carriedTraffic)*100/sum(sum(cell2mat(SweepOfTrafficMatrix(i,j)),1),2);
               SweepOfPlottingMetrics(2,i,j,n)=SweepOfStatMetrics{i,j,n}.averVirtualHops;
               SweepOfPlottingMetrics(3,i,j,n)=SweepOfStatMetrics{i,j,n}.networkCongestion;        
               SweepOfPlottingMetrics(4,i,j,n)=SweepOfStatMetrics{i,j,n}.singleHopTraffic*100/sum(sum(cell2mat(SweepOfTrafficMatrix(i,j)),1),2);
               SweepOfPlottingMetrics(5,i,j,n)=SweepOfStatMetrics{i,j,n}.numberOfLightpaths;
               SweepOfPlottingMetrics(6,i,j,n)=SweepOfStatMetrics{i,j,n}.totalNrOfUsedWavelengths;
               SweepOfPlottingMetrics(7,i,j,n)=SweepOfStatMetrics{i,j,n}.maximumLinkLoadinNrLightpaths;
               SweepOfPlottingMetrics(8,i,j,n)=SweepOfStatMetrics{i,j,n}.messagePropagationDelay;  

            end
            k=k+1;
            statusbar(k/(firstSweepNrPoints*secondSweepNrPoints*size(listOfMethodsString,1)),f);
        end
    end
end
delete(f) %The status bar is deleted

if anyExitFlagIsNull == 1;
    warndlg('Some simulation point failed','Error in What If Analysis','modal') 
end

set(handles.metric_popupmenu,'Enable','on');
set(handles.text23,'Enable','on');


%We show the simulation text report in the edit
previousText=get(handles.edit6,'String');
if secondSweepNrPoints > 1,
    secondSweepInfoString = vertcat({[' - Second Sweep Parameter: ',nameOfSecondSweepParameter, ' : ']},... 
                                    {['   ', num2str(secondSweepPrct*100)]});
else
    secondSweepInfoString = [''];
end
currentClock=clock;	

whatIfSimulationTextReport = vertcat(...
          {['##### WHAT IF ANALYSIS REPORT #####']},...
          {['']},...
          {['##################################################']},...
        {['Simulation date: ',num2str(ceil(currentClock(3))),'/',num2str(ceil(currentClock(2))),'/',num2str(ceil(currentClock(1))),' - ',num2str(ceil(currentClock(4))),':',num2str(ceil(currentClock(5)))]},...
        {['##################################################']},...
        {[' ']},...
        {[' ']}, ...
        {['INPUT DATA OF THE WHAT IF ANALYSIS:']},...
        {[' ']},...
        {[' - Physical Topology File: ',topologyFilename]},...
        {[' - Traffic File: ',trafficFilename]},...
        {[' - Number Of Simulations: ',num2str(firstSweepNrPoints*secondSweepNrPoints*size(listOfMethodsString,1))]},...
        {[' - Planning Algorithm(s): ']},...
        listOfMethodsString,...
        {[' - First Sweep Parameter: ',nameOfFirstSweepParameter, ' : ']},...
        {['   ', num2str(firstSweepPrct*100)]},...
        secondSweepInfoString,...
        {[' ']},...
        {[' ']}, ...
        {['##################################################']}...
        );

whatIfSimulationTextReport = regexprep(whatIfSimulationTextReport, '%', 'prct' );
whatIfSimulationTextReport=vertcat(previousText, {[' ']}, whatIfSimulationTextReport);
set(handles.edit6,'String', whatIfSimulationTextReport);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%pushbutton2 - RESET BUTTON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = pushbutton2_Callback(h, eventdata, handles, varargin)

delete(statusbar);
clear all;
close all;
WhatIfAnalysis;

% --------------------------------------------------------------------
% --------------------------------------------------------------------
% RESULTS REPORT
% --------------------------------------------------------------------
% --------------------------------------------------------------------

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SaveResults_pushbutton - Pushbutton to save the results report from the
%results edit into a .results file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = SaveResults_pushbutton_Callback(h, eventdata, handles, varargin)

%We open the file to save our 'Results File (*.results)'
[filename, pathname] = uiputfile({'*.results','Results File (*.results)'},'Save Results File as','data\results\');
fullpathname=[pathname filename];
fid = fopen(fullpathname, 'w');

designResults=get(handles.edit6,'String');

designResultsString=[];
for k=1:length(designResults),
    designResultsString= [designResultsString '\n' cell2mat(designResults(k))]; 
end

fprintf(fid, designResultsString);
fclose(fid);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%ResetResults_pushbutton - Pushbutton to reser the results edit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = ResetResults_pushbutton_Callback(h, eventdata, handles, varargin)

set(handles.edit6,'String','');


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%pushbuttonSaveXML - 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = pushbuttonSaveXML_Callback(h, eventdata, handles, varargin)

metadataWhatIfFigure=openfig('metadataWhatIfFigure.fig','reuse');
dataMetadataWhatIfFigure=guihandles(metadataWhatIfFigure);
guidata(metadataWhatIfFigure,dataMetadataWhatIfFigure);






Contact us