예제 #1
0
        public static void Calculate(string variableName, int mode, int pathType, double vot, int minute)
        {
            var samplingWeightsCalculator = new SamplingWeightsCalculator(variableName, mode, pathType, vot, minute);
            var segmentCount = samplingWeightsCalculator._segmentCount;

            Global.SegmentZones = new SegmentZone[segmentCount][];

            Parallel.For(0, segmentCount, new ParallelOptions {
                MaxDegreeOfParallelism = ParallelUtility.LargeDegreeOfParallelism
            }, segment => CalculateSegment(samplingWeightsCalculator, segment));
        }
예제 #2
0
        private static void CalculateSegment(SamplingWeightsCalculator samplingWeightsCalculator, int segment)
        {
            var file = new FileInfo(string.Format(Global.SamplingWeightsPath, segment));

            if (Global.Configuration.ShouldLoadSamplingWeightsFromFile && file.Exists)
            {
                Global.SegmentZones[segment] = LoadSamplingWeightsFromFile(file);

                return;
            }

            Global.SegmentZones[segment] = samplingWeightsCalculator.ComputeSegment(segment);

            if (Global.Configuration.ShouldLoadSamplingWeightsFromFile && !file.Exists)
            {
                SaveSamplingWeightsToFile(file, segment);
            }
        }