diff --git a/src/main/java/playground/amit/Delhi/overlap/algo/elements/SegmentalOverlap.java b/src/main/java/playground/amit/Delhi/overlap/algo/elements/SegmentalOverlap.java index 31c8f1c0..e8b24a4f 100644 --- a/src/main/java/playground/amit/Delhi/overlap/algo/elements/SegmentalOverlap.java +++ b/src/main/java/playground/amit/Delhi/overlap/algo/elements/SegmentalOverlap.java @@ -56,7 +56,7 @@ void remove(String vehicleNumber, String tripId){ } public int getCount() { - return counter; + return Math.min(counter - OverlapOptimizer.MIN_DEVICES, 1); } public Tuple getSelfTripVehicleRoute() { diff --git a/src/main/java/playground/amit/Delhi/overlap/algo/optimizer/OverlapOptimizer.java b/src/main/java/playground/amit/Delhi/overlap/algo/optimizer/OverlapOptimizer.java index 6d60ff7d..d04f91c7 100644 --- a/src/main/java/playground/amit/Delhi/overlap/algo/optimizer/OverlapOptimizer.java +++ b/src/main/java/playground/amit/Delhi/overlap/algo/optimizer/OverlapOptimizer.java @@ -22,6 +22,7 @@ public class OverlapOptimizer { public static final Logger LOG = LogManager.getLogger(OverlapOptimizer.class); + public static int MIN_DEVICES; // public enum OptimizingElements{vehicle, GTFS} @@ -34,8 +35,9 @@ public class OverlapOptimizer { private final SigmoidFunction sigmoidFunction; private double totalNetworkRouteLength= Double.NaN; - public OverlapOptimizer(int timebinSize, String outputPath, SigmoidFunction sigmoidFunction){ + public OverlapOptimizer(int timebinSize, String outputPath, SigmoidFunction sigmoidFunction, int minDevicesPerTimeBin){ this.spatialOverlap = new SpatialOverlap(timebinSize); + MIN_DEVICES = minDevicesPerTimeBin; this.outputPath = outputPath; this.sigmoidFunction = sigmoidFunction; String date = new SimpleDateFormat("dd-MM-yy").format(Calendar.getInstance().getTime()); diff --git a/src/main/java/playground/amit/Delhi/overlap/gtfs/DelhiGTFSOverlapIdentifier.java b/src/main/java/playground/amit/Delhi/overlap/gtfs/DelhiGTFSOverlapIdentifier.java index ea27f370..d7340b34 100644 --- a/src/main/java/playground/amit/Delhi/overlap/gtfs/DelhiGTFSOverlapIdentifier.java +++ b/src/main/java/playground/amit/Delhi/overlap/gtfs/DelhiGTFSOverlapIdentifier.java @@ -11,9 +11,13 @@ public class DelhiGTFSOverlapIdentifier { public static void main(String[] args) { String GTFS_PATH = "..\\..\\repos\\sl-repos\\shared\\data\\project_data\\delhi\\gtfs_files\\\\12052021\\GTFS_DIMTS_12052021.zip"; int timebinSize = 24*60*60; + int freqDataPointsDevice = 1; + int minDataPointsPerTimeBin = 40; // configurable + int minDevicesPerTimeBin = (int) Math.ceil( (freqDataPointsDevice* timebinSize/60) / minDataPointsPerTimeBin ); + String outFilePath = "..\\..\\repos\\sl-repos\\shared\\data\\project_data\\delhi\\gtfs_files\\25052021\\gtfs_overlap_prob_24hTimebin_excludingSelfTrips\\"; - OverlapOptimizer optimizer = new OverlapOptimizer(timebinSize, outFilePath, SigmoidFunction.BipolarSigmoid); + OverlapOptimizer optimizer = new OverlapOptimizer(timebinSize, outFilePath, SigmoidFunction.BipolarSigmoid, minDevicesPerTimeBin); optimizer.initializeWithGTFS(GTFS_PATH); // optimizer.run(10); optimizer.optimizeTillProb(0.0); diff --git a/src/main/java/playground/amit/Delhi/overlap/vehicles/DelhiVehicleOverlapIdentifier.java b/src/main/java/playground/amit/Delhi/overlap/vehicles/DelhiVehicleOverlapIdentifier.java index 2f2e6e7a..fbd62ff4 100644 --- a/src/main/java/playground/amit/Delhi/overlap/vehicles/DelhiVehicleOverlapIdentifier.java +++ b/src/main/java/playground/amit/Delhi/overlap/vehicles/DelhiVehicleOverlapIdentifier.java @@ -9,13 +9,22 @@ */ public class DelhiVehicleOverlapIdentifier { + + + public static void main(String[] args) { String GTFS_PATH = FileUtils.SVN_PROJECT_DATA_DRIVE+"\\delhi\\gtfs_files\\\\12052021\\GTFS_DIMTS_12052021.zip"; String vehicles_file = FileUtils.SVN_PROJECT_DATA_DRIVE+"\\delhi\\dimts\\Mar2021\\VehicleSampleData.txt"; + int timebinSize = 24*60*60; + int freqDataPointsDevice = 1; + int minDataPointsPerTimeBin = 40; // configurable + int minDevicesPerTimeBin = (int) Math.ceil( (freqDataPointsDevice* timebinSize) / minDataPointsPerTimeBin ); + + String outFilePath = FileUtils.SVN_PROJECT_DATA_DRIVE+"\\delhi\\gtfs_files\\02122021\\vehicles_overlap_prob_24hTimebin_excludingSelfTrips\\"; - OverlapOptimizer optimizer = new OverlapOptimizer(timebinSize, outFilePath, SigmoidFunction.BipolarSigmoid); + OverlapOptimizer optimizer = new OverlapOptimizer(timebinSize, outFilePath, SigmoidFunction.BipolarSigmoid, minDevicesPerTimeBin); optimizer.initializeWithGTFSAndVehicles(GTFS_PATH, vehicles_file); // optimizer.run(10); optimizer.optimizeTillProb(0.0);