Skip to content

Commit

Permalink
Fix vehicles using linked road when proba=0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
minhduc0711 committed Aug 9, 2021
1 parent 6419f14 commit 8e31eaa
Showing 1 changed file with 8 additions and 2 deletions.
Expand Up @@ -40,6 +40,7 @@
import simtools.gaml.extensions.traffic.RoadNodeSkill;
import simtools.gaml.extensions.traffic.RoadSkill;
import simtools.gaml.extensions.traffic.carfollowing.IDM;
import ummisco.gama.dev.utils.DEBUG;

public class MOBIL {
/**
Expand Down Expand Up @@ -72,8 +73,13 @@ public static ImmutablePair<Integer, Double> chooseLane(final IScope scope,
int numCurrentLanes = RoadSkill.getNumLanes(road);
int numLinkedLanes = (linkedRoad != null) ? RoadSkill.getNumLanes(linkedRoad) : 0;
int linkedLaneLimit = getLinkedLaneLimit(vehicle);
linkedLaneLimit = (linkedLaneLimit != -1 && numLinkedLanes > linkedLaneLimit) ?
linkedLaneLimit : numLinkedLanes;
if (linkedLaneLimit == -1) {
linkedLaneLimit = numLinkedLanes;
} else if (probaUseLinkedRoad == 0.0) {
linkedLaneLimit = 0;
} else {
linkedLaneLimit = Math.min(linkedLaneLimit, numLinkedLanes);
}
List<Integer> allowedLanes = getAllowedLanes(vehicle);
// Restrict the lane index when entering a new road
currentLowestLane = Math.min(currentLowestLane,
Expand Down

0 comments on commit 8e31eaa

Please sign in to comment.