コード例 #1
0
        public void LabelStoreToExcel()
        {
            DataTable labelDt = new DataTable();

            for (int i = 0; i < highbounds[0] - lowbounds[0] + 1; i++)
            {
                labelDt.Columns.Add(i.ToString(), Type.GetType("System.Double"));
            }

            for (int i = 0; i < labelMatrix.RowCount; i++)
            {
                var row = labelDt.NewRow();
                row.ItemArray = labelMatrix.Row(labelMatrix.RowCount - i - 1).Select(x => (object)x).ToArray();
                labelDt.Rows.Add(row);
            }

            if (File.Exists(@"C:\Users\shiya\Desktop\record\label.xlsx"))
            {
                File.Delete(@"C:\Users\shiya\Desktop\record\label.xlsx");
            }
            File.Create(@"C:\Users\shiya\Desktop\record\label.xlsx").Close();
            ExcelOperation.dataTableListToExcel(new List <DataTable>()
            {
                labelDt
            }, false,
                                                @"C:\Users\shiya\Desktop\record\label.xlsx");

            _data.strbuf = "Finish Write Labels to Excel";
            _data.update = true;
        }
コード例 #2
0
        void UpdateRecordAndDisplay()
        {
            Console.WriteLine("Generation: {0}", gen);
            List <GAEncoding> currentBests = cePool.Where(x => x.Key.entropy == cePool.Max(y => y.Key.entropy))
                                             .Select(x => x.Key).ToList();

            for (int i = 0; i < currentBests.Count; i++)
            {
                Console.WriteLine("Solution: {1}, Entropy: {0}", currentBests[i].entropy, i);
            }
            var a         = currentBests[0].weightsVect.Sum();
            var solutions = Print_Solution(currentBests[0]);

            object[] temp   = new object[pNumOfParams * pNumOfParams];
            var      newRow = dt.NewRow();

            for (int i = 0; i < pNumOfParams * pNumOfParams; i++)
            {
                temp[i] = currentBests[0].weightsVect.ToArray()[i];
            }
            newRow.ItemArray = temp;
            dt.Rows.Add(newRow);

            int fake = 0;

            if (fake > 0)
            {
                ExcelOperation.dataTableListToExcel(new List <DataTable>()
                {
                    dt
                }, false,
                                                    @"C:\Users\shiya\Desktop\record\a.xlsx");
            }
        }
コード例 #3
0
        void UpdateRecordAndDisplay()
        {
            Console.WriteLine("Generation: {0}", gen);
            List <GAEncoding> currentBests = cePool.Where(x => x.Key.rank == 0)
                                             .Select(x => x.Key).ToList();

            //for (int i = 0; i < currentBests.Count; i++)
            //{
            //    Console.WriteLine("Solution: {1}, Entropy: {0}", currentBests[i].entropy, i);
            //    Console.WriteLine("Solution: {1}, Diversity: {0}", currentBests[i].diversity, i);
            //}
            Console.WriteLine("Max_Entropy: {0}", currentBests.Where(x => x.entropy == currentBests
                                                                     .Max(y => y.entropy)).First().entropy);
            Console.WriteLine("Max_Diversity: {0}", currentBests.Where(x => x.diversity == currentBests
                                                                       .Max(y => y.diversity)).First().diversity);

            _data.fitness = currentBests.Where(x => x.entropy == currentBests
                                               .Max(y => y.entropy)).First().entropy;
            _data.generation = gen;
            _data.strbuf     = "Fitness: " + _data.fitness.ToString();
            _data.update     = true;

            var a         = currentBests[0].weightsVect.Sum();
            var solutions = Print_Solution(currentBests[0]);

            object[] temp   = new object[pNumOfParams * pNumOfParams];
            var      newRow = dt.NewRow();

            for (int i = 0; i < pNumOfParams * pNumOfParams; i++)
            {
                temp[i] = currentBests[0].weightsVect.ToArray()[i];
            }
            newRow.ItemArray = temp;
            dt.Rows.Add(newRow);

            int fake = 0;

            if (fake > 0)
            {
                ExcelOperation.dataTableListToExcel(new List <DataTable>()
                {
                    dt
                }, false,
                                                    @"C:\Users\shiya\Desktop\record\a.xlsx");
            }
        }