The FemalesWithChildrenByChildAgeCSfilter filter is incorrectly implemented. The offending bit is this loop, gathering children ages:
Set<Person> childrenInBU = person.getBenefitUnit().getChildren();
int[] ages = new int[childrenInBU.size()];
if (childrenInBU != null) {
int arrayPosition = 0;
for (Person child : childrenInBU) {
ages[arrayPosition] = child.getDemAge();
}
}
arrayPosition is never incremented, meaning ages will only see one child (and if there are more than one children, this means the minimum age being seen will also be 0 rather than the age of that child).
The semantic of that filter is also slightly unclear. Looking at the implementation (and especially an older implementation that's been commented out), this seems to be intended to check that all children are in the given age range. The way it's used in experiment/SimPathsObserver.java, however, seems to need to check that any child (rather than all children) is in the given age range (for which leveraging BenefitUnit::getIndicatorChildren is probably the way to go).
Note: the check childrenInBU != null is unnecessary since BenefitUnit::getChildren never returns a null. It's also too late anyway since childrenInBU.size() called before would fail on a null.
Once the semantic is clarified, I'm happy to make a PR (I also have a performance improvement for BenefitUnit::getIndicatorChildren I can throw in).
The
FemalesWithChildrenByChildAgeCSfilterfilter is incorrectly implemented. The offending bit is this loop, gathering children ages:arrayPositionis never incremented, meaningageswill only see one child (and if there are more than one children, this means the minimum age being seen will also be 0 rather than the age of that child).The semantic of that filter is also slightly unclear. Looking at the implementation (and especially an older implementation that's been commented out), this seems to be intended to check that all children are in the given age range. The way it's used in
experiment/SimPathsObserver.java, however, seems to need to check that any child (rather than all children) is in the given age range (for which leveragingBenefitUnit::getIndicatorChildrenis probably the way to go).Note: the check
childrenInBU != nullis unnecessary sinceBenefitUnit::getChildrennever returns anull. It's also too late anyway sincechildrenInBU.size()called before would fail on anull.Once the semantic is clarified, I'm happy to make a PR (I also have a performance improvement for
BenefitUnit::getIndicatorChildrenI can throw in).