コード例 #1
0
        private static void threadbench(int m)
        {
            string        filename = $"C:\\Users\\Public\\Gridworld_Heuristics\\testresults_world{m}_{DateTime.Now.ToFileTime()}";
            MainViewModel benchvm  = new MainViewModel();
            float         w1       = 1;
            float         w2       = 1;

            GridHelper.readInputs(m, benchvm.world, benchvm.startPairs, benchvm.endPairs, benchvm.hardPairs);
            Naiive     searchLocal    = new Naiive(benchvm.world);
            Sequential seqsearchLocal = new Sequential(benchvm.world);
            Integrated intSearchLocal = new Integrated(benchvm.world);

            for (int j = 0; j < 5; j++)     //Startend pairs
            {
                for (int k = 0; k < 5; k++) //Algos
                {
                    if (k < 2)
                    {
                        for (int f = 0; f < 5; f++) // Heuristics
                        {
                            searchLocal.initAttr(f, k, w1, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                 benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                            searchLocal.hSearch();
                            snapshot(searchLocal, filename, m, j, k, f, w1, w2);
                            if (k == 1)
                            {//Weighted a*
                                w1 = 1.25f;
                                searchLocal.initAttr(f, k, w1, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                     benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                                searchLocal.hSearch();
                                snapshot(searchLocal, filename, m, j, k, f, w1, w2);
                                w1 = 2f;
                                searchLocal.initAttr(f, k, w1, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                     benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                                searchLocal.hSearch();
                                snapshot(searchLocal, filename, m, j, k, f, w1, w2);
                            }
                        }
                    }
                    if (k == 2)
                    {
                        searchLocal.initAttr(-1, k, w1, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                             benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal.hSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                    }
                    if (k == 3)
                    {
                        w1 = 1.25f;
                        w2 = 1.25f;
                        seqsearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = seqsearchLocal.seqSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);

                        w2 = 2f;
                        seqsearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = seqsearchLocal.seqSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);

                        w1 = 2f;
                        seqsearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = seqsearchLocal.seqSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);

                        w2 = 1.25f;
                        seqsearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = seqsearchLocal.seqSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                    }
                    else
                    {
                        w1 = 1.25f;
                        w2 = 1.25f;
                        intSearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = intSearchLocal.intSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                        w2 = 2f;
                        intSearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = intSearchLocal.intSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                        w1 = 2f;
                        intSearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = intSearchLocal.intSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                        w2 = 1.25f;
                        intSearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = intSearchLocal.intSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                    }
                }
            }
        }