Example #1
0
        private void Browse_Click(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                string content  = File.ReadAllText(filename);
                wiadomosc.Text = content;

                //CommunicationModule cm = new CommunicationModule("127.0.0.1", 5555, 5000);
                //var socket = cm.SetupClient();
                //cm.Connect(socket);

                this.solveRequestMessage = new SolveRequestMessage()
                {
                    Data           = CommunicationModule.ConvertStringToData(content),
                    ProblemType    = "DVRP",
                    SolvingTimeout = long.Parse(this.timeoutTextBox.Text)
                };

                this.computationalClient = new ComputationClient("127.0.0.1", 5555, 2000);
                //BaseNode bn = new BaseNode();

                //cm.SendData(bn.SerializeMessage(solveRequestMessage), socket);
                //cm.CloseSocket(socket);
            }
        }
        public void SolveProblemTest17D()
        {
            string testData = System.IO.File.ReadAllText(@"DVRPTestData\okul17D.vrp");

            byte[]         problemData = CommunicationModule.ConvertStringToData(testData);
            TaskSolverDVRP taskSolver  = new TaskSolverDVRP(problemData);

            byte[][] division  = taskSolver.DivideProblem(6);
            byte[][] solutions = new byte[6][];
            for (int i = 0; i <= 6; i++)
            {
                int[][] partialData = DVRPHelper.ParsePartialProblemData(division[i]);
                solutions[i] = taskSolver.Solve(division[i], new TimeSpan());
            }
            taskSolver.MergeSolution(solutions);
            DVRPPartialSolution finalSol = DVRPPartialSolution.Parse2FinalSol(CommunicationModule.ConvertDataToString(taskSolver.Solution, taskSolver.Solution.Length), taskSolver.Dvrp);

            Assert.IsTrue(Math.Abs(finalSol.pathLen - 1089) < 1);
        }
        public void DivideProblemTest()
        {
            string testData = System.IO.File.ReadAllText(@"DVRPTestData\okul12D.vrp");

            byte[]         problemData = CommunicationModule.ConvertStringToData(testData);
            TaskSolverDVRP taskSolver  = new TaskSolverDVRP(problemData);

            byte[][] result       = taskSolver.DivideProblem(10);
            string   fistNodeText = System.IO.File.ReadAllText(@"DVRPTestData\AllTxtFiles.txt");

            int[][][] firstNodeTab  = DVRP.ParseData(CommunicationModule.ConvertStringToData(fistNodeText));
            int[][][] firstNodeTest = DVRP.ParseData(result[0]);

            bool   ok  = true;
            string msg = "";

            if (firstNodeTab.Length == firstNodeTest.Length)
            {
                for (int i = 0; i < firstNodeTab.Length; i++)
                {
                    if (firstNodeTab[i].Length == firstNodeTest[i].Length)
                    {
                        for (int j = 0; j < firstNodeTab[i].Length; j++)
                        {
                            if (firstNodeTab[i][j].Length == firstNodeTest[i][j].Length)
                            {
                                for (int k = 0; k < firstNodeTab[i][j].Length; k++)
                                {
                                    if (firstNodeTab[i][j][k] != firstNodeTest[i][j][k])
                                    {
                                        msg = "firstNodeTab[i][j][k] != firstNodeTest[i][j][k]";
                                        ok  = false;
                                        break;
                                    }
                                }
                                if (!ok)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                msg = "firstNodeTab[i][j].Length != firstNodeTest[i][j].Length";
                                ok  = false;
                                break;
                            }
                        }
                        if (!ok)
                        {
                            break;
                        }
                    }
                    else
                    {
                        msg = "firstNodeTab[i].Length == firstNodeTest.Length";
                        ok  = false;
                        break;
                    }
                }
            }
            else
            {
                msg = "firstNodeTab.Length != firstNodeTest.Length";
                ok  = false;
            }

            Assert.IsTrue(ok, msg);
        }