Exemple #1
0
        public static void TripComputation()
        {
            var stopwatch = new Stopwatch();
            var lattice   = ComputeLattice();

            // Data retrival from DB
            foreach (var dayOfWeek in (DayOfWeek[])Enum.GetValues(typeof(DayOfWeek)))
            {
                //var dayOfWeek = DayOfWeek.Friday;
                Console.WriteLine("=========== Day {0} ==========\n", dayOfWeek);

                //var Trips = GenerateTrips(lattice, dayOfWeek);
                var Trips = ImportTripDataFromFile(string.Format(@".\{0}Trips-2015.dat", dayOfWeek));
                TripStats.DistributionOfRequests(Trips, dayOfWeek.ToString());

                #region Stats
                Console.WriteLine("# of Trips: {0}", Trips.Count());
                Console.WriteLine("=========== End Of Process ===========\n");
                #endregion
            }
        }
Exemple #2
0
        public static void RunCommand(EnumCommands iCommand)
        {
            if (Commands.ContainsKey(iCommand))
            {
                switch (iCommand)
                {
                case EnumCommands.ComputeLattice:
                    printLn(">>Compute Lattice");
                    lattice = ComputeLattice();
                    break;

                case EnumCommands.GetRoute:
                    printLn(">>Get Route");
                    printLn(">>Source Location (lat, long):");
                    double[] source = ParseLocation(Console.ReadLine());

                    printLn(">>Destination Location (lat, long):");
                    double[] destination = ParseLocation(Console.ReadLine());

                    string result = RoutingService.Service.GetRoute(source, destination);
                    string path   = Path.Combine(saveFile, "route.geojson");
                    File.WriteAllText(path, result);
                    printLn("Route saved to : " + path);
                    break;

                case EnumCommands.GetTrips:
                    if (lattice == null)
                    {
                        RunCommand(EnumCommands.ComputeLattice);
                    }

                    printLn(">>Get Trips");
                    trips = GetTrips(lattice);
                    break;

                case EnumCommands.ComputeProbDist:
                    if (trips.Count == 0)
                    {
                        RunCommand(EnumCommands.GetTrips);
                    }
                    if (trips.Count > 0)
                    {
                        printLn(">>Save distribution results As:");
                        string file = Console.ReadLine();
                        printLn(">>Compute Probability Distribution");
                        TripStats.DistributionOfRequests(trips, file);
                    }
                    else
                    {
                        printLn("No trips available. Please check parameters.");
                    }
                    break;

                case EnumCommands.SaveAsBinary:
                    printLn(">>Enter File Name:");
                    string binfile = Console.ReadLine();
                    printLn(">Saving Trip Data<");
                    //TODO
                    //ToBinary.CsvToBinary(trips, Path.Combine(saveFile, binfile + ".dat"));
                    printLn(string.Format("{0} Trips Saved", trips.Count));
                    break;

                case EnumCommands.SaveAsCSV:
                    printLn(">>Enter File Name:");
                    string csvfile = Console.ReadLine();
                    printLn(">Saving Raw Trip Data<");
                    TripFunctions.Save(tripsDB, Path.Combine(saveFile, csvfile + ".csv"));
                    printLn(string.Format("{0} Trips Saved", tripsDB.Count));
                    break;

                default:
                    break;
                }
            }
        }