public SenderTests()
        {
            CsvFileReader csvReader    = new CsvFileReader();
            List <string> dataList     = csvReader.DataList;
            DataSplitter  splittedData = new DataSplitter(dataList);

            DateList = splittedData.DateList;
            TimeList = splittedData.TimeList;
        }
示例#2
0
        private List <RowElement> SplitData(DataTable data, FormData formData)
        {
            var dataSplitter = new DataSplitter(data,
                                                formData.ItemsInRow,
                                                formData.ColumnNumber,
                                                formData.ColumnName);

            dataSplitter.SplitData();

            return(dataSplitter.ListOfRows);
        }
示例#3
0
        private void InitFile(string filePath)
        {
            var ds   = new DataSplitter();
            var data = ds.ReadFile(filePath);

            this.pager = new BitmapPager(data, this.pageSize, this.scrollSize);

            var bm = pager.GetCurrent();

            this.DisplayBitmap(bm);

            this.Prev.IsEnabled = false;
            this.Next.IsEnabled = true;
        }
示例#4
0
        public void Setup()
        {
            //Make a fake Transponder Data Receiver
            _fakeTransponderReceiver = Substitute.For <ITransponderReceiver>();

            //Inject the fake
            _uut = new DataSplitter(_fakeTransponderReceiver);

            receivedArgs   = null;
            NumberOfEvents = 0;


            _uut.DataReceivedEvent += (s, a) =>
            {
                receivedArgs = a;
                NumberOfEvents++;
            };
        }
示例#5
0
        private static void RunTaxiTripsInnerProduct(Random random)
        {
            // NYC Coords
            // Big Square
            const double minLat  = 40.49;
            const double maxLat  = 40.91;
            const double minLong = -74.26;
            const double maxLong = -73.66;
            // Small Square

            /*const double minLat = 40.623;
             * const double maxLat = 40.846;
             * const double minLong = -74.04;
             * const double maxLong = -73.74;*/

            var nycCityRegion = new CityRegion(minLat, maxLat, minLong, maxLong);
            //var          sqrtNumOfNodes   = 5;
            //var          sqrtVectorLength = 10;
            var hoursInWindow      = 24;
            var iterations         = 750;
            var tipSplitter        = new DataSplitter <TaxiTripEntry>(entry => entry.Tip > 0, "Tip");
            var vendorSplitter     = new DataSplitter <TaxiTripEntry>(entry => entry.TaxiVendor == TaxiVendor.CMT, "Vendor");
            var paymentSplitter    = new DataSplitter <TaxiTripEntry>(entry => entry.PaymentType == PaymentType.Cash, "PaymentType");
            var passengersSplitter = new DataSplitter <TaxiTripEntry>(entry => entry.NumOfPassangers > 1, "Passengers");
            var splitters          = ArrayUtils.Init(tipSplitter, vendorSplitter, paymentSplitter, passengersSplitter);
            var approximation      = new MultiplicativeUpperLowerApproximation(0.7, 1.3);
            var chosenSplitter     = vendorSplitter;


            foreach (var sqrtVectorLength in ArrayUtils.Init(101))
            {
                // foreach (var sqrtVectorLength in ArrayUtils.Init(35, 61, 86, 100, 111, 122, 132, 141, 158, 173, 187, 200, 212, 223))
                //foreach (var sqrtNumOfNodes in ArrayUtils.Init(6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20))
                foreach (var sqrtNumOfNodes in ArrayUtils.Init(8))
                {
                    InnerProductRunner.RunTaxiTrips(random, iterations, sqrtNumOfNodes, hoursInWindow, approximation,
                                                    sqrtVectorLength, chosenSplitter, nycCityRegion, taxiBinDataPath, resultDir);
                }
            }
        }
示例#6
0
        private List <LineSegment> GetCuttingSegments()
        {
            double startLen    = 0;
            double startSpeed  = 0;
            double stopLen     = 0;
            double stopSpeed   = 0;
            double normalSpeed = this.layerPara.CutSpeed;

            if (this.layerPara.IsSlowStart)
            {
                startSpeed = this.layerPara.SlowStartSpeed;
                if (startSpeed > 0)
                {
                    startLen = this.layerPara.SlowStartDistance;
                }
            }
            if (this.layerPara.IsSlowStop)
            {
                stopSpeed = this.layerPara.SlowStopSpeed;
                if (stopSpeed > 0)
                {
                    stopLen = this.layerPara.SlowStopDistance;
                }
            }

            var    items         = base.GetDataCollection();
            var    segments      = new List <LineSegment>();
            var    spiltter      = new DataSplitter(items, startLen, stopLen);
            double accelebration = GlobalModel.Params.LayerConfig.ProcessAcceleratedSpeed;

            if (spiltter.IsValid)
            {
                var part1 = spiltter.GetStartData();
                if (part1.Any())
                {
                    var tmp = MovementUtil.GetLineSegments(part1, startSpeed, accelebration);
                    if (tmp.Any())
                    {
                        segments.AddRange(tmp);
                    }
                }
                var part2 = spiltter.GetMiddleData();
                if (part2.Any())
                {
                    segments.AddRange(MovementUtil.GetLineSegments(part2, normalSpeed, accelebration));
                }
                var part3 = spiltter.GetEndData();
                if (part3.Any())
                {
                    var tmp = MovementUtil.GetLineSegments(part3, stopSpeed, accelebration);
                    if (tmp.Any())
                    {
                        segments.AddRange(tmp);
                    }
                }
            }
            else
            {
                segments.AddRange(MovementUtil.GetLineSegments(items, normalSpeed, accelebration));
            }

            return(segments);
        }
        public static void RunTaxiTrips(Random random, int iterations, int sqrtNumOfNodes, int hoursInWindow, ApproximationType approximation, int sqrtVectorLength, DataSplitter <TaxiTripEntry> splitter, CityRegion cityRegion, string taxiBinDataPath, string resultDir)
        {
            var vectorLength = 2 * sqrtVectorLength * sqrtVectorLength;
            var numOfNodes   = sqrtNumOfNodes * sqrtNumOfNodes;
            var resultPath   =
                PathBuilder.Create(resultDir, "InnerProduct")
                .AddProperty("Dataset", "TaxiTrips")
                .AddProperty("Nodes", numOfNodes.ToString())
                .AddProperty("VectorLength", vectorLength.ToString())
                .AddProperty("Window", hoursInWindow.ToString())
                .AddProperty("Iterations", iterations.ToString())
                .AddProperty("Approximation", approximation.AsString())
                .AddProperty("DataSplit", splitter.Name)
                .ToPath("csv");

            using (var resultCsvFile = AutoFlushedTextFile.Create(resultPath, AccumaltedResult.Header(numOfNodes)))
                using (var binaryReader = new BinaryReader(File.OpenRead(taxiBinDataPath)))
                {
                    var innerProductFunction = new InnerProductFunction(vectorLength);
                    var taxiTrips            = TaxiTripEntry.FromBinary(binaryReader);
                    var windowManager        = TaxiTripsWindowManger.Init(hoursInWindow, sqrtNumOfNodes, sqrtVectorLength, splitter, cityRegion, taxiTrips);
                    var initVectors          = windowManager.GetCurrentVectors();
                    var multiRunner          = MultiRunner.InitAll(initVectors, numOfNodes, vectorLength, approximation, innerProductFunction.MonitoredFunction);
                    for (int i = 0; i < iterations; i++)
                    {
                        if (!windowManager.TakeStep())
                        {
                            break;
                        }
                        var changeVectors = windowManager.GetChangeVector();
                        multiRunner.Run(changeVectors, random, false)
                        .Select(r => r.AsCsvString())
                        .ForEach(resultCsvFile.WriteLine);
                    }
                }
        }