Skip to content

Commit

Permalink
minor bugfixes to disable working activities if they are not allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
timhilgert committed Oct 21, 2019
1 parent 8ce5bb4 commit f3a7f36
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/main/java/edu/kit/ifv/mobitopp/actitopp/Coordinator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) &&
Expand Down Expand Up @@ -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) &&
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2436,15 +2445,23 @@ private void selectWithWhomforJointActions()
Map<Integer,ActitoppPerson> otherunmodeledpersinhh = new HashMap<Integer, ActitoppPerson>();
// first add all other household members
otherunmodeledpersinhh.putAll(person.getHousehold().getHouseholdmembers());
// delete all members that are already modeled or the person itself

List<Integer> 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)
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/edu/kit/ifv/mobitopp/actitopp/HActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit f3a7f36

Please sign in to comment.