Class AbstractMonothreadedEngine

    • Constructor Detail

      • AbstractMonothreadedEngine

        public AbstractMonothreadedEngine()
    • Method Detail

      • performSimulation

        protected SimulationTimeStamp performSimulation​(ISimulationModel simulationModel,
                                                        DynamicStateMap currentSimulationDynamicState,
                                                        LinkedHashMap<LevelIdentifier,​ILevel> levels,
                                                        LinkedHashMap<LevelIdentifier,​LinkedHashSet<IAgent4Engine>> agents,
                                                        IEnvironment4Engine environment)
        Runs the simulation, so that it goes from its current initial state to its final state.

        Implementation instructions

        This method has multiple roles along the execution of the simulation:

        • Determine when the perception, global state revision and decision methods of the agents are called, using the value of the levels, agents and environment arguments.
        • Determine when the natural method of the environment is called using the value of the levels, agents and environment arguments.
        • Determine when the reaction of a level is computed using the value of the levels, agents and environment arguments.
        • Determine how the reaction is computed:
          • Write how the system influences are managed: the addition of the public local state of an agent to a level implies the addition of the agent for that level in the levels argument.
          • Include the produced influences either into the reaction of other levels, or in their transitory state dynamics
        • Update the content of the levels, agents and environment arguments according to the changes occurring during the execution of the simulation.
        • When the simulation reaches an half-consistent state, this method has to update the value of the currentSimulationDynamicState argument to match the real state of the simulation: if a level is consistent, then its consistent state has to be put in currentSimulationDynamicState (see ILevel.getLastConsistentState()). If it is transitory, then its transitory state has to be put in currentSimulationDynamicState (see ILevel.getLastTransitoryState());
        • When the simulation reaches an half-consistent state, this method has the responsibility to call the IProbe.observeAtPartialConsistentTime(SimulationTimeStamp, fr.univ_artois.lgi2a.similar.microkernel.ISimulationEngine) method of each probe of the simulation (after the operations described in the previous item of this list);
        • After each reaction phase, check that the abortion flag is raised (see AbstractSimulationEngineWithInitialization.isAbortionRequested()). If true, stop the execution of the simulation and throw an ExceptionSimulationAborted exception.
        Specified by:
        performSimulation in class AbstractSimulationEngineWithInitialization
        Parameters:
        simulationModel - The model of the simulation being run.
        currentSimulationDynamicState - Models the public local dynamic states of the simulation being forwarded to the probes to display the content of the simulation. This map contains either consistent dynamic states (if the current time stamp of the simulation is equal to the current time stamp of the level) or transitory dynamic state (if the level is currently between two of its time stamps).
        levels - A map associating a level to its identifier. This map initially contains the levels in their initial state.
        agents - A map associating the agents lying in each level of the simulation to the identifier of the level. This map contains the initial agents of the simulation, in their initial state.
        environment - The environment where the simulation takes place. This environment is in its initial state.
        Returns:
        The final time stamp of the simulation.
      • buildDynamicStateDisambiguation

        protected abstract DynamicStateMap buildDynamicStateDisambiguation​(DynamicStateMap currentSimulationHalfConsistentState)
        Builds a disambiguated version of an half consistent state of the simulation.
        Parameters:
        currentSimulationHalfConsistentState - The half-consistent state of the simulation.
        Returns:
        A disambiguation of the half-consistent state of the simulation.