コード例 #1
0
        public double ComputeAverageSpeed(MetricPath path)
        {
            double averageSpeed = 0;

            double roadLength = path.GetLength();
            double roadLengthCoveredInEachSegment = roadLength / numberOfLines;
            double totalTravellingTime            = 0;

            for (int ii = 0; ii < numberOfLines; ii++)
            {
                double entrySpeed      = this.SegmentLinearSpeedProfileList[0].LinearBezierSplineList[ii].P0.CoordinateList[0];
                double exitSpeed       = this.SegmentLinearSpeedProfileList[0].LinearBezierSplineList[ii].P1.CoordinateList[0];
                double speedDifference = exitSpeed - entrySpeed;

                if (Math.Abs(speedDifference) < double.Epsilon)
                {
                    totalTravellingTime += roadLengthCoveredInEachSegment / entrySpeed;
                }
                else
                {
                    totalTravellingTime += Math.Log(exitSpeed / entrySpeed) * roadLengthCoveredInEachSegment / speedDifference;
                }
            }

            averageSpeed = roadLength / totalTravellingTime;

            return(averageSpeed);
        }
コード例 #2
0
 public void GenerateConstant(MetricPath path, double speed)
 {
     segmentLinearSpeedProfileList = new List <SegmentLinearSpeedProfile>();
     foreach (MapSegment mapSegment in path.MapSegmentList)
     {
         SegmentLinearSpeedProfile segmentLinearSpeedProfile = new SegmentLinearSpeedProfile();
         segmentLinearSpeedProfile.GenerateConstant(mapSegment, speed, numberOfLines);
         segmentLinearSpeedProfileList.Add(segmentLinearSpeedProfile);
     }
 }
コード例 #3
0
 public void Generate(MetricPath path, List <double> speedList)
 {
     segmentLinearSpeedProfileList = new List <SegmentLinearSpeedProfile>();
     foreach (MapSegment mapSegment in path.MapSegmentList)
     {
         SegmentLinearSpeedProfile segmentLinearSpeedProfile = new SegmentLinearSpeedProfile();
         segmentLinearSpeedProfile.Generate(speedList, numberOfLines);
         segmentLinearSpeedProfileList.Add(segmentLinearSpeedProfile);
     }
 }
コード例 #4
0
        public bool IsFiltered(List <CounterFilter> filters)
        {
            foreach (CounterFilter filter in filters)
            {
                if (MetricPath.Contains(filter.Expression))
                {
                    return(true);
                }
            }

            return(false);
        }
        public void RunSynchronous(PiecewiseLinearSpeedProfileOptimizationSettings optimizationSettings,
                                   Random randomNumberGenerator, double optimizationTime, MetricMap metricMap, MetricPath metricPath)
        {
            this.optimizationTime      = optimizationTime;
            this.optimizationSettings  = optimizationSettings;
            this.metricMap             = metricMap;
            this.metricPath            = metricPath;
            this.randomNumberGenerator = randomNumberGenerator;

            stopWatch = new Stopwatch();
            OptimizationLoop();
        }
コード例 #6
0
        private void GenerateMetricPath()
        {
            // Generate path:
            TopologicalPathGenerator topologicalPathGenerator = new Dijkstra();
            int             topologicalStartPointID           = 0;
            int             topologicalEndPointID             = metricMap.RoadPointList.Count - 1;
            TopologicalPath topologicalPath = topologicalPathGenerator.GenerateShortestPath(metricMap, topologicalStartPointID, topologicalEndPointID);

            metricPath = new MetricPath();
            metricPath.Generate(topologicalPath, metricMap);
            metricPath.GenerateMetricPathPointList(0.001, 0.5, 0.01, 0.1); // Ugly MW ToDo: Parameterize
            metricPath.ComputeSegmentLengths(0.1);
        }
        public void Run(PiecewiseLinearSpeedProfileOptimizationSettings optimizationSettings,
                        Random randomNumberGenerator, double optimizationTime, MetricMap metricMap, MetricPath metricPath)
        {
            this.optimizationTime      = optimizationTime;
            this.optimizationSettings  = optimizationSettings;
            this.metricMap             = metricMap;
            this.metricPath            = metricPath;
            this.randomNumberGenerator = randomNumberGenerator;

            stopWatch          = new Stopwatch();
            optimizationThread = new Thread(new ThreadStart(OptimizationLoop));
            optimizationThread.Start();
        }
コード例 #8
0
        public PiecewiseLinearSpeedProfile(MetricPath path, int numberOfLines)
        {
            this.numberOfLines   = numberOfLines;
            connectionPointsList = new List <List <double> >();

            int    numberOfPathPoints           = path.DistanceList.Count;
            double roadLength                   = path.GetLength();
            double distanceCoveredInEachSection = roadLength / numberOfLines;
            double distanceCoveredSoFar         = 0;

            for (int ii = 0; ii < numberOfLines; ii++)
            {
                distanceCoveredSoFar += distanceCoveredInEachSection;
                List <double> linearSectionInfoList = new List <double>();
                linearSectionInfoList.Add(ii);
                linearSectionInfoList.Add(distanceCoveredSoFar);
                connectionPointsList.Add(linearSectionInfoList);
            }
        }
コード例 #9
0
 public void Increment(MetricPath path = default(MetricPath)) =>
 AppendWrite(current => current + 1, path);
コード例 #10
0
 public void IncrementBy(int count, MetricPath path = default(MetricPath)) =>
 AppendWrite(current => current + count, path);
コード例 #11
0
 public void AssignMetricPath(MetricPath metricPath)
 {
     this.metricPath = metricPath;
 }