Skip to content

Commit

Permalink
feat: add functionality to treat interaction activity in withinday re…
Browse files Browse the repository at this point in the history
…planning (#2969)
  • Loading branch information
sebhoerl authored Dec 2, 2023
1 parent 1404d60 commit 820ef8f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

package org.matsim.core.mobsim.qsim.agents;

import java.util.ArrayList;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.TransportMode;
Expand All @@ -31,8 +34,7 @@
import org.matsim.core.mobsim.framework.MobsimAgent;
import org.matsim.core.mobsim.framework.PlanAgent;
import org.matsim.core.mobsim.qsim.ActivityEndRescheduler;

import java.util.List;
import org.matsim.core.population.PopulationUtils;

/**
* <p>
Expand Down Expand Up @@ -287,4 +289,20 @@ public static Activity findNextActivityWithType( MobsimAgent agent, String type
public static List<PlanElement> subList( MobsimAgent agent, int fromIndex, int toIndex) {
return getModifiablePlan(agent).getPlanElements().subList( fromIndex, toIndex ) ;
}

public static List<PlanElement> convertInteractionActivities(List<? extends PlanElement> elements) {
List<PlanElement> updatedElements = new ArrayList<>(elements.size());

for (int i = 0; i < elements.size(); i++) {
PlanElement element = elements.get(i);

if (element instanceof Activity) {
element = PopulationUtils.convertInteractionToStandardActivity((Activity) element);
}

updatedElements.add(element);
}

return updatedElements;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,14 @@ public static Activity createInteractionActivityFromCoordAndLinkId(String type,
act.setLinkId(linkId);
return act ;
}

public static Activity convertInteractionToStandardActivity(Activity activity) {
if (activity instanceof InteractionActivity) {
return createActivity(activity);
} else {
return activity;
}
}

public static Leg createLeg(String transportMode) {
return getFactory().createLeg(transportMode) ;
Expand Down

0 comments on commit 820ef8f

Please sign in to comment.