No BSD License  

Highlights from
MatPlanWDM v0.5

image thumbnail
from MatPlanWDM v0.5 by Pablo Pavon MariƱo
Educational network planning tool for the RWA problem in WDM networks (MILP and heuristic based)

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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help onPopulationDistanceTraffic

% Last Modified by GUIDE v2.5 15-Oct-2007 16:20:20

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @onPopulationDistanceTraffic_OpeningFcn, ...
                   'gui_OutputFcn',  @onPopulationDistanceTraffic_OutputFcn, ...
                   'gui_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 onPopulationDistanceTraffic is made visible.
function onPopulationDistanceTraffic_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 onPopulationDistanceTraffic (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%OpenPhysFile_pushbutton - Pushbutton to open the Phys File
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

load_global_traffGen;

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

[distanceMatrix]=calculateDistanceMatrix(auxPhys.nodesPlaceMatrix);

set(handles.OpenPhysFile_pushbutton,'ForegroundColor',[0 0.5 0]);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%RF_edit - RANDOM FACTOR 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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


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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%popOffset_edit - POPULATION OFFSET
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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


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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%popPower_edit - POPULATION POWER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%distOffset_edit - DISTANCE OFFSET
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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


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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%distPower_edit - DISTANCE POWER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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



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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%trafficMatrix_edit - TRAFFIC MATRIX
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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


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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Apply_pushbutton - Pushbutton to save the Traffic Matrix defined by
%the user
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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


load_global_traffGen;

auxRF=str2num(get(handles.RF_edit,'String'));
if isempty(auxRF), 
    errordlg('The Random Factor must be a non-negative number','Incorrect Value','modal');
    return
elseif (auxRF < 0) | (auxRF > 1),
    errordlg('The Random Factor must be comprised between 0 and 1','Incorrect Value','modal');   
    return
else
    RF=auxRF;
end

auxPopOffset=str2num(get(handles.popOffset_edit,'String'));
if isempty(auxPopOffset) | auxPopOffset < 0, 
    errordlg('The Population Offset must be a non-negative number','Incorrect Value','modal'); 
    return
else
    popOffset=auxPopOffset;
end

auxPopPower=str2num(get(handles.popPower_edit,'String'));
if isempty(auxPopPower) | auxPopPower < 0, 
    errordlg('The Population Power must be a non-negative number','Incorrect Value','modal'); 
    return
else
    popPower=auxPopPower;
end

auxDistOffset=str2num(get(handles.distOffset_edit,'String'));
if isempty(auxDistOffset) | auxDistOffset < 0, 
    errordlg('The Distance Offset must be a non-negative number','Incorrect Value','modal'); 
    return
else
    distOffset=auxDistOffset;
end

auxDistPower=str2num(get(handles.distPower_edit,'String'));
if isempty(auxDistPower) | auxDistPower < 0, 
    errordlg('The Distance Power must be a non-negative number','Incorrect Value','modal');  
    return
else
    distPower=auxDistPower;
end

if isempty(auxPhys.nodePopulation) | isempty(distanceMatrix) | isempty(auxPhys.nodeLevel) | isempty(auxPhys.levelMatrix) | ...
        isempty(RF) | isempty(popOffset) | isempty(popPower) | isempty(distOffset) | isempty(distPower), 
    errordlg('Some parameter is incorrect or empty','Incorrect Values','modal')
    return
end


close;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Cancel_pushbutton - Pushbutton to cancel the Traffic Generation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

close;




Contact us