21 package org.matsim.core.population.algorithms;
23 import org.apache.logging.log4j.LogManager;
24 import org.apache.logging.log4j.Logger;
46 import java.util.List;
47 import java.util.Optional;
49 import java.util.stream.Stream;
81 throw new RuntimeException(
"Expected carOnlyNetwork not to be multi-modal. Aborting!");
93 log.info(
"Network seems to be multimodal. XY2Links will only use car links.");
108 if (selectedPlan == null) {
110 log.warn(
"Person " + person.getId() +
" has no plans!");
118 boolean needsXY2Links =
false;
125 planLoop:
for (
PlanElement pe : plan.getPlanElements()) {
129 if (needsReComputation) {
130 needsXY2Links =
true;
138 default ->
throw new IllegalStateException(
"Unexpected PlanElement: " + pe);
142 this.xy2links.
run(plan);
145 this.router.
run(plan);
153 String errorMessage =
"Routing mode not set for leg :" + leg +
" of agent id " + person.getId().toString();
154 log.error( errorMessage );
208 Optional<Id<Link>> inconsistentLink = networkRoute.getLinkIds().stream()
215 if (inconsistentLink.isPresent()) {
216 String errorMessage =
"Route inconsistent with link modes for link: " + inconsistentLink.get() +
" Person " + person.getId() +
"; Leg '" + leg +
"'";
217 log.error(errorMessage +
"\n Consider cleaning inconsistent routes by using PopulationUtils.checkRouteModeAndReset()." +
218 "\n If this is intended, set the routing config parameter 'networkRouteConsistencyCheck' to 'disable'.");
235 List<Leg> legs = trip.getLegsOnly();
236 if (!legs.isEmpty()) {
239 for (
Leg leg : legs) {
242 if (existingRoutingMode == null) {
243 if (routingMode == null) {
246 String errorMessage =
"Found a mixed trip, some legs with routingMode and others without. " 247 +
"This is inconsistent. Agent id: " + plan.
getPerson().getId().toString();
248 log.error(errorMessage);
252 if (!routingMode.equals(existingRoutingMode)) {
253 String errorMessage =
"Found a trip whose legs have different routingModes. " 254 +
"This is inconsistent. Agent id: " + plan.
getPerson().getId().toString();
255 log.error(errorMessage);
262 if (routingMode == null) {
263 if (legs.size() == 1) {
265 routingMode = legs.get(0).getMode();
267 String errorMessage =
"Found a trip of only one leg of mode transit_walk. " 268 +
"This should not happen during simulation since transit_walk was replaced by walk and " 269 +
"routingMode. Agent id: " + plan.
getPerson().getId().toString();
270 log.error(errorMessage);
275 String errorMessage =
"Found a trip whose legs have no routingMode. " 276 +
"This is only allowed for (outdated) input plans, not during simulation (after PrepareForSim). Agent id: " 278 log.error(errorMessage);
void run(final Person person)
Map< Id< ActivityFacility >, ? extends ActivityFacility > getFacilities()
static String getRoutingMode(Leg leg)
void setDistance(final double distance)
void checkAndAddRoutingMode(Plan plan)
final NetworkConfigGroup network()
final ActivityFacilities activityFacilities
static boolean isMultimodal(final Network network)
final Id< Link > getEndLinkId()
void filter(final Network subNetwork, final Set< String > extractModes)
NetworkRouteConsistencyCheck getNetworkRouteConsistencyCheck()
Id< TransitRoute > getRouteId()
PersonPrepareForSim(final PlanAlgorithm router, final Scenario scenario, final Network carOnlyNetwork)
void checkModeConsistent(Person person, Leg leg)
boolean needsReComputation(Activity act)
PersonPrepareForSim(final PlanAlgorithm router, final Scenario scenario)
Id< TransitStopFacility > getEgressStopId()
static void setRoutingMode(Leg leg, String mode)
static Network createNetwork()
static final String transit_walk
void setRoute(Route route)
static List< Trip > getTrips(final Plan plan)
List< PlanElement > getPlanElements()
boolean needsReRoute(Person person, Leg leg)
Id< TransitStopFacility > getAccessStopId()
static double calcDistance(final NetworkRoute networkRoute, final double relPosOnDepartureLink, final double relPosOnArrivalLink, final Network network)
RoutingConfigGroup routing()
Map< Id< Link >, ? extends Link > getLinks()
Id< ActivityFacility > getFacilityId()
abstract void run(Plan plan)
ActivityFacilities getActivityFacilities()
void run(final Person person)
double getRelativePositionOfEntryExitOnLink()
final Id< Link > getStartLinkId()
final GlobalConfigGroup global()
final PlanAlgorithm router
Set< String > getAllowedModes()
Id< TransitLine > getLineId()
abstract T getSelectedPlan()
abstract List<? extends T > getPlans()