Home > src > expAnneal_Dialog.m

# expAnneal_Dialog

## PURPOSE

- create expAnneal dialog

## SYNOPSIS

function varargout = expAnneal_Dialog(varargin)

## DESCRIPTION

     - create expAnneal dialog

     copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut

        This file is part of SOS

        SOS is free software: you can redistribute it and/or modify
        it for academic and non-commercial purposes
        under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.  For commercial or for-profit
        uses, please contact the authors (sos@cnbc.cmu.edu).

        SOS is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

## CROSS-REFERENCE INFORMATION

This function calls:

- getdfName - extracts a dataframe name selected in the GUI
- sos_gui - sos main GUI
- validatePositiveInteger - helper function to validate that a string represents a positive integer
- validateProbability - helper function to validate that a string represents a probability
- validateRealNumber - helper function to validate that a string represents a real number
- verbosePrint - master print function that regulates cmd line output based on verbosity flags

This function is called by:

- sos_gui - sos main GUI

## SUBFUNCTIONS

- function expAnneal_Dialog_OpeningFcn(hObject, eventdata, handles, varargin)
- function varargout = expAnneal_Dialog_OutputFcn(hObject, eventdata, handles)
- function pushbutton_createExpAnneal_Callback(hObject, eventdata, handles)
- function edit_pval_Callback(hObject, eventdata, handles)
- function flag = validate_pval(handles)
- function edit_pval_CreateFcn(hObject, eventdata, handles)
- function edit_pDecrease_Callback(hObject, eventdata, handles)
- function flag = validate_pDecrease(handles)
- function edit_pDecrease_CreateFcn(hObject, eventdata, handles)
- function edit_blockSize_Callback(hObject, eventdata, handles)
- function flag = validate_blockSize(handles)
- function edit_blockSize_CreateFcn(hObject, eventdata, handles)
- function edit_overrideInitDeltaCost_Callback(hObject, eventdata, handles)
- function flag = validate_overrideInitDeltaCost(handles)
- function edit_overrideInitDeltaCost_CreateFcn(hObject, eventdata, handles)

## SOURCE CODE

    0001 % - create expAnneal dialog
    0002 %
    0003 % copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut
    0004 %
    0005 %    This file is part of SOS
    0006 %
    0007 %    SOS is free software: you can redistribute it and/or modify
    0008 %    it for academic and non-commercial purposes
    0009 %    under the terms of the GNU General Public License as published by
    0010 %    the Free Software Foundation, either version 3 of the License, or
    0011 %    (at your option) any later version.  For commercial or for-profit
    0012 %    uses, please contact the authors (sos@cnbc.cmu.edu).
    0013 %
    0014 %    SOS is distributed in the hope that it will be useful,
    0015 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
    0016 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0017 %    GNU General Public License for more details.
    0018
    0019 %    You should have received a copy of the GNU General Public License
    0020 %    along with SOS (see COPYING.txt).
    0021 %    If not, see <http://www.gnu.org/licenses/>.
    0022
    0023
    0024 function varargout = expAnneal_Dialog(varargin)
    0025 % EXPANNEAL_DIALOG M-file for expAnneal_Dialog.fig
    0026 %      EXPANNEAL_DIALOG, by itself, creates a new EXPANNEAL_DIALOG or raises the existing
    0027 %      singleton*.
    0028 %
    0029 %      H = EXPANNEAL_DIALOG returns the handle to a new EXPANNEAL_DIALOG or the handle to
    0030 %      the existing singleton*.
    0031 %
    0032 %      EXPANNEAL_DIALOG('CALLBACK',hObject,eventData,handles,...) calls the local
    0033 %      function named CALLBACK in EXPANNEAL_DIALOG.M with the given input arguments.
    0034 %
    0035 %      EXPANNEAL_DIALOG('Property','Value',...) creates a new EXPANNEAL_DIALOG or raises the
    0036 %      existing singleton*.  Starting from the left, property value pairs are
    0037 %      applied to the GUI before expAnneal_Dialog_OpeningFcn gets called.  An
    0038 %      unrecognized property name or invalid value makes property application
    0039 %      stop.  All inputs are passed to expAnneal_Dialog_OpeningFcn via varargin.
    0040 %
    0041 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
    0042 %      instance to run (singleton)".
    0043 %
    0044 % See also: GUIDE, GUIDATA, GUIHANDLES
    0045
    0046 % Edit the above text to modify the response to help expAnneal_Dialog
    0047
    0048 % Last Modified by GUIDE v2.5 12-Sep-2010 14:28:36
    0049
    0050 % Begin initialization code - DO NOT EDIT
    0051 gui_Singleton = 1;
    0052 gui_State = struct('gui_Name',       mfilename, ...
    0053                    'gui_Singleton',  gui_Singleton, ...
    0054                    'gui_OpeningFcn', @expAnneal_Dialog_OpeningFcn, ...
    0055                    'gui_OutputFcn',  @expAnneal_Dialog_OutputFcn, ...
    0056                    'gui_LayoutFcn',  [] , ...
    0057                    'gui_Callback',   []);
    0058 if nargin && ischar(varargin{1})
    0059     gui_State.gui_Callback = str2func(varargin{1});
    0060 end
    0061
    0062 if nargout
    0063     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    0064 else
    0065     gui_mainfcn(gui_State, varargin{:});
    0066 end
    0067 % End initialization code - DO NOT EDIT
    0068
    0069
    0070 % --- Executes just before expAnneal_Dialog is made visible.
    0071 function expAnneal_Dialog_OpeningFcn(hObject, eventdata, handles, varargin)
    0072 % This function has no output args, see OutputFcn.
    0073 % hObject    handle to figure
    0074 % eventdata  reserved - to be defined in a future version of MATLAB
    0075 % handles    structure with handles and user data (see GUIDATA)
    0076 % varargin   command line arguments to expAnneal_Dialog (see VARARGIN)
    0077
    0078 % Choose default command line output for expAnneal_Dialog
    0079 handles.output = hObject;
    0080
    0081 % Update handles structure
    0082 guidata(hObject, handles);
    0083
    0084 % UIWAIT makes expAnneal_Dialog wait for user response (see UIRESUME)
    0085 % uiwait(handles.figure_expAnneal_Dialog);
    0086
    0087
    0088 % --- Outputs from this function are returned to the command line.
    0089 function varargout = expAnneal_Dialog_OutputFcn(hObject, eventdata, handles)
    0090 % varargout  cell array for returning output args (see VARARGOUT);
    0091 % hObject    handle to figure
    0092 % eventdata  reserved - to be defined in a future version of MATLAB
    0093 % handles    structure with handles and user data (see GUIDATA)
    0094
    0095 % Get default command line output from handles structure
    0096 varargout{1} = handles.output;
    0097
    0098
    0099 % --- Executes on button press in pushbutton_createExpAnneal.
    0100 function pushbutton_createExpAnneal_Callback(hObject, eventdata, handles)
    0101 % hObject    handle to pushbutton_createExpAnneal (see GCBO)
    0102 % eventdata  reserved - to be defined in a future version of MATLAB
    0103 % handles    structure with handles and user data (see GUIDATA)
    0104
    0105     createObj = true;
    0106
    0107     createObj = validate_blockSize(handles);
    0108
    0109     if createObj == true
    0110         createObj = validate_pDecrease(handles);
    0111
    0112         if createObj == true
    0113             createObj = validate_pval(handles);
    0114
    0115             if createObj == true
    0116
    0117                 mainWindowHandle = sos_gui;
    0118                 mainWindowData = guidata(mainWindowHandle);
    0119
    0120                 sosObjName = getdfName(mainWindowData.popupmenu_SOSSelector,'SOS');
    0121
    0122                 if isempty(sosObjName) == 0
    0123
    0124                     blockSize = (get(handles.edit_blockSize,'String'));
    0125                     pDecrease = (get(handles.edit_pDecrease,'String'));
    0126                     pval = (get(handles.edit_pval,'String'));
    0127
    0128                     overrideInitDeltaCost = (get(handles.edit_overrideInitDeltaCost,'String'));
    0129
    0130                     % use different commands if overrideInitDeltaCost is
    0131                     % present
    0132                     if isempty(overrideInitDeltaCost)
    0133
    0134                     % write the file
    0135                          command = [sosObjName,'.setAnnealSchedule(''schedule'',''exp'',',...
    0136                              '''blockSize'',',blockSize,','...
    0137                              '''pDecrease'',',pDecrease,','...
    0138                              '''pval'',',pval,');'];
    0139
    0140                          verbosePrint(['Executing command: ','''',command,''''],'expAnneal_Dialog_createExpAnneal');
    0141                         evalin('base',command);
    0142                         close(handles.figure_expAnneal_Dialog);
    0143                     elseif validate_overrideInitDeltaCost(handles)
    0144                          command = [sosObjName,'.setAnnealSchedule(''schedule'',''exp'',',...
    0145                              '''blockSize'',',blockSize,','...
    0146                              '''pDecrease'',',pDecrease,','...
    0147                              '''pval'',',pval,','...
    0148                              '''overrideInitDeltaCost'',',overrideInitDeltaCost,');'];
    0149
    0150
    0151                         verbosePrint(['Executing command: ','''',command,''''],'expAnneal_Dialog_createExpAnneal');
    0152                         evalin('base',command);
    0153                         close(handles.figure_expAnneal_Dialog);
    0154
    0155                     end
    0156
    0157
    0158                 else
    0159                     % no need to use this, all methods generate errors
    0160                 end
    0161             end
    0162         end
    0163     end
    0164
    0165
    0166
    0167 function edit_pval_Callback(hObject, eventdata, handles)
    0168 % hObject    handle to edit_pval (see GCBO)
    0169 % eventdata  reserved - to be defined in a future version of MATLAB
    0170 % handles    structure with handles and user data (see GUIDATA)
    0171
    0172 % Hints: get(hObject,'String') returns contents of edit_pval as text
    0173 %        str2double(get(hObject,'String')) returns contents of edit_pval as a double
    0174     validate_pval(handles);
    0175
    0176
    0177 function flag = validate_pval(handles)
    0178     str = get(handles.edit_pval,'String');
    0179
    0180     errmsg = 'alpha must be a probability value between 0 and 1';
    0181     errtitle = 'Invalid alpha!';
    0182
    0183     flag = validateProbability(str,errmsg,errtitle);
    0184
    0185
    0186 % --- Executes during object creation, after setting all properties.
    0187 function edit_pval_CreateFcn(hObject, eventdata, handles)
    0188 % hObject    handle to edit_pval (see GCBO)
    0189 % eventdata  reserved - to be defined in a future version of MATLAB
    0190 % handles    empty - handles not created until after all CreateFcns called
    0191
    0192 % Hint: edit controls usually have a white background on Windows.
    0193 %       See ISPC and COMPUTER.
    0194 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0195     set(hObject,'BackgroundColor','white');
    0196 end
    0197
    0198
    0199
    0200 function edit_pDecrease_Callback(hObject, eventdata, handles)
    0201 % hObject    handle to edit_pDecrease (see GCBO)
    0202 % eventdata  reserved - to be defined in a future version of MATLAB
    0203 % handles    structure with handles and user data (see GUIDATA)
    0204
    0205 % Hints: get(hObject,'String') returns contents of edit_pDecrease as text
    0206 %        str2double(get(hObject,'String')) returns contents of edit_pDecrease as a double
    0207     validate_pDecrease(handles);
    0208
    0209
    0210 function flag = validate_pDecrease(handles)
    0211     str = get(handles.edit_pDecrease,'String');
    0212
    0213     errmsg = 'pDecrease must be a probability value between 0 and 1';
    0214     errtitle = 'Invalid pDecrease!';
    0215
    0216     flag = validateProbability(str,errmsg,errtitle);
    0217
    0218
    0219 % --- Executes during object creation, after setting all properties.
    0220 function edit_pDecrease_CreateFcn(hObject, eventdata, handles)
    0221 % hObject    handle to edit_pDecrease (see GCBO)
    0222 % eventdata  reserved - to be defined in a future version of MATLAB
    0223 % handles    empty - handles not created until after all CreateFcns called
    0224
    0225 % Hint: edit controls usually have a white background on Windows.
    0226 %       See ISPC and COMPUTER.
    0227 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0228     set(hObject,'BackgroundColor','white');
    0229 end
    0230
    0231
    0232
    0233 function edit_blockSize_Callback(hObject, eventdata, handles)
    0234 % hObject    handle to edit_blockSize (see GCBO)
    0235 % eventdata  reserved - to be defined in a future version of MATLAB
    0236 % handles    structure with handles and user data (see GUIDATA)
    0237
    0238 % Hints: get(hObject,'String') returns contents of edit_blockSize as text
    0239 %        str2double(get(hObject,'String')) returns contents of edit_blockSize as a double
    0240     validate_blockSize(handles);
    0241
    0242
    0243 function flag = validate_blockSize(handles)
    0244     str = get(handles.edit_blockSize,'String');
    0245
    0246     errmsg = 'Block size must be a whole number > 0';
    0247     errtitle = 'Invalid block size!';
    0248
    0249     flag = validatePositiveInteger(str,errmsg,errtitle);
    0250
    0251 % --- Executes during object creation, after setting all properties.
    0252 function edit_blockSize_CreateFcn(hObject, eventdata, handles)
    0253 % hObject    handle to edit_blockSize (see GCBO)
    0254 % eventdata  reserved - to be defined in a future version of MATLAB
    0255 % handles    empty - handles not created until after all CreateFcns called
    0256
    0257 % Hint: edit controls usually have a white background on Windows.
    0258 %       See ISPC and COMPUTER.
    0259 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0260     set(hObject,'BackgroundColor','white');
    0261 end
    0262
    0263
    0264
    0265 function edit_overrideInitDeltaCost_Callback(hObject, eventdata, handles)
    0266 % hObject    handle to edit_overrideInitDeltaCost (see GCBO)
    0267 % eventdata  reserved - to be defined in a future version of MATLAB
    0268 % handles    structure with handles and user data (see GUIDATA)
    0269
    0270 % Hints: get(hObject,'String') returns contents of edit_overrideInitDeltaCost as text
    0271 %        str2double(get(hObject,'String')) returns contents of edit_overrideInitDeltaCost as a double
    0272     validate_overrideInitDeltaCost(handles);
    0273
    0274
    0275 function flag = validate_overrideInitDeltaCost(handles)
    0276      str = get(handles.edit_overrideInitDeltaCost,'String');
    0277
    0278     errmsg = 'initDeltaCost must be a number';
    0279     errtitle = 'Invalid overrideInitDeltaCost!';
    0280
    0281     flag = validateRealNumber(str,errmsg,errtitle);
    0282
    0283
    0284 % --- Executes during object creation, after setting all properties.
    0285 function edit_overrideInitDeltaCost_CreateFcn(hObject, eventdata, handles)
    0286 % hObject    handle to edit_overrideInitDeltaCost (see GCBO)
    0287 % eventdata  reserved - to be defined in a future version of MATLAB
    0288 % handles    empty - handles not created until after all CreateFcns called
    0289
    0290 % Hint: edit controls usually have a white background on Windows.
    0291 %       See ISPC and COMPUTER.
    0292 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0293     set(hObject,'BackgroundColor','white');
    0294 end