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

java.lang.Object
es.uam.eps.ir.relison.diffusion.simulation.Simulation<U,​I,​P>
Type Parameters:
U - type of the users.
I - type of the information pieces.
P - type of the parameter values.

public class Simulation<U extends java.io.Serializable,​I extends java.io.Serializable,​P>
extends java.lang.Object
Class that stores the evolution of a simulation over time. It just stores the pieces that are read by the different users in the network.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private Data<U,​I,​P> data
    Data.
    private int initialNumber
    Initial iteration number.
    private java.util.List<Iteration<U,​I,​P>> iterations
    List of iterations.
    private int numIterations
    Total number of iterations in the simulation.
  • Constructor Summary

    Constructors 
    Constructor Description
    Simulation​(Data<U,​I,​P> data)
    Constructor.
    Simulation​(Data<U,​I,​P> data, int initialNumber)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    boolean addIteration​(Iteration<U,​I,​P> iteration)
    Adds an iteration.
    Data<U,​I,​P> getData()
    Obtains the data for the simulation.
    SimulationState<U,​I,​P> getFinalState​(UpdateMechanism upd)
    Finds a final state of the simulation.
    int getInitialNumber()
    Number of the first iteration.
    Iteration<U,​I,​P> getIteration​(int number)
    Gets an individual iteration in the simulation.
    int getNumIterations()
    Obtains the current number of iterations in the simulation.
    private void updateDiscarded​(Iteration<U,​I,​P> iteration, java.util.Map<U,​java.util.Map<I,​java.lang.Long>> propagated, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> discarded, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> received)
    Updates the values for discarded pieces of information.
    private void updatePropagated​(Iteration<U,​I,​P> iteration, java.util.Map<U,​java.util.Map<I,​java.lang.Long>> propagated, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> discarded, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> received)
    Updates the values for propagated pieces of information.
    private void updateReceived​(Iteration<U,​I,​P> iteration, java.util.Map<U,​java.util.Map<I,​java.lang.Long>> propagated, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> discarded, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> received, UpdateMechanism upd)
    Updates the values for received pieces of information.

    Methods inherited from class java.lang.Object

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

    • numIterations

      private int numIterations
      Total number of iterations in the simulation.
    • iterations

      private final java.util.List<Iteration<U extends java.io.Serializable,​I extends java.io.Serializable,​P>> iterations
      List of iterations.
    • data

      private final Data<U extends java.io.Serializable,​I extends java.io.Serializable,​P> data
      Data.
    • initialNumber

      private final int initialNumber
      Initial iteration number.
  • Constructor Details

    • Simulation

      public Simulation​(Data<U,​I,​P> data, int initialNumber)
      Constructor.
      Parameters:
      data - the real data.
      initialNumber - initial iteration number.
    • Simulation

      public Simulation​(Data<U,​I,​P> data)
      Constructor.
      Parameters:
      data - the real data
  • Method Details

    • addIteration

      public boolean addIteration​(Iteration<U,​I,​P> iteration)
      Adds an iteration. The iteration must have the correct iteration number (initial + number of iterations).
      Parameters:
      iteration - the iteration to add.
      Returns:
      true if the iteration is correctly added, false if it is not.
    • getIteration

      public Iteration<U,​I,​P> getIteration​(int number)
      Gets an individual iteration in the simulation.
      Parameters:
      number - the number of the iteration.
      Returns:
      the iteration if it exists, null if it does not.
    • getNumIterations

      public int getNumIterations()
      Obtains the current number of iterations in the simulation.
      Returns:
      the current number of iterations in the simulation.
    • getData

      public Data<U,​I,​P> getData()
      Obtains the data for the simulation.
      Returns:
      the data for the simulation.
    • getInitialNumber

      public int getInitialNumber()
      Number of the first iteration.
      Returns:
      the number of the first iteration.
    • getFinalState

      public SimulationState<U,​I,​P> getFinalState​(UpdateMechanism upd)
      Finds a final state of the simulation.
      Parameters:
      upd - update mechanism.
      Returns:
      the final state of the simulation.
    • updatePropagated

      private void updatePropagated​(Iteration<U,​I,​P> iteration, java.util.Map<U,​java.util.Map<I,​java.lang.Long>> propagated, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> discarded, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> received)
      Updates the values for propagated pieces of information.
      Parameters:
      iteration - the current iteration.
      propagated - the set of propagated pieces.
      discarded - the set of discarded pieces.
      received - the set of received pieces.
    • updateDiscarded

      private void updateDiscarded​(Iteration<U,​I,​P> iteration, java.util.Map<U,​java.util.Map<I,​java.lang.Long>> propagated, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> discarded, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> received)
      Updates the values for discarded pieces of information.
      Parameters:
      iteration - the current iteration.
      propagated - the set of propagated pieces.
      discarded - the set of discarded pieces.
      received - the set of received pieces.
    • updateReceived

      private void updateReceived​(Iteration<U,​I,​P> iteration, java.util.Map<U,​java.util.Map<I,​java.lang.Long>> propagated, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> discarded, java.util.Map<U,​java.util.Map<I,​Tuple2oo<java.util.Set<U>,​java.lang.Long>>> received, UpdateMechanism upd)
      Updates the values for received pieces of information.
      Parameters:
      iteration - the current iteration.
      propagated - the set of propagated pieces.
      discarded - the set of discarded pieces.
      received - the set of received pieces.
      upd - the update mechanism.