diff --git a/siloCore/src/main/java/de/tum/bgu/msm/data/household/HouseholdUtil.java b/siloCore/src/main/java/de/tum/bgu/msm/data/household/HouseholdUtil.java index e4bacbed1..7a924e598 100644 --- a/siloCore/src/main/java/de/tum/bgu/msm/data/household/HouseholdUtil.java +++ b/siloCore/src/main/java/de/tum/bgu/msm/data/household/HouseholdUtil.java @@ -39,11 +39,11 @@ public static int getAnnualHhIncome(Household household) { return household.getPersons().values().stream().mapToInt(Person::getAnnualIncome).sum(); } - public static boolean checkIfAdultsPresent(Household household) { + public static boolean checkIfNoAdultsPresent(Household household) { if (household.getPersons().isEmpty()) { return false; } - return household.getPersons().values().stream().anyMatch(pp -> pp.getAge() >= 16); + return household.getPersons().values().stream().allMatch(pp -> pp.getAge() < 16); } public static HouseholdType defineHouseholdType(Household household) { @@ -79,6 +79,7 @@ public static HouseholdType defineHouseholdType(Household household) { /** * return income category defined exogenously + * * @param hhInc * @return */ @@ -93,13 +94,13 @@ public static IncomeCategory getIncomeCategoryForIncome(int hhInc) { return IncomeCategory.values()[IncomeCategory.values().length - 1]; } - public static Person findMostLikelyUnmarriedPartner (Person per, Household hh) { + public static Person findMostLikelyUnmarriedPartner(Person per, Household hh) { // when assigning roles to persons, look for likely partner in household that is not married yet Person selectedPartner = null; double highestUtil = Double.NEGATIVE_INFINITY; double tempUtil; - for (Person partner: hh.getPersons().values()) { + for (Person partner : hh.getPersons().values()) { if (partner.getGender() != per.getGender() && partner.getRole() != PersonRole.MARRIED) { int ageDiff = Math.abs(per.getAge() - partner.getAge()); if (ageDiff == 0) { @@ -121,12 +122,12 @@ public static Person findMostLikelyPartner(Person per, Household hh) { double highestUtil = Double.NEGATIVE_INFINITY; double tempUtil; Person selectedPartner = null; - for(Person partner: hh.getPersons().values()) { + for (Person partner : hh.getPersons().values()) { if (!partner.equals(per) && partner.getGender() != per.getGender() && partner.getRole() == PersonRole.MARRIED) { final int ageDiff = Math.abs(per.getAge() - partner.getAge()); if (ageDiff == 0) { tempUtil = 2.; - } else { + } else { tempUtil = 1. / ageDiff; } if (tempUtil > highestUtil) { @@ -137,7 +138,7 @@ public static Person findMostLikelyPartner(Person per, Household hh) { } if (selectedPartner == null) { logger.error("Could not find spouse of person " + per.getId() + " in household " + hh.getId()); - for (Person person: hh.getPersons().values()) { + for (Person person : hh.getPersons().values()) { logger.error("Houshold member " + person.getId() + " (gender: " + person.getGender() + ") is " + person.getRole()); } @@ -145,15 +146,15 @@ public static Person findMostLikelyPartner(Person per, Household hh) { return selectedPartner; } - public static void defineUnmarriedPersons (Household hh) { + public static void defineUnmarriedPersons(Household hh) { // For those that did not become the married couple define role in household (child or single) - for (Person pp: hh.getPersons().values()) { + for (Person pp : hh.getPersons().values()) { if (pp.getRole() == PersonRole.MARRIED) { continue; } boolean someone15to40yearsOlder = false; // assumption that this person is a parent final int ageMain = pp.getAge(); - for (Person per: hh.getPersons().values()) { + for (Person per : hh.getPersons().values()) { if (pp.equals(per)) { continue; } @@ -177,7 +178,7 @@ public static void defineUnmarriedPersons (Household hh) { public static void findMarriedCouple(Household hh) { List personsCopy = hh.getPersons().values().stream().sorted(new PersonUtils.PersonByAgeComparator()).collect(Collectors.toList()); - for (Person person: personsCopy) { + for (Person person : personsCopy) { Person partner = HouseholdUtil.findMostLikelyUnmarriedPartner(person, hh); if (partner != null) { partner.setRole(PersonRole.MARRIED); @@ -196,12 +197,12 @@ public static void findMarriedCouple(Household hh) { } } } - + public static Map getPopulationByZoneAsMap(DataContainer dataContainer) { - Map zonePopulationMap = new HashMap<>(); - for (int zone : dataContainer.getGeoData().getZones().keySet()) { - zonePopulationMap.put(zone, 0); - } + Map zonePopulationMap = new HashMap<>(); + for (int zone : dataContainer.getGeoData().getZones().keySet()) { + zonePopulationMap.put(zone, 0); + } for (Household hh : dataContainer.getHouseholdDataManager().getHouseholds()) { final int zone = dataContainer.getRealEstateDataManager().getDwelling(hh.getDwellingId()).getZoneId(); diff --git a/siloCore/src/main/java/de/tum/bgu/msm/io/output/DefaultHouseholdWriter.java b/siloCore/src/main/java/de/tum/bgu/msm/io/output/DefaultHouseholdWriter.java index 206a5b760..073bde0c7 100644 --- a/siloCore/src/main/java/de/tum/bgu/msm/io/output/DefaultHouseholdWriter.java +++ b/siloCore/src/main/java/de/tum/bgu/msm/io/output/DefaultHouseholdWriter.java @@ -3,14 +3,14 @@ import de.tum.bgu.msm.data.household.Household; import de.tum.bgu.msm.data.household.HouseholdDataManager; import de.tum.bgu.msm.utils.SiloUtil; -import org.jboss.logging.Logger; +import org.apache.log4j.Logger; import java.io.PrintWriter; public class DefaultHouseholdWriter implements HouseholdWriter { private final HouseholdDataManager householdData; - private final static Logger logger = Logger.getLogger(DefaultHouseholdWriter.class); + private final static Logger logger = Logger.getLogger(DefaultHouseholdWriter.class); public DefaultHouseholdWriter(HouseholdDataManager householdData) { this.householdData = householdData; diff --git a/siloCore/src/main/java/de/tum/bgu/msm/models/demography/death/DeathModelImpl.java b/siloCore/src/main/java/de/tum/bgu/msm/models/demography/death/DeathModelImpl.java index 85e73795d..965a97ac2 100644 --- a/siloCore/src/main/java/de/tum/bgu/msm/models/demography/death/DeathModelImpl.java +++ b/siloCore/src/main/java/de/tum/bgu/msm/models/demography/death/DeathModelImpl.java @@ -101,7 +101,7 @@ boolean die(Person person) { } householdDataManager.removePerson(person.getId()); - final boolean onlyChildrenLeft = HouseholdUtil.checkIfAdultsPresent(hhOfPersonToDie); + final boolean onlyChildrenLeft = HouseholdUtil.checkIfNoAdultsPresent(hhOfPersonToDie); if (onlyChildrenLeft) { for (Person pp : hhOfPersonToDie.getPersons().values()) { if (pp.getId() == SiloUtil.trackPp || hhOfPersonToDie.getId() == SiloUtil.trackHh) { diff --git a/siloCore/src/main/java/de/tum/bgu/msm/models/demography/leaveParentalHousehold/LeaveParentHhModelImpl.java b/siloCore/src/main/java/de/tum/bgu/msm/models/demography/leaveParentalHousehold/LeaveParentHhModelImpl.java index 9cec69ebb..e0c12b251 100644 --- a/siloCore/src/main/java/de/tum/bgu/msm/models/demography/leaveParentalHousehold/LeaveParentHhModelImpl.java +++ b/siloCore/src/main/java/de/tum/bgu/msm/models/demography/leaveParentalHousehold/LeaveParentHhModelImpl.java @@ -17,9 +17,6 @@ package de.tum.bgu.msm.models.demography.leaveParentalHousehold; import de.tum.bgu.msm.container.DataContainer; -import de.tum.bgu.msm.data.Region; -import de.tum.bgu.msm.data.dwelling.RealEstateDataManager; -import de.tum.bgu.msm.data.geo.GeoData; import de.tum.bgu.msm.data.household.Household; import de.tum.bgu.msm.data.household.HouseholdDataManager; import de.tum.bgu.msm.data.household.HouseholdFactory; @@ -67,17 +64,6 @@ public LeaveParentHhModelImpl(DataContainer dataContainer, MovesModelImpl move, @Override public void setup() { -// switch (properties.main.implementation) { -// case MARYLAND: -// case AUSTIN: -// reader = new InputStreamReader(this.getClass().getResourceAsStream("LeaveParentHhCalcMstm")); -// break; -// case MUNICH: -// case PERTH: -// case KAGAWA: -// case CAPE_TOWN: -// reader = new InputStreamReader(this.getClass().getResourceAsStream("LeaveParentHhCalc")); -// } } @Override diff --git a/siloCore/src/main/java/de/tum/bgu/msm/models/demography/marriage/MarriageModelImpl.java b/siloCore/src/main/java/de/tum/bgu/msm/models/demography/marriage/MarriageModelImpl.java index 1379af72d..2bb05614f 100644 --- a/siloCore/src/main/java/de/tum/bgu/msm/models/demography/marriage/MarriageModelImpl.java +++ b/siloCore/src/main/java/de/tum/bgu/msm/models/demography/marriage/MarriageModelImpl.java @@ -363,7 +363,7 @@ private void movePerson(Person person1, Household moveTo) { if (!moveTo.equals(household1)) { householdDataManager.removePersonFromHousehold(person1); householdDataManager.addPersonToHousehold(person1, moveTo); - if (HouseholdUtil.checkIfAdultsPresent(household1)) { + if (HouseholdUtil.checkIfNoAdultsPresent(household1)) { moveRemainingChildren(household1, moveTo); } } diff --git a/useCases/capeTown/src/main/java/de/tum/bgu/msm/models/demography/MarriageModelCapeTown.java b/useCases/capeTown/src/main/java/de/tum/bgu/msm/models/demography/MarriageModelCapeTown.java index e491533a6..9697aa136 100644 --- a/useCases/capeTown/src/main/java/de/tum/bgu/msm/models/demography/MarriageModelCapeTown.java +++ b/useCases/capeTown/src/main/java/de/tum/bgu/msm/models/demography/MarriageModelCapeTown.java @@ -362,7 +362,7 @@ private void movePerson(Person person1, Household moveTo) { if (!moveTo.equals(household1)) { householdDataManager.removePersonFromHousehold(person1); householdDataManager.addPersonToHousehold(person1, moveTo); - if (HouseholdUtil.checkIfAdultsPresent(household1)) { + if (HouseholdUtil.checkIfNoAdultsPresent(household1)) { moveRemainingChildren(household1, moveTo); } } diff --git a/useCases/maryland/src/main/java/de/tum/bgu/msm/models/MarriageModelMstm.java b/useCases/maryland/src/main/java/de/tum/bgu/msm/models/MarriageModelMstm.java index 110f6c195..118a91103 100644 --- a/useCases/maryland/src/main/java/de/tum/bgu/msm/models/MarriageModelMstm.java +++ b/useCases/maryland/src/main/java/de/tum/bgu/msm/models/MarriageModelMstm.java @@ -383,7 +383,7 @@ private void movePerson(Person person1, Household moveTo) { if (!moveTo.equals(household1)) { householdDataManager.removePersonFromHousehold(person1); householdDataManager.addPersonToHousehold(person1, moveTo); - if (HouseholdUtil.checkIfAdultsPresent(household1)) { + if (HouseholdUtil.checkIfNoAdultsPresent(household1)) { moveRemainingChildren(household1, moveTo); } } diff --git a/useCases/munich/src/main/java/de/tum/bgu/msm/models/MarriageModelMuc.java b/useCases/munich/src/main/java/de/tum/bgu/msm/models/MarriageModelMuc.java index f9dd0733e..520a1ddde 100644 --- a/useCases/munich/src/main/java/de/tum/bgu/msm/models/MarriageModelMuc.java +++ b/useCases/munich/src/main/java/de/tum/bgu/msm/models/MarriageModelMuc.java @@ -365,7 +365,7 @@ private void movePerson(Person person1, Household moveTo) { if (!moveTo.equals(household1)) { householdDataManager.removePersonFromHousehold(person1); householdDataManager.addPersonToHousehold(person1, moveTo); - if (HouseholdUtil.checkIfAdultsPresent(household1)) { + if (HouseholdUtil.checkIfNoAdultsPresent(household1)) { moveRemainingChildren(household1, moveTo); } }