Package microsim.alignment.probability
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.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
align
(@NonNull Collection<T> agents, @Nullable org.apache.commons.collections4.Predicate<T> filter, @NonNull AlignmentProbabilityClosure<T> closure, double targetProbability) The main alignment method that sorts by differences between predicted probability and a random number.sortByComparator
(@NonNull Map<T, Double> unsortedMap, boolean ascendingOrder) Sorting of objects of type T (usually the agents) by an associated Double number.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface microsim.alignment.AlignmentUtils
extractAgentList, validateProbabilityValue
-
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 benull
.targetProbability
- The resulting average probability that the method might converge to.- Throws:
NullPointerException
- whenagents
, orclosure
, or both arenull
.
-
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 theSBDAlignment
and inSBDLAlignment
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
- whenunsortedMap
isnull
.
-