Esempio n. 1
0
 //分支界限法搜索频点序列
 public void SearchBetter2(List<int> highintefcelllist)
 {
     System.Diagnostics.Stopwatch Time = new System.Diagnostics.Stopwatch();
     Time.Start();
     Individual indiv = new Individual(slist.sectorList.Count);
     ancestor.clone(ref indiv);
     double interftempori = checkhighlist(delta2,highintefcelllist,indiv);
     for (int i = 0; i < highintefcelllist.Count; i++)
     {
         indiv.gene[highintefcelllist[i]] = -1;
     }
     int k = 0;// 小区下标
     int n = highintefcelllist.Count;//小区个数
     int[] fcnindex = new int[n];
     int[] x = new int[n];
     for (int j = 0; j < n; j++)
     {
         fcnindex[j] = -1;
     }
     int count = 0;
     int index = 0;
     //按照层次,横向搜索
     for (int ii = 0; ii < n; ii++)
     {
         double minfitness = 0;
         int minfitnessindex = 0;
         bool first = true;
         for (index = 0; index < slist.sectorList[highintefcelllist[ii]].useablefcn.Count; index++)
         {
             count++;
             x[ii] = slist.sectorList[ii].useablefcn[index];
             if (checkhighlist(delta2, highintefcelllist, indiv) < interftempori)//可以加条件,剪枝,保证个体条件不恶化
             {
                 indiv.gene[highintefcelllist[ii]] = x[ii];
                 if (first)
                 {
                     //评估函数(上界+下界),这里是按照干扰来评估的。
                     minfitness = DownEvalueTotalFitness(n, ii, indiv, highintefcelllist);
                     minfitnessindex = index;
                     first = false;
                 }
                 else
                 {
                     double temp = DownEvalueTotalFitness(n, ii, indiv, highintefcelllist);
                     if (temp < minfitness)
                     {
                         minfitness = temp;
                         minfitnessindex = index;
                     }
                 }
             }//if
             indiv.gene[highintefcelllist[ii]] = -1;
         }//for
         x[ii] = slist.sectorList[ii].useablefcn[minfitnessindex];
         indiv.gene[highintefcelllist[ii]] = x[ii];
         if (checkhighlist(delta2, highintefcelllist, indiv) > interftempori)
         {
             Console.WriteLine("到达第"+ii+"个小区最优解方向就已经停止,没搜到,一共用时 {0}", Time.Elapsed.TotalSeconds);
             break;
         }
     }//for
     double t=checkhighlist(delta2,highintefcelllist,indiv);
     if (t<=interftempori)//最后筛选的条件,选择满足什么样条件的个体
     {
         indiv.clone(ref ancestor);
         Time.Stop();
         Console.WriteLine("已经搜到,一共用时 {0}S,干扰小区和关联小区集合一共提高{1}", Time.Elapsed.TotalSeconds,(interftempori-t)/interftempori*100+"%");
     }
     else
     {
         Time.Stop();
         Console.WriteLine("没有搜到,一共用时 {0}S", Time.Elapsed.TotalSeconds);
     }
 }
Esempio n. 2
0
 //评估函数(上+下)
 public double DownEvalueTotalFitness(int n, int k, Individual individual, List<int> highintefcelllist)
 {
     Individual tempindiv = new Individual(slist.sectorList.Count);
     individual.clone(ref tempindiv);
     int i = 0, j = 0;
     int minindex = 0;
     double minintfess = 0;
     for (i = k + 1; i < n; i++)
     {
         for (j = 0; j < slist.sectorList[highintefcelllist[i]].useablefcn.Count; j++)
         {
             if (j == 0)
             {
                 tempindiv.gene[highintefcelllist[i]] = slist.sectorList[highintefcelllist[i]].useablefcn[j];
                 minindex = 0;
                 minintfess = checkhighlist(delta2, highintefcelllist,tempindiv);
             }
             else
             {
                 tempindiv.gene[highintefcelllist[i]] = slist.sectorList[highintefcelllist[i]].useablefcn[j];
                 double tempinter = checkhighlist(delta2, highintefcelllist, tempindiv);
                 if (tempinter < minintfess)
                 {
                     minintfess = tempinter;
                     minindex = j;
                 }
             }
         }
         tempindiv.gene[highintefcelllist[i]] = slist.sectorList[highintefcelllist[i]].useablefcn[minindex];
     }
     return checkhighlist(delta2,highintefcelllist,tempindiv);
 }
Esempio n. 3
0
 //回朔法搜索频点序列
 public bool SearchBetter(List<int> highintefcelllist)
 {
     System.Diagnostics.Stopwatch Time1 = new System.Diagnostics.Stopwatch();
     Time1.Start();
     Individual indiv = new Individual(slist.sectorList.Count);
     ancestor.clone(ref indiv);
     double interftempori = checkhighlist(delta2, highintefcelllist, ancestor);
     double orihighlist = interftempori;
     for (int i = 0; i < highintefcelllist.Count; i++)
     {
         indiv.gene[highintefcelllist[i]] = -1;
     }
     int k = 0;// 小区下标
     int n = highintefcelllist.Count;//小区个数
     int[] fcnindex = new int[n];
     for (int j = 0; j < n; j++)
     {
         fcnindex[j] = -1;
     }
     //这是主要的回朔
     bool flag = false;
     int count = 0;
     int deletecount = 0;
     int solutioncount = 0;
     while (k >= 0 && Time1.Elapsed.TotalSeconds <= 300)//&& Time.Elapsed.TotalSeconds <= 300
     {
         fcnindex[k]++;
         indiv.gene[highintefcelllist[k]] = -1;
         if (fcnindex[k] < slist.sectorList[highintefcelllist[k]].useablefcn.Count)
         {
             indiv.gene[highintefcelllist[k]] = slist.sectorList[highintefcelllist[k]].useablefcn[fcnindex[k]];
             count++;
         }
         else
         {
             fcnindex[k] = -1;//重新置空PCI;列表下标,这里出了问题以前!
             k = k - 1;//回朔到上一个小区
             continue;
         }
         //其中OK函数负责找到PCI,并且实际分配
         while (checkhighlist(delta2, highintefcelllist, indiv) > interftempori)//可以加其他条件
         {
             fcnindex[k]++;
             deletecount++;
             if (fcnindex[k] < slist.sectorList[highintefcelllist[k]].useablefcn.Count)
             {
                 indiv.gene[highintefcelllist[k]] = slist.sectorList[highintefcelllist[k]].useablefcn[fcnindex[k]];//继续找下一个可用PCI
                 count++;
             }
             else
             {
                 break;
             }
         }
         if (fcnindex[k] < slist.sectorList[highintefcelllist[k]].useablefcn.Count)
         {
             if (k == n - 1)
             {
                 double tempinterf = checkhighlist(delta2, highintefcelllist, indiv);
                 if (tempinterf < interftempori)
                 {
                     interftempori = tempinterf;
                     indiv.clone(ref ancestor);
                     solutioncount++;
                     flag = true;
                     Console.WriteLine("高干扰小区以及关联小区一共提升了" + (orihighlist - interftempori) / orihighlist * 100 + "%");
                     continue;
                 }
                 else
                 {
                     continue;
                 }
             }
             else
             {
                 k = k + 1;//分配下一个PCI
             }
         }
         else
         {
             fcnindex[k] = -1;//重新置空PCI;列表下标,这里出了问题以前!
             indiv.gene[highintefcelllist[k]] = -1;
             k = k - 1;//回朔到上一个小区
         }
     }
     if (flag)
     {
         Console.WriteLine("搜索节点个数为:" + count + "剪枝个数为:" + deletecount + "解的个数为:" + solutioncount);
         return true;
     }
     else
     {
         Console.WriteLine("搜索节点个数为:" + count + "剪枝个数为:" + deletecount + "解的个数为:" + solutioncount);
         return false;
     }
 }