def run(self, duration, obs=None):
from ecell4_base.core import TimeoutObserver<EOL>timeout = TimeoutObserver(self.__timeout)<EOL>if obs is None:<EOL><INDENT>obs = (timeout, )<EOL><DEDENT>elif isinstance(obs, collections.Iterable):<EOL><INDENT>obs = tuple(obs) + (timeout, )<EOL><DEDENT>else:<EOL><INDENT>obs = (obs, timeout)<EOL><DEDENT>from ipywidgets import FloatProgress, HBox, HTML<EOL>from IPython.display import display<EOL>from time import sleep<EOL>fp = FloatProgress(min=<NUM_LIT:0>, max=<NUM_LIT:100>)<EOL>ptext = HTML()<EOL>display(HBox(children=[fp, ptext]))<EOL>tstart = self.__sim.t()<EOL>upto = tstart + duration<EOL>while self.__sim.t() < upto:<EOL><INDENT>self.__sim.run(upto - self.__sim.t(), obs)<EOL>value = (self.__sim.t() - tstart) / duration<EOL>fp.value = value * <NUM_LIT:100><EOL>ptext.value = self.get_text(value, timeout.accumulation())<EOL>sleep(self.__wait)<EOL><DEDENT>fp.value = <NUM_LIT:100><EOL>ptext.value = self.get_text(<NUM_LIT:1>, timeout.accumulation())<EOL>
Run the simulation.

        Parameters
        ----------
        duration : Real
            a duration for running a simulation.
                A simulation is expected to be stopped at t() + duration.
        obs : list of Obeservers, optional
            observers