Class Simulator<U extends java.io.Serializable,​I extends java.io.Serializable,​P>

java.lang.Object
es.uam.eps.ir.relison.diffusion.simulation.Simulator<U,​I,​P>
Type Parameters:
U - type of the users.
I - type of the information pieces.
P - type of the parameters.
All Implemented Interfaces:
java.io.Serializable

public class Simulator<U extends java.io.Serializable,​I extends java.io.Serializable,​P>
extends java.lang.Object
implements java.io.Serializable
Class for the execution of information propagation simulations.
See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private int currentPropagated
    Number of items that have propagated information in an iteration.
    private int currentPropagatingUsers
    Number of users that have propagated information in an iteration.
    private java.lang.Long currentTimestamp
    For time-based simulations, the current timestamp.
    private Data<U,​I,​P> data
    The data to use in the simulation.
    private long newlyPropagatedInfo
    Number of newly propagated information in an iteration.
    private int numIter
    The current iteration.
    private Protocol<U,​I,​P> protocol
    Communication protocol.
    private SimulationState<U,​I,​P> state
    Current state of the simulation.
    private StopCondition<U,​I,​P> stop
    Stop condition for the simulation.
  • Constructor Summary

    Constructors 
    Constructor Description
    Simulator​(Protocol<U,​I,​P> protocol, StopCondition<U,​I,​P> stop)
    Full constructor.
  • Method Summary

    Modifier and Type Method Description
    void initialize​(Data<U,​I,​P> data)
    Initializes and prepares the data.
    void initialize​(Data<U,​I,​P> data, Simulation<U,​I,​P> simulation)
    Initializes and prepares the data.
    Simulation<U,​I,​P> simulate()
    Executes the simulation and stores the results in a file.
    Simulation<U,​I,​P> simulate​(java.lang.String backup)
    Executes the simulation and stores the results in a file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • stop

      private final StopCondition<U extends java.io.Serializable,​I extends java.io.Serializable,​P> stop
      Stop condition for the simulation.
    • protocol

      private final Protocol<U extends java.io.Serializable,​I extends java.io.Serializable,​P> protocol
      Communication protocol.
    • data

      private Data<U extends java.io.Serializable,​I extends java.io.Serializable,​P> data
      The data to use in the simulation.
    • numIter

      private int numIter
      The current iteration.
    • currentPropagated

      private int currentPropagated
      Number of items that have propagated information in an iteration.
    • currentPropagatingUsers

      private int currentPropagatingUsers
      Number of users that have propagated information in an iteration.
    • newlyPropagatedInfo

      private long newlyPropagatedInfo
      Number of newly propagated information in an iteration.
    • state

      private SimulationState<U extends java.io.Serializable,​I extends java.io.Serializable,​P> state
      Current state of the simulation.
    • currentTimestamp

      private java.lang.Long currentTimestamp
      For time-based simulations, the current timestamp.
  • Constructor Details

    • Simulator

      public Simulator​(Protocol<U,​I,​P> protocol, StopCondition<U,​I,​P> stop)
      Full constructor.
      Parameters:
      protocol - the communication protocol to apply.
      stop - the stop condition of the simulation.
  • Method Details

    • initialize

      public void initialize​(Data<U,​I,​P> data)
      Initializes and prepares the data.
      Parameters:
      data - the complete data for the simulation.
    • initialize

      public void initialize​(Data<U,​I,​P> data, Simulation<U,​I,​P> simulation)
      Initializes and prepares the data.
      Parameters:
      data - the complete data for the simulation.
      simulation - the current state of the simulation.
    • simulate

      public Simulation<U,​I,​P> simulate()
      Executes the simulation and stores the results in a file. This method does not backup the simulation.
      Returns:
      the simulation evolution.
    • simulate

      public Simulation<U,​I,​P> simulate​(java.lang.String backup)
      Executes the simulation and stores the results in a file.
      Parameters:
      backup - file where we want to backup the simulation, to prevent errors.
      Returns:
      the simulation evolution.