Skip to content

Commit

Permalink
'demo'
Browse files Browse the repository at this point in the history
  • Loading branch information
smasky committed Oct 31, 2024
1 parent 0997b9a commit 0739625
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 107 deletions.
49 changes: 20 additions & 29 deletions GUI/component/op_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ def __init__(self, parent=None):

def reset(self):

Pro.OPInfos=None
Pro.OPResult=None
Pro.paraInfos=None
Pro.problemInfos=None
Pro.objInfos=None

Pro.OP_infos={}
Pro.OP_result={}
Pro.OP_paraInfos={}
Pro.OP_problemInfos={}
Pro.OP_objInfos={}
self.contentWidget.setCurrentIndex(0)
self.setupWidget.reset()
self.opWidget.reset()
Expand All @@ -98,10 +98,10 @@ def nextPage(self):

if widget.objType=="SOP":
op=widget.SOP_METHOD[widget.sopComBox.currentIndex()]
Pro.OPInfos={'opName': op, 'opClass': Pro.SOP_METHOD[op], 'opHyper': hyper[Pro.SOP_METHOD[op]]}
Pro.OP_infos={'opName': op, 'opClass': Pro.SOP_METHOD[op], 'opHyper': hyper[Pro.SOP_METHOD[op]]}
else:
op=widget.MOP_METHOD[widget.mopComBox.currentIndex()]
Pro.OPInfos={'opName': op, 'opClass': Pro.MOP_METHOD[op], 'opHyper': hyper[Pro.MOP_METHOD[op]]}
Pro.OP_infos={'opName': op, 'opClass': Pro.MOP_METHOD[op], 'opHyper': hyper[Pro.MOP_METHOD[op]]}

self.INDEX+=1
self.contentWidget.setCurrentIndex(self.INDEX)
Expand Down Expand Up @@ -326,8 +326,8 @@ def loadParaFile(self):
infos=Pro.importParaFromFile(path)
self.numPara.setText(str(len(infos)))

Pro.paraInfos=infos
Pro.projectInfos['paraPath']=path
Pro.OP_paraInfos=infos
Pro.OP_runInfos['paraPath']=path

def loadObjFile(self):

Expand All @@ -340,7 +340,7 @@ def loadObjFile(self):
objs=[f"obj {i : d}" for i in list(infos.keys())]
self.objEdit.addObjs(objs)

Pro.projectInfos['objPath']=path
Pro.OP_runInfos['objPath']=path

def ensureObj(self):

Expand All @@ -349,7 +349,7 @@ def ensureObj(self):
for objID in objIDs:
objInfos[objID]=self.objInfos[objID]

Pro.objInfos=objInfos
Pro.OP_objInfos=objInfos

def reset(self):

Expand Down Expand Up @@ -490,7 +490,7 @@ def updateUI(self):

def swatChanged(self):

Pro.projectInfos['swatExe']=self.swatEdit.currentText()
Pro.OP_runInfos['swatExe']=self.swatEdit.currentText()

def initialize(self):
#
Expand All @@ -499,23 +499,23 @@ def initialize(self):
averWidth = fontMetrics.averageCharWidth()
nChars=textWidth // averWidth
self.verbose.setProperty('totalWidth', nChars)
Pro.verboseWidth=nChars
Pro.OP_runInfos['verboseWidth']=nChars
#
numParallel=int(self.parallelEdit.value())
Pro.projectInfos['numParallel']=numParallel
Pro.projectInfos['tempPath']=os.path.join(Pro.projectInfos['projectPath'], 'temp')
Pro.OP_runInfos['numParallel']=numParallel
Pro.OP_runInfos['tempPath']=os.path.join(Pro.projectInfos['projectPath'], 'temp')

self.initializeBtn.setEnabled(False)

self.swatEdit.setEnabled(False)
self.parallelEdit.setEnabled(False)
self.problemEdit.setEnabled(False)

Pro.initProject(self.verbose, self.optimizationBtn)
Pro.initOP(self.verbose, self.optimizationBtn)

def optimizing(self):

Pro.problemInfos['name']=self.problemEdit.text()
Pro.OP_problemInfos['name']=self.problemEdit.text()

self.resetChange.emit(False)
self.optimizationBtn.setEnabled(False)
Expand Down Expand Up @@ -583,18 +583,10 @@ def __init__(self, parent=None):
vBoxLayout.addSpacing(10)
############################

#TODO
# h=QHBoxLayout()
# self.applyBtn=PrimaryPushButton("Apply optimal parameters to SWAT")
# setFont(self.applyBtn)
# h.addStretch(1); h.addWidget(self.applyBtn); h.addStretch(1)
# vBoxLayout.addLayout(h)
# vBoxLayout.addSpacing(10)

def updateUI(self):

self.verbose.append("")
self.verbose.append("".join(Pro.OPResult['verbose']))
self.verbose.append("".join(Pro.OP_result['verbose']))

class RadioWidget(QWidget):

Expand Down Expand Up @@ -658,5 +650,4 @@ def ensureType(self):
else:
self.clearBtn.emit()
self.mop.emit()
self.nextBtn.emit(True)

self.nextBtn.emit(True)
37 changes: 22 additions & 15 deletions GUI/component/validation_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self, parent=None):
vMainLayout.addWidget(self.table)

self.verbose=TextEdit(self);self.verbose.setReadOnly(True)
font = QFont("Consolas", pointSize=8)
font = QFont("Consolas", pointSize=12)
font.setStyleHint(QFont.Monospace)
self.verbose.setFont(font)
self.verbose.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
Expand Down Expand Up @@ -219,19 +219,19 @@ def loadFile(self):
for info in infos:
self.table.addRows_(info)

Pro.paraInfos=infos #TODO
Pro.projectInfos['paraPath']=path
Pro.Val_paraInfos=infos #TODO
Pro.Val_runInfos['paraPath']=path

objFile=self.objFileBox.currentText()
path=os.path.join(Pro.projectInfos['projectPath'], objFile)
infos=Pro.importProFromFile(path)

Pro.objInfos=infos #TODO
Pro.projectInfos['objPath']=path
Pro.Val_objInfos=infos #TODO
Pro.Val_runInfos['objPath']=path

Pro.projectInfos['numParallel']=1
Pro.projectInfos['tempPath']=os.path.join(Pro.projectInfos['projectPath'], 'validation') #TODO
Pro.projectInfos['swatExe']=self.swatBox.currentText()
Pro.Val_runInfos['numParallel']=1
Pro.Val_runInfos['tempPath']=os.path.join(Pro.projectInfos['projectPath'], 'validation') #TODO
Pro.Val_runInfos['swatExe']=self.swatBox.currentText()

self.resetBtn.setEnabled(True)
self.loadBtn.setEnabled(False)
Expand All @@ -248,6 +248,14 @@ def reset(self):
self.simBtn.setEnabled(False)
self.visualBtn.setEnabled(False)

self.verbose.clear()

Pro.Val_objInfos={}
Pro.Val_paraInfos={}
Pro.Val_problemInfos={}
Pro.Val_result={}
Pro.Val_runInfos={}

def setDecsToTable(self, index):

decs=self.data[index]
Expand All @@ -264,12 +272,11 @@ def apply(self):
averWidth = fontMetrics.averageCharWidth()
nChars=textWidth // averWidth
self.verbose.setProperty('totalWidth', nChars)
Pro.verboseWidth=nChars
Pro.Val_runInfos['verboseWidth']=nChars
#

self.verbose.clear()

Pro.initProject(self.verbose, self.simBtn)
Pro.initVal(self.verbose, self.simBtn)

self.applyBtn.setEnabled(False)

Expand All @@ -279,11 +286,11 @@ def finish():

self.verbose.append("The objective values are: ")

objs, simData=Pro.ValResult
objs, simData=Pro.Val_result

self.data=simData

for i, (ID, _) in enumerate(Pro.objInfos.items()):
for i, (ID, _) in enumerate(Pro.Val_objInfos.items()):

self.verbose.append(f"obj {ID}: {objs[i]:.4f} ")

Expand Down Expand Up @@ -481,7 +488,7 @@ def __init__(self, parent=None):

h=QHBoxLayout()
self.treeWidget=TreeWidgetObj(self)
self.treeWidget.addItems_(Pro.objInfos)
self.treeWidget.addItems_(Pro.Val_objInfos)

self.canvas=MplCanvas(width=16, height=9, dpi=300)

Expand Down Expand Up @@ -522,7 +529,7 @@ def __init__(self, width=16, height=9, dpi=300):
def plotPic(self, objID, serID, simData):

self.show_plot()
objInfos=Pro.objInfos
objInfos=Pro.Val_objInfos

timeLists=objInfos[objID][serID]['timeList']
dataList=objInfos[objID][serID]['dataList']
Expand Down
1 change: 0 additions & 1 deletion GUI/get_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def click_help(self):
QDesktopServices.openUrl(url)

def activateBtn(self):
#TODO
btnSets=Project.btnSets

for btn in btnSets[1:]:
Expand Down
3 changes: 3 additions & 0 deletions GUI/main_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ def initNavigation(self):

for btn in Pro.btnSets:
setFont(btn, 16)

for btn in Pro.btnSets[1:]:
btn.setEnabled(False)

def switchTo(self, interface):

Expand Down
Loading

0 comments on commit 0739625

Please sign in to comment.