Class ResamplingAlignment<T extends EventListener>


  • public class ResamplingAlignment<T extends EventListener>
    extends AbstractOutcomeAlignment<T>
    Align the population by resampling. This involves picking an agent from the relevant collection of agents at (uniform) random, and resampling it's relevant attribute (as specified by the AlignmentOutcomeClosure). This process is continued until either the alignment target is reached, or the maximum number of attempts to resample has been reached. Implementation closely follows "Richiardi M., Poggi A. (2014). Imputing Individual Effects in Dynamic Microsimulation Models. An application to household formation and labor market participation in Italy. International Journal of Microsimulation, 7(2), pp. 3-39." and "Leombruni R, Richiardi M (2006). LABORsim: An Agent-Based Microsimulation of Labour Supply. An application to Italy. Computational Economics, vol. 27, no. 1, pp. 63-88"
    Author:
    Ross Richardson
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void align​(java.util.Collection<T> agents, org.apache.commons.collections4.Predicate<T> filter, AlignmentOutcomeClosure<T> closure, double targetShare)
      Align share of population by resampling.
      void align​(java.util.Collection<T> agents, org.apache.commons.collections4.Predicate<T> filter, AlignmentOutcomeClosure<T> closure, double targetShare, int maxResamplingAttempts)
      Align share of population by resampling.
      void align​(java.util.Collection<T> agents, org.apache.commons.collections4.Predicate<T> filter, AlignmentOutcomeClosure<T> closure, int targetNumber)
      Align absolute number of population by resampling.
      void align​(java.util.Collection<T> agents, org.apache.commons.collections4.Predicate<T> filter, AlignmentOutcomeClosure<T> closure, int targetNumber, int maxResamplingAttempts)
      Align absolute number of population by resampling.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResamplingAlignment

        public ResamplingAlignment()
    • Method Detail

      • align

        public void align​(java.util.Collection<T> agents,
                          org.apache.commons.collections4.Predicate<T> filter,
                          AlignmentOutcomeClosure<T> closure,
                          double targetShare)
        Align share of population by resampling. This involves picking an agent from the relevant collection of agents at (uniform) random, and resampling it's relevant attribute (as specified by the AlignmentOutcomeClosure). This process is continued until either the alignment target is reached, or the default maximum number of attempts to resample has been reached (which is 20 attempts per agent on average).
        Parameters:
        agents - - list of agents to potentially apply alignment to (will be filtered by the 'filter' Predicate class)
        filter - - filters the agentList so that only the relevant sub-population of agents is sampled
        closure - - AlignmentOutcomeClosure that specifies how to define the outcome of the agent and how to resample it
        targetShare - - the target share of the relevant sub-population (specified as a proportion of the filtered population) for which the outcome (defined by the AlignmentOutcomeClosure) must be true
      • align

        public void align​(java.util.Collection<T> agents,
                          org.apache.commons.collections4.Predicate<T> filter,
                          AlignmentOutcomeClosure<T> closure,
                          double targetShare,
                          int maxResamplingAttempts)
        Align share of population by resampling. This involves picking an agent from the relevant collection of agents at (uniform) random, and resampling it's relevant attribute (as specified by the AlignmentOutcomeClosure). This process is continued until either the alignment target is reached, or the maximum number of attempts to resample has been reached, as specified by the maxResamplingAttempts parameter.
        Specified by:
        align in class AbstractOutcomeAlignment<T extends EventListener>
        Parameters:
        agents - - list of agents to potentially apply alignment to (will be filtered by the 'filter' Predicate class)
        filter - - filters the agentList so that only the relevant sub-population of agents is sampled
        closure - - AlignmentOutcomeClosure that specifies how to define the outcome of the agent and how to resample it
        targetShare - - the target share of the relevant sub-population (specified as a proportion of the filtered population) for which the outcome (defined by the AlignmentOutcomeClosure) must be true
        maxResamplingAttempts - - the maximum number of attempts to resample before terminating the alignment (this is in case the resampling (as defined by the AlignmentOutcomeClosure) is unable to alter the outcomes of enough agents, due to the nature of the sub-population and the definition of the outcome (i.e. if agents' attributes are so far away from a binary outcome threshold boundary, that the probability of enough of them switching to the desired outcome is vanishingly small).
      • align

        public void align​(java.util.Collection<T> agents,
                          org.apache.commons.collections4.Predicate<T> filter,
                          AlignmentOutcomeClosure<T> closure,
                          int targetNumber)
        Align absolute number of population by resampling. This involves picking an agent from the relevant collection of agents at (uniform) random, and resampling it's relevant attribute (as specified by the AlignmentOutcomeClosure). This process is continued until either the alignment target is reached, or the default maximum number of attempts to resample has been reached (which is 20 attempts per agent on average).
        Parameters:
        agents - - list of agents to potentially apply alignment to (will be filtered by the 'filter' Predicate class)
        filter - - filters the agentList so that only the relevant sub-population of agents is sampled
        closure - - AlignmentOutcomeClosure that specifies how to define the outcome of the agent and how to resample it
        targetNumber - - the target number of the filtered population for which the outcome (defined by the AlignmentOutcomeClosure) must be true
      • align

        public void align​(java.util.Collection<T> agents,
                          org.apache.commons.collections4.Predicate<T> filter,
                          AlignmentOutcomeClosure<T> closure,
                          int targetNumber,
                          int maxResamplingAttempts)
        Align absolute number of population by resampling. This involves picking an agent from the relevant collection of agents at (uniform) random, and resampling it's relevant attribute (as specified by the AlignmentOutcomeClosure). This process is continued until either the alignment target is reached, or the maximum number of attempts to resample has been reached, as specified by the maxResamplingAttempts parameter.
        Specified by:
        align in class AbstractOutcomeAlignment<T extends EventListener>
        Parameters:
        agents - - list of agents to potentially apply alignment to (will be filtered by the 'filter' Predicate class)
        filter - - filters the agentList so that only the relevant sub-population of agents is sampled
        closure - - AlignmentOutcomeClosure that specifies how to define the outcome of the agent and how to resample it
        targetNumber - - the target number of the filtered population for which the outcome (defined by the AlignmentOutcomeClosure) must be true
        maxResamplingAttempts - - the maximum number of attempts to resample before terminating the alignment (this is in case the resampling (as defined by the AlignmentOutcomeClosure) is unable to alter the outcomes of enough agents, due to the nature of the sub-population and the definition of the outcome (i.e. if agents' attributes are so far away from a binary outcome threshold boundary, that the probability of enough of them switching to the desired outcome is vanishingly small).