예제 #1
0
        /// <summary>
        /// 引入规划调整小区
        /// </summary>
        private void init_adjustable_cells()
        {
            SortedSet<string> topNCells = new SortedSet<string>();

            List<FitnessStruct> lst = new List<FitnessStruct>();

            string sql = @"select *
                            from
                            (
                            SELECT SECTOR_ID
                            FROM tbcell_adjustable_cell
                            union
                            select C_Sector_ID
                            FROM tbcell_adjustable_cell
                            ) A
                            where SECTOR_ID is not null";
            DataTable dt = new DataTable();
            DBHelper.instatnce().get_dataTable(ref dt, sql);

            foreach (DataRow dr in dt.Rows) {
                string cellID = dr["sector_id"].ToString();
                FitnessStruct e = new FitnessStruct();
                e.cellName = cellID;
                lst.Add(e);
            }

            for(int i = 0; i < lst.Count; i++) {
                string cellName = lst[i].cellName;
                lst[i].fitness = m_cellInfo.get_c2i_default_sum(cellName);
                lst[i].index = m_cellInfo.cellInfo[cellName].index;
            }
            lst.Sort(new SortHelper_fitness());

            double s = .0;
            int indexPos = 0;
            for (int i = 0; i < lst.Count; i++) {
                int index = lst[i].index;
                string cellName = lst[i].cellName;
                m_highIntfCellName[index] = cellName;
                s += lst[i].fitness;
                //if (i >= lst.Count - 40)
                if (i >= 0) {
                    m_adjustCellName[index] = cellName;
                    m_adjustCellNameIndex[index] = indexPos++;
                }
                int baseID = m_cellInfo.cellInfo[cellName].ENODEBID;
                if (!m_baseCell.ContainsKey(baseID)) {
                    m_baseCell[baseID] = new SortedSet<string>();
                }
                m_baseCell[baseID].Add(cellName);
            }

            // 为要调整小区添加伴随小区
            sql = @"SELECT [SECTOR_ID]
                      ,[S_EARFCN]
                      ,[C_Sector_ID]
                      ,[C_EARFCN]
                      ,[CTYPE]
                  FROM [tbcell_adjustable_cell]  order by [C_Sector_ID]";

            DataTable dt2 = new DataTable();
            DBHelper.instatnce().get_dataTable(ref dt2, sql);

            foreach(DataRow dr in dt2.Rows) {
                string SECTOR_ID = dr["SECTOR_ID"].ToString();
                string C_Sector_ID = dr["C_Sector_ID"].ToString();
                if(m_adjCell.ContainsKey(SECTOR_ID)) {
                    m_adjCell[SECTOR_ID].Add(C_Sector_ID);
                } else {
                    m_adjCell[SECTOR_ID] = new SortedSet<string>();
                    if (C_Sector_ID == "")
                        continue;
                    m_adjCell[SECTOR_ID].Add(C_Sector_ID);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 保留一部分精英个体
        /// </summary>
        /// <param name="finishedIndex"></param>
        private void elitist_strategy(ref int finishedIndex)
        {
            // 精英个体约10-20个.
            int elitisCount = m_M / 10;
            elitisCount = Math.Min(elitisCount, 20);
            elitisCount = Math.Max(elitisCount, 10);

            List<FitnessStruct> items = new List<FitnessStruct>();
            for(int i = 0; i < m_M; i++) {
                FitnessStruct e = new FitnessStruct();
                e.fitness = m_popFitness[i];
                e.index = i;
                items.Add(e);
            }

            // 保留精英个体
            //items.Sort(compare_by_fitness);
            items.Sort(new SortHelper_fitness());
            for (int i = 0; i < elitisCount && i < m_M; i++) {
                m_populations[items[i].index].CopyTo(m_populationsNew[i], 0);
                finishedIndex = i;
            }
        }