Пример #1
0
        /****************************************/
        // TrainConnections' related methods
        /****************************************/

        /// <summary>
        /// Funtion creates trainConnecion off path of (optimalized) edges.
        /// </summary>
        /// <param name="edges"></param>
        /// <returns></returns>
        public static TrainConnection createTrainConnection(List <Edge> edges)
        {
            // if there is path with length 0 or list of edges doesn't exist
            if (edges.Count.Equals(0) || edges.Equals(null))
            {
                return(null);
            }
            // determine start and destination station
            TrainStation from = edges[0].FromStation;
            TrainStation to   = edges[edges.Count - 1].ToStation;

            // createConstraintSet new connection with start and destination stattion, and path of edges
            TrainConnection connection = new TrainConnection(from, to, edges);

            // randomizeTimetable changing station and set them in connection
            connection.setChangingStation(TrainConnection.generateChangingStation(edges));
            // randomizeTimetable variableLines of connection and set them in connection
            connection.setLinesOfConnection(TrainConnection.generateLinesOfConnection(edges));

            // calculate other variabiles
            connection.calculateDistance();
            connection.calculatePassengers();
            connection.calculateTime();

            return(connection);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Stage"/> class.
 /// </summary>
 /// <param name="from">From station.</param>
 /// <param name="to">To station.</param>
 /// <param name="line_">By the line.</param>
 public Stage(TrainStation from, TrainStation to, TrainLine line_)
 {
     edges       = FloydWarshallUtil.createEdges(line_, from, to);
     line        = line_;
     fromStation = from;
     toStation   = to;
     time        = TrainConnection.calculateTime(edges);
     distance    = TrainConnection.calculateDistance(edges);
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Stage"/> class.
 /// </summary>
 /// <param name="edges_">The list of edges.</param>
 public Stage(List <Edge> edges_)
 {
     edges       = edges_;
     line        = TrainLineCache.getInstance().getCacheContentOnNumber(edges[0].Line);
     fromStation = edges[0].FromStation;
     toStation   = edges[edges.Count - 1].ToStation;
     time        = TrainConnection.calculateTime(edges);
     distance    = TrainConnection.calculateDistance(edges);
 }