Package microsim.alignment.multiple
Class LogitScalingAlignment<T>
java.lang.Object
microsim.alignment.multiple.LogitScalingAlignment<T>
- Type Parameters:
T
- The type parameter usually representing the agent class.
- All Implemented Interfaces:
AlignmentUtils<T>
Multinomial alignment methods, where there is in general a set 'A' (>=2) of possible outcomes/states to align.
This algorithm is called Logit Scaling and is based on the minimization of the information loss (relative
entropy). This class can be applied to both weighted and non-weighted collections of agents. Additionally, it can be
used in conventional binary alignment problems.
- See Also:
- Implementation Note:
- The design of this class suboptimal at the moment to make all class implementations share as much code as
possible. In particular, when agents have no weight, they all automatically get one that is equal to 1.
This code extends the original algorithm by adding the case of weighted samples. It also does add a filter
for the whole population to align only the relevant subpopulation.
In the degenerate case when all probabilities are given as open-point distributions this algorithm fails to converge. This happens due to the fact it conserves
0
s and1
s, thus, the entire array of probabilities does not change.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
align
(@NonNull Collection<T> agents, @Nullable org.apache.commons.collections4.Predicate<T> filter, @NonNull AlignmentMultiProbabilityClosure<T> closure, double @NonNull [] targetProbabilityDistribution) General alignment procedure, it adjusts probabilities using all the provided parameters until the algorithm reaches the target precision/number of iterations.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
-
Field Details
-
ERROR_THRESHOLD
public static final double ERROR_THRESHOLDConstant: 1.0E-15.- See Also:
-
-
Constructor Details
-
LogitScalingAlignment
public LogitScalingAlignment()
-
-
Method Details
-
align
public final void align(@NonNull @NonNull Collection<T> agents, @Nullable @Nullable org.apache.commons.collections4.Predicate<T> filter, @NonNull @NonNull AlignmentMultiProbabilityClosure<T> closure, double @NonNull [] targetProbabilityDistribution) General alignment procedure, it adjusts probabilities using all the provided parameters until the algorithm reaches the target precision/number of iterations.- Parameters:
agents
- A collection of agents of a given type. Most commonly, every agent is a person, however, this class does not limit its usage to humans only.filter
- A filter to select a subpopulation from a given collection ofagents
, can acceptnull
values.closure
- An object that specifies how to get the (unaligned) probability of the agent and how to set the result of the aligned probability.targetProbabilityDistribution
- The target discrete probability distribution. Means of the aligned probabilities must be equal to these values.- Throws:
NullPointerException
- whenagents
,closure
, ortargetProbabilityDistribution
, or any combination of them are null.- Implementation Requirements:
- When the list of agents is empty, no alignment happens. The same works for cases when filtering produces an empty list.
- Implementation Note:
- The total number of iterations defaults to 50. The error threshold of the numerical scheme is
1e-15
.
-