Changeset fec5842 in sasview for src/sas/qtgui
- Timestamp:
- Mar 28, 2019 2:01:39 PM (6 years ago)
- Branches:
- ESS_GUI_bumps_abstraction
- Children:
- ccfe03b
- Parents:
- 22b4962
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingOptions.py
r22b4962 rfec5842 201 201 # disable the context help icon 202 202 self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) 203 203 self.setWindowTitle("Fit Algorithms") 204 204 # no reason to have this widget resizable 205 self.setFixedSize(self.minimumSizeHint()) 206 self.setWindowTitle("Fit Algorithms") 205 self.layout().setSizeConstraint(QtWidgets.QLayout.SetFixedSize) 207 206 208 207 # Fill up the algorithm combo, based on what BUMPS says is available … … 221 220 self.buttonBox.button(QtWidgets.QDialogButtonBox.Help).clicked.connect(self.onHelp) 222 221 222 # Assign appropriate validators 223 self.assignValidators() 224 225 # OK has to be initialized to True, after initial validator setup 226 self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 227 223 228 # Handle the combo box changes 224 229 self.cbAlgorithm.currentIndexChanged.connect(self.onAlgorithmChange) 225 230 226 # Set the default index 231 # Set the default index and trigger filling the layout 227 232 default_index = self.cbAlgorithm.findText(self.fittingMethods.default.longName) 228 233 self.cbAlgorithm.setCurrentIndex(default_index) 229 # previous algorithm choice230 self.previous_index = default_index231 232 # Assign appropriate validators233 self.assignValidators()234 235 # Set defaults236 self.current_fitter_id = self.fittingMethods.default.shortName237 238 # OK has to be initialized to True, after initial validator setup239 self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True)240 234 241 235 def assignValidators(self): … … 277 271 for i in reversed(list(range(layout.count()))): 278 272 # reversed removal avoids renumbering possibly 279 item = layout.itemAt(i)280 try:281 if item.widget().objectName() == "cbAlgorithm":282 continue283 except AttributeError:284 pass285 273 item = layout.takeAt(i) 286 274 try: # spaceritem does not have a widget 275 if item.widget().objectName() == "cbAlgorithm": 276 continue # do not delete the checkbox, will be added later again 287 277 item.widget().setParent(None) 288 278 item.widget().deleteLater() … … 294 284 lbl = QtWidgets.QLabel(name + ":") 295 285 lbl.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) 286 lbl.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, 287 QtWidgets.QSizePolicy.Fixed)) 296 288 lbl.setWordWrap(True) 297 289 return lbl … … 313 305 fm = self.fittingMethods[self.currentOptimizer] 314 306 layout = self.groupBox.layout() 315 # label for the name of the optimizer, span the whole row 316 layout.addWidget(self._makeLabel(fm.longName), layout.rowCount()+1, 0, 1, -1) 307 layout.addWidget(self.cbAlgorithm, 0, 0, 1, -1) 317 308 for param in fm.params.values(): 318 row , column = layout.rowCount()+1, layout.columnCount()309 row = layout.rowCount()+1 319 310 layout.addWidget(self._makeLabel(param.longName), row, 0) 320 311 widget = self._inputWidgetFromType(param.type, self) … … 336 327 self._fillLayout() 337 328 338 if selectedName in self.fittingMethods.longNames:339 self.current_fitter_id = self.fittingMethods[selectedName].shortName340 341 # find the right stacked widget342 widget_name = "self.page_"+str(self.current_fitter_id)343 344 # Convert the name into widget instance345 try:346 widget_to_activate = eval(widget_name)347 except AttributeError:348 # We don't yet have this optimizer.349 # Show message350 msg = "This algorithm has not yet been implemented in SasView.\n"351 msg += "Please choose a different algorithm"352 QtWidgets.QMessageBox.warning(self,353 'Warning',354 msg,355 QtWidgets.QMessageBox.Ok)356 # Move the index to previous position357 self.cbAlgorithm.setCurrentIndex(self.previous_index)358 return359 360 329 # Select the requested widget 361 330 self.updateWidgetFromConfig() … … 364 333 # OK has to be reinitialized to True 365 334 self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 366 367 # keep reference368 self.previous_index = index369 335 370 336 def paramWidget(self, fittingMethod, paramShortName): … … 422 388 # Note that we can be clusmy here, since bad current_fitter_id 423 389 # will just make the page displayed from the top 424 helpfile = "optimizer.html#fit-" + self.current_fitter_id 390 current_fitter_id = self.fittingMethods[self.currentOptimizer].shortName 391 helpfile = "optimizer.html#fit-" + current_fitter_id 425 392 help_location = tree_location + helpfile 426 393 webbrowser.open('file://' + os.path.realpath(help_location)) -
src/sas/qtgui/Perspectives/Fitting/UI/FittingOptionsUI.ui
rff3b293 rfec5842 38 38 </widget> 39 39 </item> 40 <item row="1" column="0">41 <widget class="QStackedWidget" name="stackedWidget">42 <property name="frameShape">43 <enum>QFrame::NoFrame</enum>44 </property>45 <property name="currentIndex">46 <number>0</number>47 </property>48 <widget class="QWidget" name="page_dream">49 <layout class="QGridLayout" name="gridLayout_2">50 <item row="0" column="0">51 <widget class="QGroupBox" name="groupBox_2">52 <property name="sizePolicy">53 <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">54 <horstretch>0</horstretch>55 <verstretch>0</verstretch>56 </sizepolicy>57 </property>58 <property name="title">59 <string>DREAM</string>60 </property>61 <layout class="QGridLayout" name="gridLayout">62 <item row="0" column="0">63 <widget class="QLabel" name="label">64 <property name="text">65 <string>Samples:</string>66 </property>67 </widget>68 </item>69 <item row="0" column="1">70 <widget class="QLineEdit" name="samples_dream">71 <property name="toolTip">72 <string><html><head/><body><p>Number of points to be drawn from the Markov chain.</p></body></html></string>73 </property>74 </widget>75 </item>76 <item row="1" column="0">77 <widget class="QLabel" name="label_2">78 <property name="text">79 <string>Burn-in Steps:</string>80 </property>81 </widget>82 </item>83 <item row="1" column="1">84 <widget class="QLineEdit" name="burn_dream">85 <property name="toolTip">86 <string><html><head/><body><p>The number of iterations to required for the Markov chain to converge to the equilibrium distribution.</p></body></html></string>87 </property>88 </widget>89 </item>90 <item row="2" column="0">91 <widget class="QLabel" name="label_3">92 <property name="text">93 <string>Population:</string>94 </property>95 </widget>96 </item>97 <item row="2" column="1">98 <widget class="QLineEdit" name="pop_dream">99 <property name="toolTip">100 <string><html><head/><body><p>The size of the population.</p></body></html></string>101 </property>102 </widget>103 </item>104 <item row="3" column="0">105 <widget class="QLabel" name="label_4">106 <property name="text">107 <string>Initializer:</string>108 </property>109 </widget>110 </item>111 <item row="3" column="1">112 <widget class="QComboBox" name="init_dream">113 <property name="toolTip">114 <string><html><head/><body><p><span style=" font-style:italic;">Initializer</span> determines how the population will be initialized. The options are as follows:</p><p><span style=" font-style:italic;">eps</span> (epsilon ball), in which the entire initial population is chosen at random from within a tiny hypersphere centered about the initial point</p><p><span style=" font-style:italic;">lhs</span> (latin hypersquare), which chops the bounds within each dimension in <span style=" font-weight:600;">k</span> equal sized chunks where <span style=" font-weight:600;">k</span> is the size of the population and makes sure that each parameter has at least one value within each chunk across the population.</p><p><span style=" font-style:italic;">cov</span> (covariance matrix), in which the uncertainty is estimated using the covariance matrix at the initial point, and points are selected at random from the corresponding gaussian ellipsoid</p><p><span style=" font-style:italic;">random</span> (uniform random), in which the points are selected at random within the bounds of the parameters</p></body></html></string>115 </property>116 <item>117 <property name="text">118 <string>eps</string>119 </property>120 </item>121 <item>122 <property name="text">123 <string>lhs</string>124 </property>125 </item>126 <item>127 <property name="text">128 <string>cov</string>129 </property>130 </item>131 <item>132 <property name="text">133 <string>random</string>134 </property>135 </item>136 </widget>137 </item>138 <item row="4" column="0">139 <widget class="QLabel" name="label_5">140 <property name="text">141 <string>Thinning:</string>142 </property>143 </widget>144 </item>145 <item row="4" column="1">146 <widget class="QLineEdit" name="thin_dream">147 <property name="toolTip">148 <string><html><head/><body><p>The amount of thinning to use when collecting the population.</p></body></html></string>149 </property>150 </widget>151 </item>152 <item row="5" column="0">153 <widget class="QLabel" name="label_6">154 <property name="text">155 <string>Steps:</string>156 </property>157 </widget>158 </item>159 <item row="5" column="1">160 <widget class="QLineEdit" name="steps_dream">161 <property name="toolTip">162 <string><html><head/><body><p>Determines the number of iterations to use for drawing samples after burn in.</p></body></html></string>163 </property>164 </widget>165 </item>166 </layout>167 </widget>168 </item>169 <item row="1" column="0">170 <spacer name="verticalSpacer_5">171 <property name="orientation">172 <enum>Qt::Vertical</enum>173 </property>174 <property name="sizeHint" stdset="0">175 <size>176 <width>20</width>177 <height>268</height>178 </size>179 </property>180 </spacer>181 </item>182 </layout>183 </widget>184 <widget class="QWidget" name="page_lm">185 <layout class="QGridLayout" name="gridLayout_4">186 <item row="0" column="0">187 <widget class="QGroupBox" name="groupBox_3">188 <property name="title">189 <string>Levenberg</string>190 </property>191 <layout class="QGridLayout" name="gridLayout_3">192 <item row="0" column="0">193 <widget class="QLabel" name="label_7">194 <property name="text">195 <string>Steps:</string>196 </property>197 </widget>198 </item>199 <item row="0" column="1">200 <widget class="QLineEdit" name="steps_lm">201 <property name="toolTip">202 <string><html><head/><body><p>The number of gradient steps to take.</p></body></html></string>203 </property>204 </widget>205 </item>206 <item row="1" column="0">207 <widget class="QLabel" name="label_8">208 <property name="text">209 <string>f(x) tolerance:</string>210 </property>211 </widget>212 </item>213 <item row="1" column="1">214 <widget class="QLineEdit" name="ftol_lm">215 <property name="toolTip">216 <string><html><head/><body><p>Used to determine when the fit has reached the point where no significant improvement is expected.</p></body></html></string>217 </property>218 </widget>219 </item>220 <item row="2" column="0">221 <widget class="QLabel" name="label_9">222 <property name="text">223 <string>x tolerance:</string>224 </property>225 </widget>226 </item>227 <item row="2" column="1">228 <widget class="QLineEdit" name="xtol_lm">229 <property name="toolTip">230 <string><html><head/><body><p>Used to determine when the fit has reached the point where no significant improvement is expected.</p></body></html></string>231 </property>232 </widget>233 </item>234 </layout>235 </widget>236 </item>237 <item row="1" column="0">238 <spacer name="verticalSpacer_2">239 <property name="orientation">240 <enum>Qt::Vertical</enum>241 </property>242 <property name="sizeHint" stdset="0">243 <size>244 <width>20</width>245 <height>434</height>246 </size>247 </property>248 </spacer>249 </item>250 </layout>251 </widget>252 <widget class="QWidget" name="page_newton">253 <layout class="QGridLayout" name="gridLayout_7">254 <item row="0" column="0">255 <widget class="QGroupBox" name="groupBox_5">256 <property name="title">257 <string>Quasi-Newton BFGS </string>258 </property>259 <layout class="QGridLayout" name="gridLayout_5">260 <item row="0" column="0">261 <widget class="QLabel" name="label_10">262 <property name="text">263 <string>Steps:</string>264 </property>265 </widget>266 </item>267 <item row="0" column="1">268 <widget class="QLineEdit" name="steps_newton">269 <property name="toolTip">270 <string><html><head/><body><p>The number of gradient steps to take.</p></body></html></string>271 </property>272 </widget>273 </item>274 <item row="1" column="0">275 <widget class="QLabel" name="label_13">276 <property name="text">277 <string>Starts:</string>278 </property>279 </widget>280 </item>281 <item row="1" column="1">282 <widget class="QLineEdit" name="starts_newton">283 <property name="toolTip">284 <string><html><head/><body><p>Value thattells the optimizer to restart a given number of times. Each time it restarts it uses a random starting point.</p></body></html></string>285 </property>286 </widget>287 </item>288 <item row="2" column="0">289 <widget class="QLabel" name="label_11">290 <property name="text">291 <string>f(x) tolerance:</string>292 </property>293 </widget>294 </item>295 <item row="2" column="1">296 <widget class="QLineEdit" name="ftol_newton">297 <property name="toolTip">298 <string><html><head/><body><p>Used to determine when the fit has reached the point where no significant improvement is expected.</p></body></html></string>299 </property>300 </widget>301 </item>302 <item row="3" column="0">303 <widget class="QLabel" name="label_12">304 <property name="text">305 <string>x tolerance:</string>306 </property>307 </widget>308 </item>309 <item row="3" column="1">310 <widget class="QLineEdit" name="xtol_newton">311 <property name="toolTip">312 <string><html><head/><body><p>Used to determine when the fit has reached the point where no significant improvement is expected.</p></body></html></string>313 </property>314 </widget>315 </item>316 </layout>317 </widget>318 </item>319 <item row="1" column="0">320 <spacer name="verticalSpacer">321 <property name="orientation">322 <enum>Qt::Vertical</enum>323 </property>324 <property name="sizeHint" stdset="0">325 <size>326 <width>20</width>327 <height>68</height>328 </size>329 </property>330 </spacer>331 </item>332 </layout>333 </widget>334 <widget class="QWidget" name="page_de">335 <layout class="QGridLayout" name="gridLayout_8">336 <item row="0" column="0">337 <widget class="QGroupBox" name="groupBox_6">338 <property name="title">339 <string>Differential Evolution</string>340 </property>341 <layout class="QGridLayout" name="gridLayout_6">342 <item row="0" column="0">343 <widget class="QLabel" name="label_14">344 <property name="text">345 <string>Steps:</string>346 </property>347 </widget>348 </item>349 <item row="0" column="1">350 <widget class="QLineEdit" name="steps_de">351 <property name="toolTip">352 <string><html><head/><body><p>The number of iterations.</p></body></html></string>353 </property>354 </widget>355 </item>356 <item row="1" column="0">357 <widget class="QLabel" name="label_15">358 <property name="text">359 <string>Population:</string>360 </property>361 </widget>362 </item>363 <item row="1" column="1">364 <widget class="QLineEdit" name="pop_de"/>365 </item>366 <item row="2" column="0">367 <widget class="QLabel" name="label_18">368 <property name="text">369 <string>Crossover ratio:</string>370 </property>371 </widget>372 </item>373 <item row="2" column="1">374 <widget class="QLineEdit" name="CR_de">375 <property name="toolTip">376 <string><html><head/><body><p>The size of the population.</p></body></html></string>377 </property>378 </widget>379 </item>380 <item row="3" column="0">381 <widget class="QLabel" name="label_19">382 <property name="text">383 <string>Scale:</string>384 </property>385 </widget>386 </item>387 <item row="3" column="1">388 <widget class="QLineEdit" name="F_de">389 <property name="toolTip">390 <string><html><head/><body><p>Determines how much to scale each difference vector before adding it to the candidate point.</p></body></html></string>391 </property>392 </widget>393 </item>394 <item row="4" column="0">395 <widget class="QLabel" name="label_16">396 <property name="text">397 <string>f(x) tolerance:</string>398 </property>399 </widget>400 </item>401 <item row="4" column="1">402 <widget class="QLineEdit" name="ftol_de">403 <property name="toolTip">404 <string><html><head/><body><p>Used to determine when the fit has reached the point where no significant improvement is expected.</p></body></html></string>405 </property>406 </widget>407 </item>408 <item row="5" column="0">409 <widget class="QLabel" name="label_17">410 <property name="text">411 <string>x tolerance:</string>412 </property>413 </widget>414 </item>415 <item row="5" column="1">416 <widget class="QLineEdit" name="xtol_de">417 <property name="toolTip">418 <string><html><head/><body><p>Used to determine when the fit has reached the point where no significant improvement is expected.</p></body></html></string>419 </property>420 </widget>421 </item>422 </layout>423 </widget>424 </item>425 <item row="1" column="0">426 <spacer name="verticalSpacer_3">427 <property name="orientation">428 <enum>Qt::Vertical</enum>429 </property>430 <property name="sizeHint" stdset="0">431 <size>432 <width>20</width>433 <height>356</height>434 </size>435 </property>436 </spacer>437 </item>438 </layout>439 </widget>440 <widget class="QWidget" name="page_amoeba">441 <layout class="QGridLayout" name="gridLayout_10">442 <item row="0" column="0">443 <widget class="QGroupBox" name="groupBox_7">444 <property name="title">445 <string>Nelder-Mead Simplex</string>446 </property>447 <layout class="QGridLayout" name="gridLayout_11">448 <item row="0" column="0">449 <widget class="QLabel" name="label_20">450 <property name="text">451 <string>Steps:</string>452 </property>453 </widget>454 </item>455 <item row="0" column="1">456 <widget class="QLineEdit" name="steps_amoeba">457 <property name="toolTip">458 <string><html><head/><body><p>The number of simplex update iterations to perform.</p></body></html></string>459 </property>460 </widget>461 </item>462 <item row="1" column="0">463 <widget class="QLabel" name="label_21">464 <property name="text">465 <string>Starts:</string>466 </property>467 </widget>468 </item>469 <item row="1" column="1">470 <widget class="QLineEdit" name="starts_amoeba">471 <property name="toolTip">472 <string><html><head/><body><p>Tells the optimizer to restart a given number of times. Each time it restarts it uses a random starting point.</p></body></html></string>473 </property>474 </widget>475 </item>476 <item row="2" column="0">477 <widget class="QLabel" name="label_22">478 <property name="text">479 <string>Simplex radius:</string>480 </property>481 </widget>482 </item>483 <item row="2" column="1">484 <widget class="QLineEdit" name="radius_amoeba">485 <property name="toolTip">486 <string><html><head/><body><p>The initial size of the simplex, as a portion of the bounds defining the parameter space.</p></body></html></string>487 </property>488 </widget>489 </item>490 <item row="3" column="0">491 <widget class="QLabel" name="label_24">492 <property name="text">493 <string>f(x) tolerance:</string>494 </property>495 </widget>496 </item>497 <item row="3" column="1">498 <widget class="QLineEdit" name="ftol_amoeba">499 <property name="toolTip">500 <string><html><head/><body><p>Used to determine when the fit has reached the point where no significant improvement is expected. </p></body></html></string>501 </property>502 </widget>503 </item>504 <item row="4" column="0">505 <widget class="QLabel" name="label_25">506 <property name="text">507 <string>x tolerance:</string>508 </property>509 </widget>510 </item>511 <item row="4" column="1">512 <widget class="QLineEdit" name="xtol_amoeba">513 <property name="toolTip">514 <string><html><head/><body><p>Used to determine when the fit has reached the point where no significant improvement is expected. </p></body></html></string>515 </property>516 </widget>517 </item>518 </layout>519 </widget>520 </item>521 <item row="1" column="0">522 <spacer name="verticalSpacer_4">523 <property name="orientation">524 <enum>Qt::Vertical</enum>525 </property>526 <property name="sizeHint" stdset="0">527 <size>528 <width>20</width>529 <height>382</height>530 </size>531 </property>532 </spacer>533 </item>534 </layout>535 </widget>536 </widget>537 </item>538 40 </layout> 539 41 </widget>
Note: See TracChangeset
for help on using the changeset viewer.