Package edu.cnu.mdi.sim
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 TypeMethodDescriptiondefault voidcancel(SimulationContext ctx) Cancellation hook called on the simulation thread after cancel is requested.voidinit(SimulationContext ctx) Initialize simulation resources.default voidShutdown hook called on the simulation thread when the engine is terminating (normal completion, stop, cancel, or failure).booleanstep(SimulationContext ctx) Execute a single step of the simulation.
-
Method Details
-
init
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
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
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
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)
-