コード例 #1
0
ファイル: surrogateFrame.py プロジェクト: pn51/FOQUS
 def updateStatus(self):
     """
     This function is called by the timer periodically and
     updates the surrogate generation status.  If finished it
     also stops the timer and resests the start/stop buttons.
     """
     done = False
     if not self.pg.isAlive():
         done = True
     while not self.pg.msgQueue.empty():
         msg = str(self.pg.msgQueue.get(False))
         self.monitorTextBox.append(msg)
     if done:
         self.timer.stop()
         self.pg.join()
         self.runButton.setEnabled(True)
         self.stopButton.setEnabled(False)
         if self.pg.ex:
             etype, evalue, etrace = self.pg.ex
             el = traceback.format_exception(etype, evalue, etrace)
             for line in el:
                 self.monitorTextBox.append(line)
             self.setStatusBar.emit(
                 "Surrogate Failed Elapsed Time: {0}".format(
                     hhmmss(math.floor(time.time() - self.timeRunning))
                 )
             )
         else:
             self.setStatusBar.emit(
                 "Surrogate Finished, Elapsed Time: {0}".format(
                     hhmmss(math.floor(time.time() - self.timeRunning))
                 )
             )
         if self.pg.driverFile != "":
             try:
                 df = os.path.abspath(self.pg.driverFile)
             except:
                 pass
             msgBox = QMessageBox()
             msgBox.setWindowTitle("Driver File Location")
             msgBox.setText(
                 "The surrogate model driver file path is: {0}".format(
                     os.path.abspath(df)
                 )
             )
             msgBox.exec_()
     else:
         self.refreshContents()
         self.setStatusBar.emit(
             "Surrogate Model Generation, Elapsed Time: {0}s".format(
                 math.floor(time.time() - self.timeRunning)
             )
         )
コード例 #2
0
 def updateStatus(self):
     done = False
     if self.opt.updateGraph:
         self.opt.updateGraph = False
         self.updateGraph.emit()
     if not self.opt.isAlive(): done = True
     while not self.opt.msgQueue.empty():
         msg = str(self.opt.msgQueue.get(False))
         self.msgSubwindow.msgTextBrowser.append(msg)
     bestChange = False
     itChange = False
     updateStatusLine = False
     objPoints = [[], []]
     while not self.opt.resQueue.empty():
         msg = self.opt.resQueue.get(False)
         if msg[0] == "BEST":
             self.bestObj = msg[1][0]
             self.bestX = msg[2]
             bestChange = True
         elif msg[0] == "SAMP":
             if self.a:
                 self.samp = np.array(msg[1])
                 self.sampLim = [[0] * len(self.xnames),
                                 [10] * len(self.xnames)]
                 for i in range(len(self.xnames)):
                     self.sampLim[0][i] = np.min(self.samp[:, i])
                     self.sampLim[1][i] = np.max(self.samp[:, i])
                 bestChange = True
         elif msg[0] == "IT":
             self.iteration = msg[1]
             itChange = True
             objPoints[0].append(msg[1])
             objPoints[1].append(msg[2])
         elif msg[0] == "PROG":
             itJobsComplete = msg[1]
             itTotalJobs = msg[2]
             itErrors = msg[3]
             it = msg[4]
             totalRead = msg[5]
             totalErrors = msg[6]
             updateStatusLine = True
     if bestChange:
         self.coorFigLine1[0].set_data(self.coordXCoord, self.bestX)
         self.coorFigLine2[0].set_data(self.coordXCoord, self.sampLim[0])
         self.coorFigLine3[0].set_data(self.coordXCoord, self.sampLim[1])
         self.coordCanvas.draw()
     if itChange:
         self.objFigAx.plot(objPoints[0], objPoints[1], 'bo')
         self.objCanvas.draw()
     if updateStatusLine:
         self.msgSubwindow.statusLine.setText("".join([
             "ITERATION ",
             str(it), ": ",
             str(itJobsComplete), "/",
             str(itTotalJobs), "  Err: ",
             str(itErrors), " TOTAL Complete: ",
             str(totalRead), " Err:",
             str(totalErrors)
         ]))
     if done:
         self.timer.stop()
         self.startButton.setEnabled(True)
         self.stopButton.setEnabled(False)
         self.setStatusBar.emit(
             "Optimization Finished, Elapsed Time: " +
             hhmmss(math.floor(time.time() - self.timeRunning)))
         self.settingsForm.refreshContents()
         self.settingsForm.running = False
     else:
         self.setStatusBar.emit(
             "Optimization Running, Elapsed Time: " +
             hhmmss(math.floor(time.time() - self.timeRunning)))