dialog used to calculate the nubmer of temperature-lowering steps 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.
0001 % dialog used to calculate the nubmer of temperature-lowering steps 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 0025 function varargout = numSteps_Dialog(varargin) 0026 % NUMSTEPS_DIALOG M-file for numSteps_Dialog.fig 0027 % NUMSTEPS_DIALOG, by itself, creates a new NUMSTEPS_DIALOG or raises the existing 0028 % singleton*. 0029 % 0030 % H = NUMSTEPS_DIALOG returns the handle to a new NUMSTEPS_DIALOG or the handle to 0031 % the existing singleton*. 0032 % 0033 % NUMSTEPS_DIALOG('CALLBACK',hObject,eventData,handles,...) calls the local 0034 % function named CALLBACK in NUMSTEPS_DIALOG.M with the given input arguments. 0035 % 0036 % NUMSTEPS_DIALOG('Property','Value',...) creates a new NUMSTEPS_DIALOG or raises the 0037 % existing singleton*. Starting from the left, property value pairs are 0038 % applied to the GUI before numSteps_Dialog_OpeningFcn gets called. An 0039 % unrecognized property name or invalid value makes property application 0040 % stop. All inputs are passed to numSteps_Dialog_OpeningFcn via varargin. 0041 % 0042 % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 0043 % instance to run (singleton)". 0044 % 0045 % See also: GUIDE, GUIDATA, GUIHANDLES 0046 0047 % Edit the above text to modify the response to help numSteps_Dialog 0048 0049 % Last Modified by GUIDE v2.5 12-Sep-2010 13:36:38 0050 0051 % Begin initialization code - DO NOT EDIT 0052 gui_Singleton = 1; 0053 gui_State = struct('gui_Name', mfilename, ... 0054 'gui_Singleton', gui_Singleton, ... 0055 'gui_OpeningFcn', @numSteps_Dialog_OpeningFcn, ... 0056 'gui_OutputFcn', @numSteps_Dialog_OutputFcn, ... 0057 'gui_LayoutFcn', [] , ... 0058 'gui_Callback', []); 0059 if nargin && ischar(varargin{1}) 0060 gui_State.gui_Callback = str2func(varargin{1}); 0061 end 0062 0063 if nargout 0064 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 0065 else 0066 gui_mainfcn(gui_State, varargin{:}); 0067 end 0068 % End initialization code - DO NOT EDIT 0069 0070 0071 % --- Executes just before numSteps_Dialog is made visible. 0072 function numSteps_Dialog_OpeningFcn(hObject, eventdata, handles, varargin) 0073 % This function has no output args, see OutputFcn. 0074 % hObject handle to figure 0075 % eventdata reserved - to be defined in a future version of MATLAB 0076 % handles structure with handles and user data (see GUIDATA) 0077 % varargin command line arguments to numSteps_Dialog (see VARARGIN) 0078 0079 % Choose default command line output for numSteps_Dialog 0080 handles.output = hObject; 0081 0082 % Update handles structure 0083 guidata(hObject, handles); 0084 0085 % UIWAIT makes numSteps_Dialog wait for user response (see UIRESUME) 0086 % uiwait(handles.figure_numSteps_Dialog); 0087 0088 0089 % --- Outputs from this function are returned to the command line. 0090 function varargout = numSteps_Dialog_OutputFcn(hObject, eventdata, handles) 0091 % varargout cell array for returning output args (see VARARGOUT); 0092 % hObject handle to figure 0093 % eventdata reserved - to be defined in a future version of MATLAB 0094 % handles structure with handles and user data (see GUIDATA) 0095 0096 % Get default command line output from handles structure 0097 varargout{1} = handles.output; 0098 0099 0100 0101 function edit_initDeltaCost_Callback(hObject, eventdata, handles) 0102 % hObject handle to edit_initDeltaCost (see GCBO) 0103 % eventdata reserved - to be defined in a future version of MATLAB 0104 % handles structure with handles and user data (see GUIDATA) 0105 0106 % Hints: get(hObject,'String') returns contents of edit_initDeltaCost as text 0107 % str2double(get(hObject,'String')) returns contents of edit_initDeltaCost as a double 0108 0109 % validate initDeltaCost 0110 validate_initDeltaCost(handles); 0111 0112 0113 function flag = validate_initDeltaCost(handles) 0114 str = get(handles.edit_initDeltaCost,'String'); 0115 0116 errmsg = 'initDeltaCost must be a number'; 0117 errtitle = 'Invalid initDeltaCost!'; 0118 0119 flag = validateRealNumber(str,errmsg,errtitle); 0120 0121 0122 0123 % --- Executes during object creation, after setting all properties. 0124 function edit_initDeltaCost_CreateFcn(hObject, eventdata, handles) 0125 % hObject handle to edit_initDeltaCost (see GCBO) 0126 % eventdata reserved - to be defined in a future version of MATLAB 0127 % handles empty - handles not created until after all CreateFcns called 0128 0129 % Hint: edit controls usually have a white background on Windows. 0130 % See ISPC and COMPUTER. 0131 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0132 set(hObject,'BackgroundColor','white'); 0133 end 0134 0135 0136 0137 function edit_finalDeltaCost_Callback(hObject, eventdata, handles) 0138 % hObject handle to edit_finalDeltaCost (see GCBO) 0139 % eventdata reserved - to be defined in a future version of MATLAB 0140 % handles structure with handles and user data (see GUIDATA) 0141 0142 % Hints: get(hObject,'String') returns contents of edit_finalDeltaCost as text 0143 % str2double(get(hObject,'String')) returns contents of edit_finalDeltaCost as a double 0144 validate_finalDeltaCost(handles); 0145 0146 0147 function flag = validate_finalDeltaCost(handles) 0148 str = get(handles.edit_finalDeltaCost,'String'); 0149 0150 errmsg = 'finalDeltaCost must be a number'; 0151 errtitle = 'Invalid initDeltaCost!'; 0152 0153 flag = validateRealNumber(str,errmsg,errtitle); 0154 0155 0156 % --- Executes during object creation, after setting all properties. 0157 function edit_finalDeltaCost_CreateFcn(hObject, eventdata, handles) 0158 % hObject handle to edit_finalDeltaCost (see GCBO) 0159 % eventdata reserved - to be defined in a future version of MATLAB 0160 % handles empty - handles not created until after all CreateFcns called 0161 0162 % Hint: edit controls usually have a white background on Windows. 0163 % See ISPC and COMPUTER. 0164 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0165 set(hObject,'BackgroundColor','white'); 0166 end 0167 0168 0169 0170 function edit_pDecrease_Callback(hObject, eventdata, handles) 0171 % hObject handle to edit_pDecrease (see GCBO) 0172 % eventdata reserved - to be defined in a future version of MATLAB 0173 % handles structure with handles and user data (see GUIDATA) 0174 0175 % Hints: get(hObject,'String') returns contents of edit_pDecrease as text 0176 % str2double(get(hObject,'String')) returns contents of edit_pDecrease as a double 0177 validate_pDecrease(handles); 0178 0179 0180 function flag = validate_pDecrease(handles) 0181 str = get(handles.edit_pDecrease,'String'); 0182 0183 errmsg = 'pDecrease must be a probability value between 0 and 1'; 0184 errtitle = 'Invalid pDecrease!'; 0185 0186 flag = validateProbability(str,errmsg,errtitle); 0187 0188 % --- Executes during object creation, after setting all properties. 0189 function edit_pDecrease_CreateFcn(hObject, eventdata, handles) 0190 % hObject handle to edit_pDecrease (see GCBO) 0191 % eventdata reserved - to be defined in a future version of MATLAB 0192 % handles empty - handles not created until after all CreateFcns called 0193 0194 % Hint: edit controls usually have a white background on Windows. 0195 % See ISPC and COMPUTER. 0196 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0197 set(hObject,'BackgroundColor','white'); 0198 end 0199 0200 0201 % --- Executes on button press in pushbutton_Calculate. 0202 function pushbutton_Calculate_Callback(hObject, eventdata, handles) 0203 % hObject handle to pushbutton_Calculate (see GCBO) 0204 % eventdata reserved - to be defined in a future version of MATLAB 0205 % handles structure with handles and user data (see GUIDATA) 0206 run = true; 0207 0208 run = validate_initDeltaCost(handles); 0209 0210 if run == true 0211 validate_finalDeltaCost(handles); 0212 0213 if run == true 0214 validate_pDecrease(handles); 0215 0216 if run == true 0217 % all data is valid, run the command. 0218 initDeltaCost = (get(handles.edit_initDeltaCost,'String')); 0219 finalDeltaCost = (get(handles.edit_finalDeltaCost,'String')); 0220 pDecrease = (get(handles.edit_pDecrease,'String')); 0221 0222 command = ['expAnneal.numSteps(',initDeltaCost,',',... 0223 finalDeltaCost,',',pDecrease,');']; 0224 0225 verbosePrint(['Executing command: ','''',command,''''],'numSteps_Dialog_calculate'); 0226 evalin('base',command); 0227 0228 close(handles.figure_numSteps_Dialog); 0229 0230 end 0231 end 0232 end