diff --git a/src/main/java/edu/kit/ifv/mobitopp/actitopp/Coordinator.java b/src/main/java/edu/kit/ifv/mobitopp/actitopp/Coordinator.java index b5ebe54..34d27a8 100644 --- a/src/main/java/edu/kit/ifv/mobitopp/actitopp/Coordinator.java +++ b/src/main/java/edu/kit/ifv/mobitopp/actitopp/Coordinator.java @@ -276,6 +276,9 @@ private void executeStep2(String id) step.disableAlternative("H"); } + // disable working activity if person is not allowed to work + if (!person.isAllowedToWork()) step.disableAlternative("W"); + if (Configuration.coordinated_modelling) { // if number of working days is achieved, disable W as alternative @@ -449,6 +452,9 @@ private void executeStep4(String id) // create step object DCDefaultModelStep step = new DCDefaultModelStep(id, fileBase, lookup, randomgenerator); + // disable working activity if person is not allowed to work + if (!person.isAllowedToWork()) step.disableAlternative("W"); + // if number of working days is achieved, disable W as alternative if ( person.getAttributefromMap("anztage_w") <= pattern.countDaysWithSpecificActivity(ActivityType.WORK) && @@ -595,6 +601,9 @@ private void executeStep6(String id) // create step object DCDefaultModelStep step = new DCDefaultModelStep(id, fileBase, lookup, randomgenerator); + // disable working activity if person is not allowed to work + if (!person.isAllowedToWork()) step.disableAlternative("W"); + // if number of working days is achieved, disable W as alternative if ( person.getAttributefromMap("anztage_w") <= pattern.countDaysWithSpecificActivity(ActivityType.WORK) && @@ -771,7 +780,7 @@ private void placeJointActivitiesIntoPattern() throws InvalidPatternException /* - * step 5: if joint type is 1 or 3, i.e., there is a joint trip included, the acitivity needs to be the first in the tour if the originating + * step 5: if joint type is 1 or 3, i.e., there is a joint trip included, the activity needs to be the first in the tour if the originating * one is the first on in the tour too (of the household member created the activity) * * for such cases, only use the remaining activities that are the first one in their tour @@ -2436,15 +2445,23 @@ private void selectWithWhomforJointActions() Map otherunmodeledpersinhh = new HashMap(); // first add all other household members otherunmodeledpersinhh.putAll(person.getHousehold().getHouseholdmembers()); - // delete all members that are already modeled or the person itself + List keyValues = new ArrayList<>(otherunmodeledpersinhh.keySet()); for (Integer key : keyValues) { ActitoppPerson tmpperson = otherunmodeledpersinhh.get(key); + // delete all members that are already modeled or the person itself if (tmpperson.getWeekPattern()!=null || tmpperson.getPersIndex()==person.getPersIndex()) { otherunmodeledpersinhh.remove(key); } + // remove person if activity is working and other person is not allowed to work + if (tmpactivity.getActivityType()==ActivityType.WORK && + tmpactivity.getJointStatus()!=JointStatus.JOINTTRIP && + !tmpperson.isAllowedToWork()) + { + otherunmodeledpersinhh.remove(key); + } } if (otherunmodeledpersinhh.size()>0) diff --git a/src/main/java/edu/kit/ifv/mobitopp/actitopp/HActivity.java b/src/main/java/edu/kit/ifv/mobitopp/actitopp/HActivity.java index dc5cd52..0021205 100644 --- a/src/main/java/edu/kit/ifv/mobitopp/actitopp/HActivity.java +++ b/src/main/java/edu/kit/ifv/mobitopp/actitopp/HActivity.java @@ -125,12 +125,14 @@ public void setIndex(int index) public ActivityType getActivityType() { assert ActivityType.FULLSET.contains(acttype) : "unknown activity type:" + acttype; + if (!getPerson().isAllowedToWork()) assert acttype!=ActivityType.WORK : "person is not allowed to work!"; return acttype; } public void setActivityType(ActivityType acttype) { assert ActivityType.FULLSET.contains(acttype) : "unknown activity type:" + acttype; + if (!getPerson().isAllowedToWork()) assert acttype!=ActivityType.WORK : "person is not allowed to work!"; this.acttype = acttype; }