Skip to content

Commit

Permalink
Use correct Xopt API for violation determination
Browse files Browse the repository at this point in the history
  • Loading branch information
zhe-slac committed Mar 18, 2024
1 parent 86f2289 commit e104edb
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/badger/gui/default/components/run_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,24 +690,25 @@ def check_critical(self):
# if there are no critical constraints then skip
if len(self.routine.critical_constraint_names) == 0:
return
else:
feas = self.vocs.feasibility_data(self.routine.data.iloc[-1], prefix='')
# print(feas[self.routine.critical_constraint_names], self.vocs)
violated_critical = ~feas[self.routine.critical_constraint_names].any()

if not violated_critical.item():
return
feas = self.vocs.feasibility_data(self.routine.data.tail(1), prefix='')
feasible = feas['feasible'].iloc[0].item()
if feasible:
return

# if code reaches this point there is a critical constraint violated
self.sig_pause.emit(True)
self.btn_ctrl.setIcon(self.icon_play)
self.btn_ctrl.setToolTip('Resume')
self.btn_ctrl._status = 'play'

msg = str(feas)
# Show the list of critical violated constraints
feas_crit = feas[self.routine.critical_constraint_names]
violated_crit = feas_crit.columns[~feas_crit.iloc[0]].tolist()
msg = '\n'.join(violated_crit)
reply = QMessageBox.warning(self,
'Run Paused',
f'Critical constraint was violated: {msg}\nTerminate the run?',
f'The following critical constraints were violated:\n\n{msg}\n\nTerminate the run?',
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
if reply == QMessageBox.Yes:
self.sig_stop.emit()
Expand Down

0 comments on commit e104edb

Please sign in to comment.