Interface Simulation

All Known Implementing Classes:
GeneticAlgorithmSimulation, NetworkDeclutterSimulation, SimulatedAnnealingSimulation

public interface Simulation
Computation plugin for SimulationEngine.

A Simulation contains no UI code. It runs entirely on the simulation thread. It can request UI updates via SimulationEngine.requestRefresh() and SimulationEngine.postProgress(ProgressInfo) / SimulationEngine.postMessage(String).

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Cancellation hook called on the simulation thread after cancel is requested.
    void
    Initialize simulation resources.
    default void
    Shutdown hook called on the simulation thread when the engine is terminating (normal completion, stop, cancel, or failure).
    boolean
    Execute a single step of the simulation.
  • Method Details

    • init

      void init(SimulationContext ctx) throws Exception
      Initialize simulation resources. Called exactly once on the simulation thread.
      Parameters:
      ctx - simulation context
      Throws:
      Exception - any error; will cause engine to transition to FAILED
    • step

      boolean step(SimulationContext ctx) throws Exception
      Execute a single step of the simulation. Called repeatedly on the simulation thread while running.
      Parameters:
      ctx - simulation context
      Returns:
      true to continue running; false to stop (normal completion)
      Throws:
      Exception - any error; will cause engine to transition to FAILED
    • shutdown

      default void shutdown(SimulationContext ctx) throws Exception
      Shutdown hook called on the simulation thread when the engine is terminating (normal completion, stop, cancel, or failure). Initialization may have completed only partially when this method is called, so implementations should tolerate partially initialized state.
      Parameters:
      ctx - simulation context
      Throws:
      Exception - ignored by the engine (best-effort cleanup)
    • cancel

      default void cancel(SimulationContext ctx) throws Exception
      Cancellation hook called on the simulation thread after cancel is requested.

      The simulation should attempt to exit promptly. The engine will still call shutdown(SimulationContext) afterwards.

      Parameters:
      ctx - simulation context
      Throws:
      Exception - ignored by the engine (best-effort cancellation)