Пример #1
0
        /// <summary>
        /// Check na construcao das cadeias
        /// </summary>
        /// <param name="chainType"></param>
        /// <param name="tempQueueType"></param>
        public static void QualificationChainTypes(ref BasicEnums.ChainTypes chainType, ref QueueType tempQueueType)
        {
            if ((chainType == BasicEnums.ChainTypes.Ideal))  //1-	Cadeia IDEAL inclui Cadeias REAL e SOFT, portanto devemos considerar neste grupo, para todos os efeitos, todas as 10000 cadeia geradas, ou seja todas as 10000
            {
                Queue <QueueType> .valuesCadeiaIdeal.Enqueue(tempQueueType);

#if Debug
                SaveSeedCoordAtDirSeed();
#endif
            }

            if ((chainType == BasicEnums.ChainTypes.Real)) //2-	Cadeia REAL inclui CADEIA SOFT , portanto temos que considerar neste grupo 38+3=41 cadeias para todos os efeitos; e finalmente
            {
                Queue <QueueType> .valuesCadeiaReal.Enqueue(tempQueueType);

#if Debug
                SaveSeedCoordAtDirSeed();
#endif

                //}
            }

            if (chainType == BasicEnums.ChainTypes.Soft) //3-	Cadeia SOFT está com a contagem correta.
            {
                Queue <QueueType> .valuesCadeiaSoft.Enqueue(tempQueueType);

#if Debug
                SaveSeedCoordAtDirSeed();
#endif
            }
        }
Пример #2
0
        public static double[] LoadData(BasicEnums.ChainTypes chainType, BasicEnums.HistTypes histType)
        {
            string file = firstNameFiles + chainType.ToString();

            string dir = IO.Directory.SubDirCoord;
            string pathFileSpinningRayValue = dir + @"\" + file + histType.ToString() + Consts.extensionOfFile;

            ExtendedStreamReader srSpinningRay = new ExtendedStreamReader(pathFileSpinningRayValue, Config.CurrentGuid, Config.Crypt);

            string allText = srSpinningRay.ReadToEnd();

            if (allText != null)
            {
                string[] arrString = Regex.Split(allText, ";");
                //Array.Resize(ref arrString, arrString.Length -1); //tira o bug do ENTER

                srSpinningRay.Close();
                srSpinningRay.Dispose();

                double[] arrDouble = new double[arrString.Length - 1];
                for (int i = 0; i < arrString.Length - 1; i++)
                {
                    arrDouble[i] = Convert.ToDouble(arrString[i]);
                }

                return(arrDouble);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        public static void WriteFrequencyPeerInterval(BasicEnums.HistTypes histType, BasicEnums.ChainTypes chainType)
        {
            string fileName = firstNameFiles + chainType.ToString();

            if (histType == BasicEnums.HistTypes.RadiuosOfGyration)
            {
                WriteFrequencyPeerInterval(fileName, spinningRayValues, histType, chainType);
            }
            else
            {
                if (histType == BasicEnums.HistTypes.EndToEndDistance)
                {
                    WriteFrequencyPeerInterval(fileName, calDistanceBetweenLastPointFirst, histType, chainType);
                }
            }
        }
Пример #4
0
        public static void SaveData(BasicEnums.ChainTypes chainType, Structs.Queue <QueueType> queue)
        {
            string file = firstNameFiles + chainType.ToString();

            string dir                                  = IO.Directory.SubDirCoord;
            string pathFileIsem                         = dir + @"\" + file + Consts.extensionOfFile;
            string pathFileSpinningRayValue             = dir + @"\" + file + spinningRayValues + Consts.extensionOfFile;
            string pathCalDistanceBetweenLastPointFirst = dir + @"\" + file + calDistanceBetweenLastPointFirst + Consts.extensionOfFile;


            ExtendedStreamWriter swIsem = new ExtendedStreamWriter(Config.Crypt);

            swIsem.AppendText(pathFileIsem, Config.CurrentGuid);

            ExtendedStreamWriter swSpinningRay = new ExtendedStreamWriter(Config.Crypt);

            swSpinningRay.AppendText(pathFileSpinningRayValue, Config.CurrentGuid);

            ExtendedStreamWriter swCalDistanceBetweenLastPointFirst = new ExtendedStreamWriter(Config.Crypt);

            swCalDistanceBetweenLastPointFirst.AppendText(pathCalDistanceBetweenLastPointFirst, Config.CurrentGuid);

            StringBuilder sbIsem        = new StringBuilder();
            StringBuilder sbSpinningRay = new StringBuilder();
            StringBuilder sbCalDistanceBetweenLastPointFirst = new StringBuilder();

            while (queue.Count > 0)
            {
                QueueType type = queue.Dequeue();

                sbIsem.AppendFormat("{0}{1}", type.isemName, ";");
                sbSpinningRay.AppendFormat(@"{0}{1}", type.spinningRayValue, ";");
                sbCalDistanceBetweenLastPointFirst.AppendFormat(@"{0}{1}", type.calDistanceBetweenLastPointFirst, ";");

                swSpinningRay.Write(sbSpinningRay.ToString());
                swCalDistanceBetweenLastPointFirst.Write(sbCalDistanceBetweenLastPointFirst.ToString());
                swIsem.Write(sbIsem.ToString());

                sbIsem.Clear();
                sbSpinningRay.Clear();
                sbCalDistanceBetweenLastPointFirst.Clear();
            }

            swSpinningRay.Close();
            swCalDistanceBetweenLastPointFirst.Close();
            swIsem.Close();
        }
Пример #5
0
 /// <summary>
 /// Check sobreposicao e Primeiro vizinho
 /// </summary>
 /// <param name="chainType"></param>
 /// <param name="cadeiaIdeal"></param>
 /// <param name="cadeiaReal"></param>
 /// <param name="cadeiaSoft"></param>
 public static void CheckOverRideAndFirstNeighbor(ref BasicEnums.ChainTypes chainType, ref int cadeiaIdeal, ref int cadeiaReal, ref int cadeiaSoft)
 {
     if (CheckContruction.CheckOverRide()) //Checagem de sobreposição
     {
         cadeiaIdeal++;
         chainType = BasicEnums.ChainTypes.Ideal;
     }
     else
     {
         if (CheckContruction.FirstNeighbor()) //Primeiro Vizinho
         {
             cadeiaReal++;
             chainType = BasicEnums.ChainTypes.Real;
         }
         else
         {
             cadeiaSoft++;
             chainType = BasicEnums.ChainTypes.Soft;
         }
     }
 }
        /// <summary>
        /// Efetua a contagem do Histograma para Distancia entre primeiro e ultimo pontos
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="type"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <param name="arr"></param>
        /// <returns></returns>
        private static StringBuilder HistogramDistanceBetweenLastPointFirst(string fileName, BasicEnums.ChainTypes type, double min, double max, double[] arr)
        {
            double sum    = SumRG(arr);
            double medium = FrequencyAverageRG(arr);

            StringBuilder sb = new StringBuilder();

            //sb.Append("Histograma\n");

            sb.Append("\t\t\t\t\tBIN = (max-min)/[3,32*LOG(#configs)]\n");
            sb.Append("#configs\tmin\tmax\tBIN\tsum DPP\t<DPP>\n");

            sb.Append(arr.Length + "\t" + min + "\t" + max + "\t" + AppConfigClient.Param.dataToProcess.valueOfDelta + "\t" + sum + "\t" + medium + "\n");

            //sb.Append("lenght:  " + arr.Length + "\n");
            //sb.Append("min:     " + min + "\n");
            //sb.Append("max:     " + max + "\n");
            //sb.Append("n:   " + AppConfigClient.Process.numberOfDelta + "\n");
            //sb.Append("sum RG:   " + sum + "\n");
            //sb.Append("medium RG:   " + medium + "\n");

            //Montando as frequencias dos intervalos (# de BINS)
            List <double> freq = new List <double>();

            for (double i = min; i < max; i = i + AppConfigClient.Param.dataToProcess.valueOfDelta)
            {
                freq.Add(i);
                //GICO.WriteLine(i);
            }
            freq.Add(max);

            sb.Append("Frequencies\n");
            sb.Append("Initial\tFinal\tOccurrences\n");
            int lenght = freq.Count;

            double[] faixaInicial = new double[lenght - 1];
            double[] faixaFinal   = new double[lenght - 1];
            double[] ocorrencias  = new double[lenght - 1];

            List <int> coutFreq = new List <int>();

            for (int i = 0; i < (lenght - 1); i++)
            {
                int    count = 0;
                double val_1 = Convert.ToDouble(freq[i]);
                double val_2 = Convert.ToDouble(freq[i + 1]);


                ParallelLoopResult result = Parallel.For(0, arr.Length, k =>
                {
                    if ((arr[k] >= val_1) && (arr[k] <= val_2))
                    {
                        count++;
                    }
                });

                //for (int k = 0; k < arr.Length; k++)
                //{

                //    if ((arr[k] >= val_1) && (arr[k] <= val_2))
                //    {
                //        count++;
                //    }
                //}
                faixaInicial[i] = val_1;
                faixaFinal[i]   = val_2;
                ocorrencias[i]  = count;
                sb.Append(val_1 + "\t" + val_2 + "\t" + count + "\n");
            }

            ////Gerar saida em EXCEL
            //Integration.ExcelIntegrator objExcel = new Integration.ExcelIntegrator();
            //objExcel.Execute(fileName+".xls", type, faixaInicial, faixaFinal, ocorrencias, arr.Length, min, max, 0, sum, medium);
            //objExcel = null;

            return(sb);
        }
        public static StringBuilder FrequencyPeerInterval(string fileName, BasicEnums.HistTypes histType, BasicEnums.ChainTypes type)
        {
            double[] arr = null;

            if (type == BasicEnums.ChainTypes.Ideal)
            {
                //IDEAL
                if (histType == BasicEnums.HistTypes.RadiuosOfGyration)
                {
                    arr = CalcOfFrequency.LoadData(BasicEnums.ChainTypes.Ideal, BasicEnums.HistTypes.RadiuosOfGyration);
                }
                else
                {
                    arr = CalcOfFrequency.LoadData(BasicEnums.ChainTypes.Ideal, BasicEnums.HistTypes.EndToEndDistance);
                }
            }
            else if (type == BasicEnums.ChainTypes.Real)
            {
                //REAL
                if (histType == BasicEnums.HistTypes.RadiuosOfGyration)
                {
                    arr = CalcOfFrequency.LoadData(BasicEnums.ChainTypes.Real, BasicEnums.HistTypes.RadiuosOfGyration);
                }
                else
                {
                    arr = CalcOfFrequency.LoadData(BasicEnums.ChainTypes.Real, BasicEnums.HistTypes.EndToEndDistance);
                }
            }
            else if (type == BasicEnums.ChainTypes.Soft)
            {
                //SOFT
                if (histType == BasicEnums.HistTypes.RadiuosOfGyration)
                {
                    arr = CalcOfFrequency.LoadData(BasicEnums.ChainTypes.Soft, BasicEnums.HistTypes.RadiuosOfGyration);
                }
                else
                {
                    arr = CalcOfFrequency.LoadData(BasicEnums.ChainTypes.Soft, BasicEnums.HistTypes.EndToEndDistance);
                }
            }


            StringBuilder sbHist;

            if (arr != null)
            {
                if (arr.Length > 0)
                {
                    double min;
                    double max;


                    int lengthArr = arr.Length;

                    arr = SorteDouble(arr);
                    min = arr[0];
                    max = arr[lengthArr - 1];

                    //Calcula valor de DELTA
                    AppConfigClient.Param.dataToProcess.valueOfDelta = CalcBIN(arr, lengthArr, min, max);

                    if (histType == BasicEnums.HistTypes.RadiuosOfGyration)
                    {
                        sbHist = histogramSpinningRayValues(fileName, type, min, max, arr);
                    }
                    else
                    {
                        sbHist = HistogramDistanceBetweenLastPointFirst(fileName, type, min, max, arr);
                    }
                }
                else
                {
                    sbHist = null;
                }
            }
            else
            {
                sbHist = null;
            }

            return(sbHist);
        }
Пример #8
0
        private static void WriteFrequencyPeerInterval(string fileName, string extFileName, BasicEnums.HistTypes histType, BasicEnums.ChainTypes chainType)
        {
            StringBuilder sb = Maths4Simulation.FrequencyPeerInterval(fileName + extFileName, histType, chainType);

            if (sb != null)
            {
                string dir      = IO.Directory.SubDirHistogram;
                string pathFile = dir + @"\" + fileName + histogram + extFileName + Directory.FileExtension;

                string[] ret = Regex.Split(sb.ToString(), "\n");

                ExtendedStreamWriter sw = new ExtendedStreamWriter(Config.Crypt);
                sw.CreateText(pathFile, Config.CurrentGuid);

                for (int i = 0; i < ret.Count(); i++)
                {
                    string retPrinter = ret[i];
                    sw.WriteLine(retPrinter);
                }

                sw.Flush();
                sw.Close();
            }

            return;
        }