Class EvoLudoGWT

Object
EvoLudo
EvoLudoGWT
All Implemented Interfaces:
MersenneTwister.Chronometer, CLOProvider

public class EvoLudoGWT extends EvoLudo
GWT specific implementation of EvoLudo controller.
Author:
Christoph Hauert
  • Field Details

    • IBS_CHUNK_TARGET

      private static final int IBS_CHUNK_TARGET
      Target number of microscopic IBS updates processed in one hidden GWT chunk.
      See Also:
    • OSDE_CHUNK_TARGET

      private static final int OSDE_CHUNK_TARGET
      Target number of ODE/SDE integration increments processed in one hidden GWT chunk.
      See Also:
    • IBS_EPS

      private static final double IBS_EPS
      Tolerance for floating point comparisons of update milestones.
      See Also:
    • elapsedTime

      private final Duration elapsedTime
      Create timer to measure execution times since instantiation.
    • gui

      The reference to the GUI.
    • scheduledBusy

      private boolean scheduledBusy
      true while a one-off scheduled calculation is in progress and should drive the busy spinner even though the model is not in running mode.
    • relaxationChunkStep

      private double relaxationChunkStep
      Hidden chunk size in model time used for the currently scheduled relaxation. Positive values mark a relaxation as scheduled or in progress.
    • fatalExecutionError

      private boolean fatalExecutionError
      true after a fatal execution error has disabled the lab.
    • notifyGUI

      The field to store the command to execute after parsing the command line options.
    • timer

      Timer timer
      Timer for running models.
    • chunkedStepScheduled

      private boolean chunkedStepScheduled
      true while hidden chunk updates are scheduled or in progress.
    • chunkTimeStepOrig

      private double chunkTimeStepOrig
      The original report interval while scheduled, chunked updates are in progress.
    • chunkTargetUpdates

      private double chunkTargetUpdates
      The update milestone at which the current visible step is complete.
    • fullscreenElement

      Element fullscreenElement
      The reference to the fullscreen element.
    • cloSnap

      public final CLOption cloSnap
      Command line option to request that the EvoLudo model signals the completion of of the layouting procedure for taking snapshots, e.g. with capture-website.
      See Also:
  • Constructor Details

    • EvoLudoGWT

      public EvoLudoGWT(EvoLudoWeb gui)
      Construct EvoLudo controller for GWT applications (web or ePub).
      Parameters:
      gui - the reference to the GUI
  • Method Details

    • logProgress

      public void logProgress(String msg)
      GWT uses the config channel of the logger to report progress
      Specified by:
      logProgress in class EvoLudo
      Parameters:
      msg - progress message
    • execute

      public void execute(EvoLudo.Directive directive)
      Description copied from class: EvoLudo
      Execute directive in JRE or GWT environments.
      Specified by:
      execute in class EvoLudo
      Parameters:
      directive - the directive to execute in appropriate GWT or JRE manners
    • parseCLO

      public int parseCLO(EvoLudo.Directive command)
      Parse command line options and set the command to execute after parsing completed.
      Parameters:
      command - the command to execute after parsing
      Returns:
      the number of issues that have occurred durin parsing
    • showHelp

      public void showHelp()
      Description copied from class: EvoLudo
      Show help on command line options.
      Specified by:
      showHelp in class EvoLudo
    • guiReady

      public void guiReady()
      Called when the GUI has finished loading and the dimensions of all elements are known.
    • layoutComplete

      public void layoutComplete()
      Description copied from class: EvoLudo
      Notification from GUI that layout process has finished. Opportunity for taking snapshots.
      Overrides:
      layoutComplete in class EvoLudo
    • setScheduledBusy

      private void setScheduledBusy(boolean busy)
      Track whether one-off scheduled calculations are in progress.
      Parameters:
      busy - true while deferred work is scheduled or running
    • isRelaxationScheduled

      public boolean isRelaxationScheduled()
      Check whether the current scheduled busy phase is a chunked initial relaxation.
      Returns:
      true if a chunked relaxation is pending or in progress
    • modelRelax

      public boolean modelRelax(boolean quiet)
      Description copied from class: EvoLudo
      Relax model by timeRelax steps and notify all listeners if requested. Runtime-specific subclasses may override this method to perform relaxation asynchronously.
      Overrides:
      modelRelax in class EvoLudo
      Parameters:
      quiet - set to true to skip notifying listeners
      Returns:
      true if converged
      See Also:
    • scheduleModelRelaxation

      private void scheduleModelRelaxation(boolean quiet)
      Schedule chunked relaxation of the initial model state.
      Parameters:
      quiet - set to true to suppress relaxed/stopped notifications
    • finishScheduledRelaxation

      private void finishScheduledRelaxation(boolean interrupted, boolean quiet)
      Complete or abort a scheduled relaxation.
      Parameters:
      interrupted - true if the relaxation ended because another action interrupted it
      quiet - set to true to suppress relaxed/stopped notifications
    • resetScheduledRelaxation

      private void resetScheduledRelaxation()
      Reset temporary state used for scheduled initial relaxation.
    • runGuarded

      private void runGuarded(String context, Runnable action)
      Execute work behind a fatal error boundary.
      Parameters:
      context - the description of the operation
      action - the action to execute
    • runGuarded

      private boolean runGuarded(String context, Scheduler.RepeatingCommand action)
      Execute a scheduled command behind a fatal error boundary.
      Parameters:
      context - the description of the operation
      action - the action to execute
      Returns:
      false if execution should stop
    • handleFatalExecutionError

      private void handleFatalExecutionError(String context, Throwable error)
      Disable further execution after a fatal error and notify the GUI.
      Parameters:
      context - the description of the failing operation
      error - the underlying exception
    • abortFatalExecution

      public void abortFatalExecution()
      Stop all execution paths after a fatal error, without reporting it again.
    • run

      public void run()
      Description copied from class: EvoLudo
      Start the EvoLudo model and calculate the dynamics one step at a time.
      Specified by:
      run in class EvoLudo
    • next

      public void next()
      Description copied from class: EvoLudo
      Advances the EvoLudo model by a single step. Called when pressing the 'Step' button, the 'n' or 'right-arrow' key.
      Specified by:
      next in class EvoLudo
    • scheduleSample

      private void scheduleSample()
      Schedule the next sample.
    • scheduleStep

      private void scheduleStep()
      Schedule the next step.
    • getChunkStep

      private static double getChunkStep(Model model)
      Determine the hidden chunk step for model.
      Parameters:
      model - the model to inspect
      Returns:
      the hidden chunk step in generations, or 0 if no chunking should be used
    • scheduleChunkedStep

      private void scheduleChunkedStep(double chunkStep)
      Schedule a visible report step as a sequence of hidden substeps.
      Parameters:
      chunkStep - the maximum model-time increment per hidden substep
    • getNextChunkedReport

      private double getNextChunkedReport()
      Calculate the next regular report boundary for the active chunked model.
      Returns:
      the update milestone for the next visible step
    • finishChunkedStep

      private void finishChunkedStep(boolean cont)
      Complete the current hidden chunked step and forward the visible-step result.
      Parameters:
      cont - true if the model should continue after this step
    • resetChunking

      private void resetChunking()
      Reset temporary state used for hidden chunking.
    • fireModelRunning

      public void fireModelRunning()
      Description copied from class: EvoLudo
      Called whenever the model starts its calculations. Fires only when starting to run. Notifies all registered RunListeners.
      Overrides:
      fireModelRunning in class EvoLudo
    • fireModelUnloaded

      public void fireModelUnloaded()
      Description copied from class: EvoLudo
      Called whenever a new model has finished loading. Notifies all registered LifecycleListeners.
      Overrides:
      fireModelUnloaded in class EvoLudo
    • fireModuleUnloaded

      public void fireModuleUnloaded()
      Description copied from class: EvoLudo
      Called whenever the current module has finished unloading. Notifies all registered LifecycleListeners.
      Overrides:
      fireModuleUnloaded in class EvoLudo
    • fireModelStopped

      public void fireModelStopped()
      Description copied from class: EvoLudo
      Called after the population has reached an absorbing state (or has converged to an equilibrium state). Notifies all registered RunListeners.
      Overrides:
      fireModelStopped in class EvoLudo
    • preprocessCLO

      protected String[] preprocessCLO(String[] cloarray)
      Pre-process array of command line arguments. Some arguments need priority treatment. Examples include the options --module, --verbose or --restore.
      --module
      load module and remove option
      --verbose
      set verbosity level effective immediately. This ensures that issues when parsing the remaining command line options are already properly reported

      The command line arguments stored in a typical .plist file -- in particular when generated by the --export option -- includes this very option. Since JavaScript (GWT) contracts do not permit access to the users file system without explicit user interaction the --export does not make sense. However, it would still be useful to be able to restore the state of such a file in the browser through drag'n'drop. Here we simply check if --export was provided on the command line and discard it if found.

      Overrides:
      preprocessCLO in class EvoLudo
      Parameters:
      cloarray - array of command line arguments
      Returns:
      pre-processed array of command line options
      See Also:
      • EvoLudoJRE.cloExport
    • elapsedTimeMsec

      public int elapsedTimeMsec()
      Calculate elapsed time since instantiation in milliseconds.

      GWT implementation for measuring execution time.

      Returns:
      time in milliseconds
      See Also:
    • createNetwork2D

      public Network2D createNetwork2D(AbstractGeometry geometry)
      Description copied from class: EvoLudo
      Generate 2D network. This is the factory method to provide different implementations for GWT and JRE. More specifically, the layouting process in GWT uses scheduled execution on the browser event loop to prevent the GUI from stalling, while JRE implementations take advantage of worker threads for significantly faster execution through parallelization.
      Specified by:
      createNetwork2D in class EvoLudo
      Parameters:
      geometry - the geometry backing the 2D network
      Returns:
      new instance of a 2D network
    • createNetwork3D

      public Network3D createNetwork3D(AbstractGeometry geometry)
      Description copied from class: EvoLudo
      Generate 3D network. This is the factory method to provide different implementations for GWT and JRE. More specifically, the layouting process in GWT uses scheduled execution on the browser event loop to prevent the GUI from stalling, while JRE implementations take advantage of worker threads for significantly faster execution through parallelization.

      Note: The java3d package is obsolete. At present no 3D implementation for java exists.

      Specified by:
      createNetwork3D in class EvoLudo
      Parameters:
      geometry - the geometry backing the 3D network
      Returns:
      new instance of a 3D network
    • getGit

      public String getGit()
      Description copied from class: EvoLudo
      Gets current git version of code base.
      Specified by:
      getGit in class EvoLudo
      Returns:
      the git version string
    • getGitDate

      public String getGitDate()
      Description copied from class: EvoLudo
      Gets the compilation date of the current git version.
      Specified by:
      getGitDate in class EvoLudo
      Returns:
      the git compilation date as a string
    • setDelay

      public void setDelay(int delay)
      Description copied from class: EvoLudo
      Set delay between subsequent updates.
      Overrides:
      setDelay in class EvoLudo
      Parameters:
      delay - in milliseconds
    • setFullscreenElement

      public void setFullscreenElement(Element element)
      Set the fullscreen element.
      Parameters:
      element - the element to set as fullscreen
    • setFullscreen

      public void setFullscreen(boolean fullscreen)
      Enter or exit fullscreen mode.
      Parameters:
      fullscreen - true to enter fullscreen
    • restoreFromFile

      public boolean restoreFromFile()
      Restore state of EvoLudo model from saved plist, which encodes engine state.

      Called by Restore... context menu in AbstractView.

      Specified by:
      restoreFromFile in class EvoLudo
      Returns:
      true on successfully restoring state
      See Also:
    • exportState

      public void exportState()
      Export the current state of the engine using the appropriate means available in the current environment (GWT/JRE).

      Note: nudges web browser to download the current state and save it in a file named "evoludo.plist". Export (context menu) suppressed in ePubs.

      Specified by:
      exportState in class EvoLudo
      See Also:
    • collectCLO

      public void collectCLO(CLOParser prsr)
      Description copied from class: EvoLudo
      All providers of command line options must implement this method to collect their options.

      Each command line option is (uniquely) identified by it's name (see CLOption.getName()), which corresponds to the long version of the option. If an attempt is made to add an option with a name that already exists, the parser issues a warning and ignores the option. Thus, in general, implementing subclasses should first register their options and call super.collectCLO(CLOParser) at the end such that subclasses are able to override command line options specified in a parental class.

      Override this method in subclasses to add further command line options. Subclasses must make sure that they include a call to super.

      Note: In contrast to other providers of command line options, the EvoLudo class delegates collection to the controller which maintains the shared parser.

      Specified by:
      collectCLO in interface CLOProvider
      Overrides:
      collectCLO in class EvoLudo
      Parameters:
      prsr - the reference to parser that manages command line options
      See Also: