Class AbstractSortByDifferenceAlignment<T>

java.lang.Object
microsim.alignment.probability.AbstractSortByDifferenceAlignment<T>
Type Parameters:
T - A class usually representing an agent.
All Implemented Interfaces:
AlignmentUtils<T>
Direct Known Subclasses:
SBDAlignment, SBDLAlignment

public abstract class AbstractSortByDifferenceAlignment<T> extends Object implements AlignmentUtils<T>
An abstract class for all versions of the sort-by-difference algorithm.
See Also:
  • Constructor Details

    • AbstractSortByDifferenceAlignment

      public AbstractSortByDifferenceAlignment()
  • Method Details

    • align

      public void align(@NonNull @NonNull Collection<T> agents, @Nullable @Nullable org.apache.commons.collections4.Predicate<T> filter, @NonNull @NonNull AlignmentProbabilityClosure<T> closure, double targetProbability)
      The main alignment method that sorts by differences between predicted probability and a random number.
      Parameters:
      agents - A collection of agents.
      filter - A logical filter that allows filtering out certain agents.
      closure - A closure that allows probability value manipulations, can be null.
      targetProbability - The resulting average probability that the method might converge to.
      Throws:
      NullPointerException - when agents, or closure, or both are null.
    • sortByComparator

      @NonNull protected @NonNull Map<T,Double> sortByComparator(@NonNull @NonNull Map<T,Double> unsortedMap, boolean ascendingOrder)
      Sorting of objects of type T (usually the agents) by an associated Double number. This method is used in the SBDAlignment and in SBDLAlignment algorithms.
      Parameters:
      unsortedMap - An unsorted map of objects of some type.
      ascendingOrder - If true, the method returns a map ordered by the Double value increasing, otherwise the map will be ordered by the Double value decreasing.
      Returns:
      a LinkedHashMap of type T objects that maintains the order of insertion, always not null.
      Throws:
      NullPointerException - when unsortedMap is null.