Beispiel #1
0
        //Weights are stored as serialised strings rather than objects - lazy me.
        private void SerialiseWeightsAndSaveToDB(double[] weightStatistics, List <double[]> weights1, List <double[]> weights2, List <double[]> weights3, List <double[]> weights4)
        {
            BTCCrackerDBContext wdbc = new BTCCrackerDBContext();
            WeightLog           ws   = new WeightLog();

            ws.WeightsHL0 = SerialiseWeights(weights1);
            ws.WeightsHL1 = SerialiseWeights(weights2);
            ws.WeightsHL2 = SerialiseWeights(weights3);
            ws.WeightsOL  = SerialiseWeights(weights4);

            ws.Byte0  = (int)weightStatistics[0];
            ws.Byte1  = (int)weightStatistics[1];
            ws.Byte2  = (int)weightStatistics[2];
            ws.Byte3  = (int)weightStatistics[3];
            ws.Byte4  = (int)weightStatistics[4];
            ws.Byte5  = (int)weightStatistics[5];
            ws.Byte6  = (int)weightStatistics[6];
            ws.Byte7  = (int)weightStatistics[7];
            ws.Byte8  = (int)weightStatistics[8];
            ws.Byte9  = (int)weightStatistics[9];
            ws.Byte10 = (int)weightStatistics[10];
            ws.Byte11 = (int)weightStatistics[11];
            ws.Byte12 = (int)weightStatistics[12];
            ws.Byte13 = (int)weightStatistics[13];
            ws.Byte14 = (int)weightStatistics[14];
            ws.Byte15 = (int)weightStatistics[15];
            ws.Byte16 = (int)weightStatistics[16];
            ws.Byte17 = (int)weightStatistics[17];
            ws.Byte18 = (int)weightStatistics[18];
            ws.Byte19 = (int)weightStatistics[19];
            ws.Byte20 = (int)weightStatistics[20];
            ws.Byte21 = (int)weightStatistics[21];
            ws.Byte22 = (int)weightStatistics[22];
            ws.Byte23 = (int)weightStatistics[23];
            ws.Byte24 = (int)weightStatistics[24];
            ws.Byte25 = (int)weightStatistics[25];
            ws.Byte26 = (int)weightStatistics[26];
            ws.Byte27 = (int)weightStatistics[27];
            ws.Byte28 = (int)weightStatistics[28];
            ws.Byte29 = (int)weightStatistics[29];
            ws.Byte30 = (int)weightStatistics[30];
            ws.Byte31 = (int)weightStatistics[31];

            wdbc.Add(ws);
            wdbc.SaveChanges();
        }
        private void InitValue()
        {
            BTCCrackerDBContext btcDB = new BTCCrackerDBContext();

            if (byteNum == 0)
            {
                rowCountsPerByte[0]  = btcDB.WeightLogs.Count(x => x.Byte0 >= prob);
                rowCountsPerByte[1]  = btcDB.WeightLogs.Count(x => x.Byte1 >= prob);
                rowCountsPerByte[2]  = btcDB.WeightLogs.Count(x => x.Byte2 >= prob);
                rowCountsPerByte[3]  = btcDB.WeightLogs.Count(x => x.Byte3 >= prob);
                rowCountsPerByte[4]  = btcDB.WeightLogs.Count(x => x.Byte4 >= prob);
                rowCountsPerByte[5]  = btcDB.WeightLogs.Count(x => x.Byte5 >= prob);
                rowCountsPerByte[6]  = btcDB.WeightLogs.Count(x => x.Byte6 >= prob);
                rowCountsPerByte[7]  = btcDB.WeightLogs.Count(x => x.Byte7 >= prob);
                rowCountsPerByte[8]  = btcDB.WeightLogs.Count(x => x.Byte8 >= prob);
                rowCountsPerByte[9]  = btcDB.WeightLogs.Count(x => x.Byte9 >= prob);
                rowCountsPerByte[10] = btcDB.WeightLogs.Count(x => x.Byte10 >= prob);
                rowCountsPerByte[11] = btcDB.WeightLogs.Count(x => x.Byte11 >= prob);
                rowCountsPerByte[12] = btcDB.WeightLogs.Count(x => x.Byte12 >= prob);
                rowCountsPerByte[13] = btcDB.WeightLogs.Count(x => x.Byte13 >= prob);
                rowCountsPerByte[14] = btcDB.WeightLogs.Count(x => x.Byte14 >= prob);
                rowCountsPerByte[15] = btcDB.WeightLogs.Count(x => x.Byte15 >= prob);
                rowCountsPerByte[16] = btcDB.WeightLogs.Count(x => x.Byte16 >= prob);
                rowCountsPerByte[17] = btcDB.WeightLogs.Count(x => x.Byte17 >= prob);
                rowCountsPerByte[18] = btcDB.WeightLogs.Count(x => x.Byte18 >= prob);
                rowCountsPerByte[19] = btcDB.WeightLogs.Count(x => x.Byte19 >= prob);
                rowCountsPerByte[20] = btcDB.WeightLogs.Count(x => x.Byte20 >= prob);
                rowCountsPerByte[21] = btcDB.WeightLogs.Count(x => x.Byte21 >= prob);
                rowCountsPerByte[22] = btcDB.WeightLogs.Count(x => x.Byte22 >= prob);
                rowCountsPerByte[23] = btcDB.WeightLogs.Count(x => x.Byte23 >= prob);
                rowCountsPerByte[24] = btcDB.WeightLogs.Count(x => x.Byte24 >= prob);
                rowCountsPerByte[25] = btcDB.WeightLogs.Count(x => x.Byte25 >= prob);
                rowCountsPerByte[26] = btcDB.WeightLogs.Count(x => x.Byte26 >= prob);
                rowCountsPerByte[27] = btcDB.WeightLogs.Count(x => x.Byte27 >= prob);
                rowCountsPerByte[28] = btcDB.WeightLogs.Count(x => x.Byte28 >= prob);
                rowCountsPerByte[29] = btcDB.WeightLogs.Count(x => x.Byte29 >= prob);
                rowCountsPerByte[30] = btcDB.WeightLogs.Count(x => x.Byte30 >= prob);
                rowCountsPerByte[31] = btcDB.WeightLogs.Count(x => x.Byte31 >= prob);
            }

            //Get next weights from database
            switch (byteNum)
            {
            case 0:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[0])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte0 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 1:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[1])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte1 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 2:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[2])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte2 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 3:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[3])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte3 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 4:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[4])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte4 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 5:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[5])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte5 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 6:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[6])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte6 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 7:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[7])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte7 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 8:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[8])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte8 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 9:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[9])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte9 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 10:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[10])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte10 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 11:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[11])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte11 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 12:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[12])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte12 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 13:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[13])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte13 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 14:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[14])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte14 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 15:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[15])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte15 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 16:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[16])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte16 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 17:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[17])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte17 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 18:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[18])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte18 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 19:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[19])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte19 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 20:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[20])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte20 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 21:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[21])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte21 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 22:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[22])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte22 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 23:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[23])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte23 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 24:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[24])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte24 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 25:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[25])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte25 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 26:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[26])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte26 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 27:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[27])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte27 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 28:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[28])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte28 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 29:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[29])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte29 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 30:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[30])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte30 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }

            case 31:
            {
                List <WeightLog> wl = new List <WeightLog>();

                if (rowSkipCount < rowCountsPerByte[31])
                {
                    wl = btcDB.WeightLogs.OrderByDescending(x => x.Byte31 >= prob).Skip(rowSkipCount++).Take(1).ToList();
                }

                DeserialiseWeights(wl[0]);
                ParseStats(wl[0]);

                break;
            }
            }
        }