capn-freako/PyBERT

Add Simulation Abort Capability.

capn-freako opened this issue · 1 comments

Describe the desired new or improved feature.
While we're currently able to abort an optimization, we aren't able to abort a simulation.
We should have this capability, to handle, for instance:

  • when the user launches a simulation having mistyped the number of bits she wants to run.

Expected behavior
An item in the Simulation menu, which aborts the currently running simulation when selected.
Also, a keyboard shortcut for this menu item.

Screenshots
(n/a)

Desktop (please complete the following information):

  • OS: (all)
  • Python Version (all)
  • PyBERT Version (next release)

Additional context
(n/a)

This will force us to breakout down our my_run_sweep to check that the thread is still alive and should it continue since today the thread just calls one function and returns.

    def run(self):
        """Run the simulation(s)."""
        my_run_sweeps(self.the_pybert)

Comparing that to the optimization threads that run an iteration of minimization and then check if it should stop or not.

                res = minimize(
                    self.do_opt_tx,
                    old_taps,
                    bounds=bounds,
                    constraints=cons,
                    options={"disp": False, "maxiter": max_iter},
                )

   ...

    def do_opt_tx(self, taps):
        """Run the Tx Optimization."""
        sleep(0.001)  # Give the GUI a chance to acknowledge user clicking the Abort button.

        if self.stopped():
            raise RuntimeError("Optimization aborted.")

        pybert = self.pybert
        tuners = pybert.tx_tap_tuners
        taps = list(taps)
        for tuner in tuners:
            if tuner.enabled:
                tuner.value = taps.pop(0)
        return pybert.cost

This will tie nicely into #119. We can pull apart my_run_sweep and then have the correct solver get created for time or statistical simulation.