예제 #1
0
        private DoubleMatrix CreateTimeMatrix()
        {
            DoubleMatrix timeMatrix = new DoubleMatrix(_routeEntities.Count, _routeEntities.Count);

            for (int i = 0; i < timeMatrix.Rows; i++)
            {
                for (int j = 0; j < timeMatrix.Columns; j++)
                {
                    var start = _routeEntities[i];
                    var end   = _routeEntities[j];

                    RouteLeg leg = _routeLegs.Where(x => x.FromID == start.id && x.ToID == end.id).FirstOrDefault();

                    timeMatrix[i, j] = Convert.ToDouble(leg.DrivingTime / 60);
                }
            }

            return(timeMatrix);
        }
예제 #2
0
        private DoubleMatrix CreateDistanceMatrix()
        {
            DoubleMatrix distanceMatrix = new DoubleMatrix(_routeEntities.Count, _routeEntities.Count);

            for (int i = 0; i < distanceMatrix.Rows; i++)
            {
                for (int j = 0; j < distanceMatrix.Columns; j++)
                {
                    var start = _routeEntities[i];
                    var end   = _routeEntities[j];

                    RouteLeg leg = _routeLegs.Where(x => x.FromID == start.ID &&
                                                    x.FromTypeID == start.TypeID &&
                                                    x.ToID == end.ID && x.ToTypeID == end.TypeID).FirstOrDefault();

                    distanceMatrix[i, j] = Convert.ToDouble(leg.DrivingDistance);
                }
            }

            return(distanceMatrix);
        }