Ejemplo n.º 1
0
        /// <summary>
        /// Calculates the timetable rating value.
        /// </summary>
        /// <param name="tt">The timetable.</param>
        /// <returns>The rating value.</returns>
        public static int calculateTimetableRatingValue(Timetable tt)
        {
            int ratingValue = 0;

            List <Transfer> transfers = FinalInput.getInstance().getCacheContent();

            foreach (Transfer transfer in transfers)
            {
                int value = calculateTransfer(tt, transfer);
                ratingValue += value;
            }

            return(ratingValue);
        }
        private void buttonListOfGroupsOfConnectionsNext_Click(object sender, EventArgs e)
        {
            buttonNextStarted();
            //TODO: check generation
            try
            {
                FinalInput.getInstance().createTransfers();
                prepareListViewListOfTransfers();
            }
            catch
            {
                ErrorMessageBoxUtil.ShowError("Could not extract transfers from the given list of connections.");
                buttonNextEnded();
                return;
            }

            buttonNextEnded();
            selectTab(tabPageListOfTransfers);
        }
        //----------------------------------------------
        // Methods for preparing FINAL INPUT
        //----------------------------------------------

        private void prepareListViewListOfGroupsOfConnections()
        {
            listViewFinalInput.BeginUpdate();
            listViewFinalInput.Items.Clear();

            // createConstraintSet new final input
            FinalInput.getInstance().createGroupsOfConnection();

            // loop over all groups
            foreach (GroupOfConnections group in FinalInput.getInstance().getGroupsOfConnections())
            {
                ListViewItem lvi = new ListViewItem();
                lvi.Text = group.LinesOfConnectionString;
                lvi.Tag  = group.LinesOfConnectionString;

                lvi.SubItems.Add(group.ChangingStationsString);
                lvi.SubItems.Add(group.calculatePassengers().ToString());

                listViewFinalInput.Items.Add(lvi);
            }

            listViewFinalInput.EndUpdate();
        }
        private void prepareListViewListOfTransfers()
        {
            // retrieve transfers
            List <Transfer> tranfers = FinalInput.getInstance().getCacheContent();

            listViewListOfTransfers.BeginUpdate();

            listViewListOfTransfers.Items.Clear();

            foreach (Transfer tranfer in tranfers)
            {
                ListViewItem lvi = new ListViewItem();
                lvi.Text = tranfer.OffLine.LineNumber.ToString();
                lvi.Tag  = tranfer.OffLine.LineNumber.ToString() + "->" + tranfer.OnLine.LineNumber.ToString();

                lvi.SubItems.Add(tranfer.OnLine.LineNumber.ToString());
                lvi.SubItems.Add(tranfer.Station.Name);
                lvi.SubItems.Add(tranfer.Passengers.ToString());

                listViewListOfTransfers.Items.Add(lvi);
            }

            listViewListOfTransfers.EndUpdate();
        }
        //--------------------------------------------
        // button NEXT list of station
        //--------------------------------------------

        private void buttonListOfStationNext_Click(object sender, EventArgs e)
        {
            buttonNextStarted();
            ShortestPathAlgoritm shortestPathAlgorithm;

            try
            {
                // activate algorithm
                shortestPathAlgorithm = ShortestPathAlgoritm.getInstance();
                shortestPathAlgorithm.calculateShortestPath();
            }
            catch
            {
                ErrorMessageBoxUtil.ShowError("Error in the shortest path algorithm processing.");
                buttonNextEnded();
                return;
            }

            try
            {
                shortestPathAlgorithm.generateAllTrainConnections();
            }
            catch
            {
                ErrorMessageBoxUtil.ShowError("Could not generate the list of connections.");
                buttonNextEnded();
                return;
            }

            try
            {
                // prepare list view
                prepareListViewListOfConnections();
            }
            catch
            {
                ErrorMessageBoxUtil.ShowError("Could not prepare the list of connections.");
                buttonNextEnded();
                return;
            }

            // TODO: added coz one place of processing data
            try
            {
                prepareListViewListOfGroupsOfConnections();
            }
            catch
            {
                ErrorMessageBoxUtil.ShowError("Error in groupping connections process.");
                buttonNextEnded();
                return;
            }

            // TODO: added coz one place of processing data
            try
            {
                FinalInput.getInstance().createTransfers();
                prepareListViewListOfTransfers();
            }
            catch
            {
                ErrorMessageBoxUtil.ShowError("Could not extract transfers from the given list of connections.");
                buttonNextEnded();
                return;
            }


            // open particular tab
            selectTab(tabPageListOfConncetions);
            buttonNextEnded();
        }