Package microsim.alignment.outcome
Class ResamplingWeightedAlignment<T extends EventListener & Weight>
- java.lang.Object
-
- microsim.alignment.outcome.AbstractOutcomeAlignment<T>
-
- microsim.alignment.outcome.ResamplingWeightedAlignment<T>
-
public class ResamplingWeightedAlignment<T extends EventListener & Weight> extends AbstractOutcomeAlignment<T>
Align the population by weighted resampling. This involves picking an agent from the relevant collection of agents at random with a probability that depends on an associated weight. The chosen agent then undergoes resampling of 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 the JAS-mine ResamplingAlignment class, which is based on: "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
-
-
Constructor Summary
Constructors Constructor Description ResamplingWeightedAlignment()
-
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 weighted 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 weighted 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 weighted 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 weighted resampling.void
doAlignment(java.util.List<T> list, AlignmentOutcomeClosure<T> closure, double targetNumber, int maxResamplingAttempts)
-
-
-
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 weighted resampling. This involves picking an agent from the relevant collection of agents at random with a probability that depends on an associated weight. The chosen agent then undergoes resampling of 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
- - a list of agents to potentially be resampled; the agent class must implement the Weight interface by providing a getWeight() method. In the case of the alignment algorithm, getWeight() must return a positive value.filter
- - filters the agentList so that only the relevant sub-population of agents is sampledclosure
- - AlignmentOutcomeClosure that specifies how to define the outcome of the agent and how to resample ittargetShare
- - 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 weighted resampling. This involves picking an agent from the relevant collection of agents at random with a probability that depends on an associated weight. The chosen agent then undergoes resampling of 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 classAbstractOutcomeAlignment<T extends EventListener & Weight>
- Parameters:
agents
- - a list of agents to potentially be resampled; the agent class must implement the Weight interface by providing a getWeight() method. In the case of the alignment algorithm, getWeight() must return a positive value.filter
- - filters the agentList so that only the relevant sub-population of agents is sampledclosure
- - AlignmentOutcomeClosure that specifies how to define the outcome of the agent and how to resample ittargetShare
- - 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 truemaxResamplingAttempts
- - 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 weighted resampling. This involves picking an agent from the relevant collection of agents at random with a probability that depends on an associated weight. The chosen agent then undergoes resampling of 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
- - a list of agents to potentially be resampled; the agent class must implement the Weight interface by providing a getWeight() method. In the case of the alignment algorithm, getWeight() must return a positive value.filter
- - filters the agentList so that only the relevant sub-population of agents is sampledclosure
- - AlignmentOutcomeClosure that specifies how to define the outcome of the agent and how to resample ittargetNumber
- - 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 weighted resampling. This involves picking an agent from the relevant collection of agents at random with a probability that depends on an associated weight. The chosen agent then undergoes resampling of 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 classAbstractOutcomeAlignment<T extends EventListener & Weight>
- Parameters:
agents
- - a list of agents to potentially be resampled; the agent class must implement the Weight interface by providing a getWeight() method. In the case of the alignment algorithm, getWeight() must return a positive value.filter
- - filters the agentList so that only the relevant sub-population of agents is sampledclosure
- - AlignmentOutcomeClosure that specifies how to define the outcome of the agent and how to resample ittargetNumber
- - the target number of the filtered population for which the outcome (defined by the AlignmentOutcomeClosure) must be true //XXX: Should ideally be a double, because now agents are weighted. However, interace requires an int here.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).
-
doAlignment
public void doAlignment(java.util.List<T> list, AlignmentOutcomeClosure<T> closure, double targetNumber, int maxResamplingAttempts)
-
-