public AlgTopTwo(MapModes _curModes, PathPlanningRequest _curRequest, int _ModeCount, RtwMatrix _mModes, RtwMatrix _mDistReachable, RtwMatrix _mDiffReachable, double _Efficiency_UB) : base(_curRequest, _mDistReachable, _mDiffReachable, _Efficiency_UB) { // Start timer //DateTime startTime = DateTime.Now; myModes = _curModes; //DateTime stopTime = DateTime.Now; //TimeSpan duration = stopTime - startTime; //double RunTime = duration.TotalSeconds; //System.Windows.Forms.MessageBox.Show("Run time " + RunTime + " seconds!"); CTFTTCoraseLevel = ProjectConstants.CTFTTCoraseLevel; CTFTTLevelCount = ProjectConstants.CTFTTLevelCount; mDistAfterSeg1Seg4 = mDist; }
public AlgTopN(MapModes _curModes, PathPlanningRequest _curRequest, int _ModeCount, RtwMatrix _mModes, RtwMatrix _mDistReachable, RtwMatrix _mDiffReachable, double _Efficiency_UB) : base(_curRequest, _mDistReachable, _mDiffReachable, _Efficiency_UB) { //DateTime startTime = DateTime.Now; myModes = _curModes; //DateTime stopTime = DateTime.Now; //TimeSpan duration = stopTime - startTime; //double RunTime = duration.TotalSeconds; //System.Windows.Forms.MessageBox.Show("Run time " + RunTime + " seconds!"); Start = new Point(curRequest.pStart.column, curRequest.pStart.row); if (curRequest.UseEndPoint) { End = new Point(curRequest.pEnd.column, curRequest.pEnd.row); } N = curRequest.TopN; }
// 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(); } }