function varargout = mainGui(varargin)
% MAINGUI M-file for mainGui.fig
% MAINGUI, by itself, creates a new MAINGUI or raises the existing
% singleton*.
%
% H = MAINGUI returns the handle to a new MAINGUI or the handle to
% the existing singleton*.
%
% MAINGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAINGUI.M with the given input arguments.
%
% MAINGUI('Property','Value',...) creates a new MAINGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before mainGui_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to mainGui_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 mainGui
% Last Modified by GUIDE v2.5 20-Nov-2006 13:49:20
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mainGui_OpeningFcn, ...
'gui_OutputFcn', @mainGui_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 mainGui is made visible.
function mainGui_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 mainGui (see VARARGIN)
% Choose default command line output for mainGui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
updateCharts(handles)
% UIWAIT makes mainGui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = mainGui_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 editNumWorkers_Callback(hObject, eventdata, handles)
% hObject handle to editNumWorkers (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 editNumWorkers as text
% str2double(get(hObject,'String')) returns contents of editNumWorkers as a double
% --- Executes during object creation, after setting all properties.
function editNumWorkers_CreateFcn(hObject, eventdata, handles)
% hObject handle to editNumWorkers (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 editRight_Callback(hObject, eventdata, handles)
% hObject handle to editRight (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 editRight as text
% str2double(get(hObject,'String')) returns contents of editRight as a double
% --- Executes during object creation, after setting all properties.
function editRight_CreateFcn(hObject, eventdata, handles)
% hObject handle to editRight (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 editLeft_Callback(hObject, eventdata, handles)
% hObject handle to editLeft (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 editLeft as text
% str2double(get(hObject,'String')) returns contents of editLeft as a double
% --- Executes during object creation, after setting all properties.
function editLeft_CreateFcn(hObject, eventdata, handles)
% hObject handle to editLeft (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 editNumTasks_Callback(hObject, eventdata, handles)
% hObject handle to editNumTasks (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 editNumTasks as text
% str2double(get(hObject,'String')) returns contents of editNumTasks as a double
% --- Executes during object creation, after setting all properties.
function editNumTasks_CreateFcn(hObject, eventdata, handles)
% hObject handle to editNumTasks (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 updateCharts(handles)
taskLength = defineDistribution(handles);
efficiency = 0.90 + randn(size(taskLength)) * 0.08;
efficiency = min(efficiency, 1.00);
efficiency = max(efficiency, 0.01);
histDistribution = hist(handles.axesHist, taskLength);
if numel(find(histDistribution)) == 1
axes(handles.axesHist)
bar(taskLength(1) + [-1 0 1], [0 numel(taskLength) 0])
xlabel('Task time')
ylabel('Number of tasks')
else
hist(handles.axesHist, taskLength)
axes(handles.axesHist)
xlabel('Task time')
ylabel('Number of tasks')
end
workersToSimulate = [2 4 8 16 32 64 128];
for i = 1 : numel(workersToSimulate)
fakeJob(i) = jobEstimate(taskLength, efficiency, workersToSimulate(i));
timeToFinish(i) = fakeJob(i).DeltaTime;
end
axes(handles.axesTime)
plot(workersToSimulate, timeToFinish, 'r-', 'linewidth', 5);
title('Click data point for detailed job simulation')
xlabel('Number of Workers')
ylabel('Time to solution')
grid on
for i = 1 : numel(workersToSimulate)
h = line(workersToSimulate(i), timeToFinish(i), ...
'markerSize' , 15 , ...
'marker' , 'o' , ...
'markerFaceColor', 'k' , ...
'markeredgecolor', 'k' , ...
'buttonDownFcn' , {@tryIt, fakeJob(i)});
end
function tryIt(obj, eventdata, in)
plotTasks(in)
function taskLengths = defineDistribution(handles)
distribType = getDistribType(handles);
numTasks = str2double(get(handles.editNumTasks, 'string'));
switch distribType
case 1 %constant
constantVal = str2double(get(handles.editConstTime, 'string'));
taskLengths = ones(1,numTasks) * constantVal;
case 2 %uniform distribution
minVal = str2double(get(handles.editUnifMin , 'string'));
maxVal = str2double(get(handles.editUnifMax, 'string'));
sweep = maxVal - minVal;
taskLengths = rand(1,numTasks);
taskLengths = taskLengths * sweep;
taskLengths = taskLengths + minVal;
case 3 %normal distribution
meanVal = str2double(get(handles.editNormMean , 'string'));
stdVal = str2double(get(handles.editNormSig, 'string'));
taskLengths = randn(1,numTasks);
taskLengths = taskLengths * sqrt(stdVal);
taskLengths = taskLengths + meanVal;
taskLengths = max(taskLengths, 1); %must have at least 1 second job
end
function distribType = getDistribType(handles);
if get(handles.rbConstant, 'value')
distribType = 1;
elseif get(handles.rbUniform, 'value')
distribType = 2;
elseif get(handles.rbNormal, 'value')
distribType = 3;
else
error ('This can not happen')
end
% --- Executes on button press in pbUpdate.
function pbUpdate_Callback(hObject, eventdata, handles)
% hObject handle to pbUpdate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
updateCharts(handles)
% --- Executes on button press in rbConstant.
function rbConstant_Callback(hObject, eventdata, handles)
% hObject handle to rbConstant (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of rbConstant
set(handles.editConstTime, 'enable', 'on' );
set(handles.editUnifMin, 'enable', 'off');
set(handles.editUnifMax, 'enable', 'off');
set(handles.editNormMean, 'enable', 'off');
set(handles.editNormSig, 'enable', 'off');
set(hObject, 'value', 1);
updateCharts(handles)
% --- Executes on button press in rbUniform.
function rbUniform_Callback(hObject, eventdata, handles)
% hObject handle to rbUniform (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of rbUniform
set(handles.editConstTime, 'enable', 'off' );
set(handles.editUnifMin, 'enable', 'on');
set(handles.editUnifMax, 'enable', 'on');
set(handles.editNormMean, 'enable', 'off');
set(handles.editNormSig, 'enable', 'off');
set(hObject, 'value', 1);
updateCharts(handles)
% --- Executes on button press in rbNormal.
function rbNormal_Callback(hObject, eventdata, handles)
% hObject handle to rbNormal (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of rbNormal
set(handles.editConstTime, 'enable', 'off' );
set(handles.editUnifMin, 'enable', 'off');
set(handles.editUnifMax, 'enable', 'off');
set(handles.editNormMean, 'enable', 'on');
set(handles.editNormSig, 'enable', 'on');
set(hObject, 'value', 1);
updateCharts(handles)
function editConstTime_Callback(hObject, eventdata, handles)
% hObject handle to editConstTime (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 editConstTime as text
% str2double(get(hObject,'String')) returns contents of editConstTime as a double
updateCharts(handles)
% --- Executes during object creation, after setting all properties.
function editConstTime_CreateFcn(hObject, eventdata, handles)
% hObject handle to editConstTime (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 editUnifMax_Callback(hObject, eventdata, handles)
% hObject handle to editUnifMax (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 editUnifMax as text
% str2double(get(hObject,'String')) returns contents of editUnifMax as a double
updateCharts(handles)
% --- Executes during object creation, after setting all properties.
function editUnifMax_CreateFcn(hObject, eventdata, handles)
% hObject handle to editUnifMax (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 editNormSig_Callback(hObject, eventdata, handles)
% hObject handle to editNormSig (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 editNormSig as text
% str2double(get(hObject,'String')) returns contents of editNormSig as a double
updateCharts(handles)
% --- Executes during object creation, after setting all properties.
function editNormSig_CreateFcn(hObject, eventdata, handles)
% hObject handle to editNormSig (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 editUnifMin_Callback(hObject, eventdata, handles)
% hObject handle to editUnifMin (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 editUnifMin as text
% str2double(get(hObject,'String')) returns contents of editUnifMin as a double
updateCharts(handles)
% --- Executes during object creation, after setting all properties.
function editUnifMin_CreateFcn(hObject, eventdata, handles)
% hObject handle to editUnifMin (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 editNormMean_Callback(hObject, eventdata, handles)
% hObject handle to editNormMean (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 editNormMean as text
% str2double(get(hObject,'String')) returns contents of editNormMean as a double
updateCharts(handles)
% --- Executes during object creation, after setting all properties.
function editNormMean_CreateFcn(hObject, eventdata, handles)
% hObject handle to editNormMean (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
% Copyright 2007 - 2009 The MathWorks, Inc.