Exemplo n.º 1
0
        // Method to perform the path planning
        protected override void DoPathPlanning()
        {
            // Sanity check: Don't do this when there is no mode or just 1 mode
            if (ModeCount < 3)
            {
                System.Windows.Forms.MessageBox.Show("Can't use TopN algorithm because there are less than 3 modes!");
                return;
            }

            // Do not exceed Max N set in project constants
            int GCount = ModeCount;
            if (GCount > ProjectConstants.Max_N)
            {
                GCount = ProjectConstants.Max_N;
            }

            // Loop through Gaussian Counts
            int counter = 0;
            for (int i = GCount; i > 1; i--)
            {
                for (int j = i; j > 1; j--)
                {
                    // Clone things for each search
                    PathPlanningRequest curRequestCopy = curRequest.DeepClone();
                    RtwMatrix mDistCopy = mDist.Clone();
                    RtwMatrix mDiffCopy = mDiff.Clone();
                    // Set appropriate parameters (always do coarse to fine and parallel)
                    curRequestCopy.AlgToUse = AlgType.TopN;
                    curRequestCopy.BatchRun = false;
                    curRequestCopy.DrawPath = false;
                    curRequestCopy.RunTimes = 1;
                    curRequestCopy.UseCoarseToFineSearch = true;
                    curRequestCopy.UseHierarchy = true;
                    curRequestCopy.UseParallelProcessing = true;
                    curRequestCopy.TopN = j;
                    MapModes curModes = new MapModes(i, ModeCount, mModes, curRequestCopy, mDist, mDiff);
                    // Create path planning object
                    AlgTopN curAlg = new AlgTopN(curModes, curRequestCopy, ModeCount, mModes, mDistCopy, mDiffCopy, Efficiency_UB);
                    curAlg.index = counter;
                    lstThreads.Add(curAlg);
                    counter++;
                }
            }

            // Allocate array space for results
            arrResponses = new PathPlanningResponse[lstThreads.Count];

            // Decide whether to do parallelization
            if (curRequest.UseParallelProcessing)
            {
                ParallelSearch();
            }
            else
            {
                ExtensiveSearch();
                FindBestPath();
            }
        }
Exemplo n.º 2
0
        // Algorithm specific implementation of the path planning
        protected override void DoPathPlanning()
        {
            // Take care of business without hierarchical search

            // Always use parallelization at this level no matter what

            if (!curRequest.UseEndPoint)
            {
                // For the no end point path planning requests
                // Always use CC
                PathPlanningRequest newRequest = curRequest.DeepClone();
                newRequest.AlgToUse = AlgType.CC;
                AlgPathPlanning myAlg = new AlgCC(newRequest, mDist, mDiff, Efficiency_UB);
                lstThreads.Add(myAlg);

                // Also always use LHCGWCONV
                newRequest = curRequest.DeepClone();
                newRequest.AlgToUse = AlgType.LHCGWCONV;
                RtwMatrix mDistCopy1 = mDist.Clone();
                RtwMatrix mDiffCopy1 = mDiff.Clone();
                myAlg = new AlgGlobalWarming(newRequest, ModeCount, mDistCopy1, mDiffCopy1, Efficiency_UB);
                lstThreads.Add(myAlg);

                // TopTwo works best when there are two modes (n>=2)
                if (ModeCount == 2)
                {
                    newRequest = curRequest.DeepClone();
                    newRequest.AlgToUse = AlgType.TopTwo;
                    RtwMatrix mDistCopy2 = mDist.Clone();
                    RtwMatrix mDiffCopy2 = mDiff.Clone();
                    myAlg = new AlgTopTwo(newRequest, ModeCount, mModes, mDistCopy2, mDiffCopy2, Efficiency_UB);
                    lstThreads.Add(myAlg);
                }

                // Use TopN if there are more than two modes
                if (ModeCount >= 3)
                {
                    newRequest = curRequest.DeepClone();
                    newRequest.AlgToUse = AlgType.TopN;
                    if (ModeCount <= ProjectConstants.Max_N)
                    {
                        newRequest.TopN = ModeCount;
                    }
                    // This is really hierarchical search
                    for (int i = 3; i < ProjectConstants.Max_N + 1; i++)
                    {
                        PathPlanningRequest newR = newRequest.DeepClone();
                        newR.TopN = i;
                        RtwMatrix mDistCopy2 = mDist.Clone();
                        RtwMatrix mDiffCopy2 = mDiff.Clone();
                        myAlg = new AlgTopN(newR, ModeCount, mModes, mDistCopy2, mDiffCopy2, Efficiency_UB);
                        lstThreads.Add(myAlg);
                    }
                }

                if (ProjectConstants.DebugMode)
                {
                    curRequest.SetLog("Running a total of " + lstThreads.Count + " path planning tasks.\n");
                }
                SpawnThreads();
            }
            else
            {

            }

            //if (HierarchicalSearch())
            //{
            //    return;
            //}
        }