Commit 9059ec66 authored by Julian Zobel's avatar Julian Zobel
Browse files

Added a 1percent chance that an alternative route is taken, if available

parent 7698d9d7
......@@ -26,6 +26,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import com.graphhopper.GHRequest;
......@@ -43,6 +44,7 @@ import com.graphhopper.util.DistanceCalc2D;
import com.graphhopper.util.EdgeIteratorState;
import com.graphhopper.util.Instruction;
import com.graphhopper.util.InstructionList;
import com.graphhopper.util.Parameters;
import com.graphhopper.util.Parameters.Routing;
import com.graphhopper.util.PointList;
import com.graphhopper.util.shapes.GHPoint;
......@@ -50,6 +52,7 @@ import com.graphhopper.util.shapes.GHPoint;
import de.tud.kom.p2psim.api.topology.Topology;
import de.tud.kom.p2psim.api.topology.movement.SimLocationActuator;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.GPSCalculation;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.ModularMovementModelViz;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.RouteSensorComponent;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.util.Either;
......@@ -198,7 +201,9 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
// https://github.com/graphhopper/graphhopper/blob/master/docs/web/api-doc.md#flexible
if(blockedAreas != null && !blockedAreas.isEmpty()) {
req.getHints().put(Routing.BLOCK_AREA, blockedAreas);
}
}
req.setAlgorithm(Parameters.Algorithms.ALT_ROUTE);
GHResponse rsp = hopper.route(req);
......@@ -214,7 +219,24 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
currentRoutes.put(comp, trajectory);
} else {
PointList pointList = rsp.getBest().getPoints();
if(rsp.hasAlternatives()) {
// System.out.println(" >>");
// for (PathWrapper pw : rsp.getAll()) {
// System.out.println(pw.getDistance());
// ModularMovementModelViz.paths.add(pw.getPoints());
// }
// System.out.println(" ");
if(Math.random() < 0.01) {
pointList = rsp.getAll().get(1).getPoints();
}
}
//PointList pointList = rsp.getBest().getPoints();
if (isCalculateRouteSegments()) {
/*
......
......@@ -86,7 +86,7 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedAssi
this.roamingStates.put(comp, roamingTransitionState.PAUSE);
// schedule roaming
Event.scheduleWithDelay(gaussianDistributionPauseTime(Time.MINUTE, Time.MINUTE), this, comp, EVENT_ROAMING_PAUSE_ENDED);
Event.scheduleWithDelay(gaussianDistributionPauseTime(5 * Time.MINUTE, Time.MINUTE), this, comp, EVENT_ROAMING_PAUSE_ENDED);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment