Exemplo n.º 1
0
        /// <summary>
        ///A test for Clone
        ///</summary>
        public void CloneTestHelper <T>()
        {
            MatrixBase <Double> target = new Double[, ] {
                { 11F, 12F, 13F, 14F },
                { 21F, 22F, 23F, 24F },
                { 31F, 32F, 33F, 34F }
            };
            MatrixBase <Double> expected = new Double[, ] {
                { 11F, 12F, 13F, 14F },
                { 21F, 22F, 23F, 24F },
                { 31F, 32F, 33F, 34F }
            };
            MatrixBase <Double> actual = target.Clone();

            Assert.AreEqual(expected, actual);
            Assert.AreNotEqual((object)expected.DataSource, (object)actual.DataSource);
        }
Exemplo n.º 2
0
            public void AddResult(ResultData r)
            {
                Boolean match = false;
                int     indx  = -1;

                foreach (MainResults MaRe in results)
                {
                    //match = (MaRe.Latitude == r.Latitude && MaRe.Longitude == r.Longitude);
                    match = (MaRe.OrganizationLocationID == r.OrganizationLocationID);
                    if (match)
                    {
                        indx = results.IndexOf(MaRe);
                        break;
                    }
                }
                if (!match)
                {
                    MainResults mr = new MainResults();
                    mr.TaxID                  = new String[] { r.TaxID };
                    mr.NPI                    = new String[] { r.NPI };
                    mr.PracticeName           = r.PracticeName;
                    mr.ProviderName           = new String[] { r.ProviderName };
                    mr.PracticeRangeMin       = String.Format("{0:c0}", decimal.Parse(r.RangeMin));
                    mr.RangeMin               = new String[] { r.RangeMin };
                    mr.PracticeRangeMax       = String.Format("{0:c0}", decimal.Parse(r.RangeMax));
                    mr.RangeMax               = new String[] { r.RangeMax };
                    mr.PracticeYourCostMin    = String.Format("{0:c0}", decimal.Parse(r.YourCostMin));
                    mr.YourCostMin            = new String[] { r.YourCostMin };
                    mr.PracticeYourCostMax    = String.Format("{0:c0}", decimal.Parse(r.YourCostMax));
                    mr.YourCostMax            = new String[] { r.YourCostMax };
                    mr.Latitude               = r.Latitude;
                    mr.Longitude              = r.Longitude;
                    mr.OrganizationLocationID = r.OrganizationLocationID;
                    mr.LocationAddress1       = r.LocationAddress1;
                    mr.LocationCity           = r.LocationCity;
                    mr.LocationState          = r.LocationState;
                    mr.LocationZip            = r.LocationZip;
                    mr.Distance               = r.Distance;
                    mr.NumericDistance        = r.NumericDistance;
                    mr.PracticeFairPrice      = r.FairPrice;
                    mr.FairPrice              = new Boolean[] { r.FairPrice };
                    mr.HGRecognized           = new Int32[] { r.HGRecognized };
                    switch (r.HGRecognized)
                    {
                    case -1:
                        mr.PracticeHGRecognized = "N/A";
                        break;

                    case 0:
                        mr.PracticeHGRecognized = "0/1 Physicians";
                        break;

                    case 1:
                        mr.PracticeHGRecognized = "1/1 Physicians";
                        break;

                    default:
                        mr.PracticeHGRecognized = "N/A";
                        break;
                    }
                    mr.PracticeAvgRating = r.HGOverallRating;
                    mr.HGOverallRating   = new Double[] { r.HGOverallRating };
                    mr.HGPatientCount    = new int[] { r.HGPatientCount };
                    results.Add(mr);
                }
                else
                {
                    MainResults mr = results[indx];

                    String[] s = new String[mr.TaxID.Length + 1];
                    mr.TaxID.CopyTo(s, 0);
                    s[s.Length - 1] = r.TaxID;
                    mr.TaxID        = (String[])s.Clone();
                    mr.NPI.CopyTo(s, 0);
                    s[s.Length - 1] = r.NPI;
                    mr.NPI          = (String[])s.Clone();
                    mr.ProviderName.CopyTo(s, 0);
                    s[s.Length - 1] = r.ProviderName;
                    mr.ProviderName = (String[])s.Clone();

                    mr.RangeMin.CopyTo(s, 0);
                    s[s.Length - 1]     = r.RangeMin;
                    mr.RangeMin         = (String[])s.Clone();
                    mr.PracticeRangeMin = String.Format("{0:c0}", ((double.Parse(mr.PracticeRangeMin.Replace("$", "")) + double.Parse(r.RangeMin)) / 2.0));
                    mr.RangeMax.CopyTo(s, 0);
                    s[s.Length - 1]     = r.RangeMax;
                    mr.RangeMax         = (String[])s.Clone();
                    mr.PracticeRangeMax = String.Format("{0:c0}", ((double.Parse(mr.PracticeRangeMax.Replace("$", "")) + double.Parse(r.RangeMax)) / 2.0));

                    mr.YourCostMin.CopyTo(s, 0);
                    s[s.Length - 1]        = r.YourCostMin;
                    mr.YourCostMin         = (String[])s.Clone();
                    mr.PracticeYourCostMin = String.Format("{0:c0}", ((double.Parse(mr.PracticeYourCostMin.Replace("$", "")) + double.Parse(r.YourCostMin)) / 2.0));
                    mr.YourCostMax.CopyTo(s, 0);
                    s[s.Length - 1]        = r.YourCostMax;
                    mr.YourCostMax         = (String[])s.Clone();
                    mr.PracticeYourCostMax = String.Format("{0:c0}", ((double.Parse(mr.PracticeYourCostMax.Replace("$", "")) + double.Parse(r.YourCostMax)) / 2.0));

                    Boolean[] b = new Boolean[mr.FairPrice.Length + 1];
                    mr.FairPrice.CopyTo(b, 0);
                    b[b.Length - 1] = r.FairPrice;
                    mr.FairPrice    = (Boolean[])b.Clone();
                    if (!mr.PracticeFairPrice && r.FairPrice)
                    {
                        mr.PracticeFairPrice = r.FairPrice;
                    }

                    Int32[] i32 = new Int32[mr.HGRecognized.Length + 1];
                    mr.HGRecognized.CopyTo(i32, 0);
                    i32[i32.Length - 1] = r.HGRecognized;
                    mr.HGRecognized     = (Int32[])i32.Clone();
                    switch (r.HGRecognized)
                    {
                    case -1:
                        //Do Nothing
                        break;

                    case 0:
                        if (mr.PracticeHGRecognized == "N/A")
                        {
                            mr.PracticeHGRecognized = "0/0 Physicians";
                        }
                        String[] str0 = mr.PracticeHGRecognized.Replace("Physicians", "").Trim().Split('/');
                        mr.PracticeHGRecognized = String.Format("{0}/{1} Physicians",
                                                                str0[0],
                                                                (Convert.ToInt32(str0[1]) + 1).ToString());
                        break;

                    case 1:
                        if (mr.PracticeHGRecognized == "N/A")
                        {
                            mr.PracticeHGRecognized = "0/0 Physicians";
                        }
                        String[] str1 = mr.PracticeHGRecognized.Replace("Physicians", "").Trim().Split('/');
                        mr.PracticeHGRecognized = String.Format("{0}/{1} Physicians",
                                                                (Convert.ToInt32(str1[0]) + 1).ToString(),
                                                                (Convert.ToInt32(str1[1]) + 1).ToString());
                        break;

                    default:
                        break;
                    }

                    Double[] d = new Double[mr.HGOverallRating.Length + 1];
                    mr.HGOverallRating.CopyTo(d, 0);
                    d[d.Length - 1]      = r.HGOverallRating;
                    mr.HGOverallRating   = (Double[])d.Clone();
                    mr.PracticeAvgRating = ((mr.PracticeAvgRating + r.HGOverallRating) / 2.0);

                    int[] i = new int[mr.HGPatientCount.Length + 1];
                    mr.HGPatientCount.CopyTo(i, 0);
                    i[i.Length - 1]   = r.HGPatientCount;
                    mr.HGPatientCount = (int[])i.Clone();

                    results[indx] = mr;
                }
            }
        public void ServiceHost_ClientInputRecieved(object sender, ClientInputMessage e)
        {
            Trace.WriteLine("ClientInputRecieved Recieved User Id : " + e.idUsuario, "Warning");
            try
            {
                /*Crear Blob desde un Stream*/
                // Se obtiene la cuenta de almacenamiento
                storageAccount = CloudStorageAccount.Parse(
                    CloudConfigurationManager.GetSetting("StorageConnectionString"));

                // Se crea el cliente de blobs
                blobClient = storageAccount.CreateCloudBlobClient();

                // Obtencion del container
                container = blobClient.GetContainerReference(VariablesConfiguracion.containerName);

                Int64 subid = 1;

                String mustacheTemplateStr = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/App_Data/mustacheCloud.txt");

                //Template para generar los MDL
                FormatCompiler compiler     = new FormatCompiler();
                Generator      generatorMDL = compiler.Compile(mustacheTemplateStr);

                //Obtener parametros del cliente
                SimulacionParameters parametros = JsonConvert.DeserializeObject <SimulacionParameters>(e.message);

                //Barrido paramétrico
                //Especificar número de parámetros, n
                Int32 n = parametros.reacciones.Count(r => r.rate != null);
                if (n > 0)
                {
                    //Inicializo vector de inicios, fines y steps
                    LinkedList <Double> inicios = new LinkedList <Double>();
                    LinkedList <Double> fines   = new LinkedList <Double>();
                    LinkedList <Double> steps   = new LinkedList <Double>();
                    foreach (var reaccion in parametros.reacciones.FindAll(r => r.rate != null))
                    {
                        var inicio = reaccion.rate.rateInicio;
                        var fin    = reaccion.rate.rateFin;
                        var step   = reaccion.rate.rateStep;
                        inicios.AddLast(inicio);
                        fines.AddLast(fin);
                        steps.AddLast(step);
                    }

                    var iniciosArray = inicios.ToArray();
                    var finesArray   = fines.ToArray();
                    var stepsArray   = steps.ToArray();


                    //Defino vector lógico L para hacer barrido selectivo
                    Int32[] vectorLogico = new Int32[n];
                    for (int i = 0; i < n; i++)
                    {
                        //vectorLogico[i] = i < 5 ? 1 : 100;
                        vectorLogico[i] = 1000;
                    }

                    // Inicialización del vector j
                    Double[] j = new Double[n];
                    for (var k = 0; k < n; k++)
                    {
                        if (k == vectorLogico[k])
                        {
                            iniciosArray[k] += stepsArray[k];
                        }
                        j[k] = iniciosArray[k];
                    }

                    LinkedList <Double[]> jotas = new LinkedList <double[]>();
                    //Barrido parametrico
                    Int32 z = n - 1;
                    while (z >= 0)
                    {
                        if ((j[z] - finesArray[z]) * stepsArray[z] > 0)
                        {
                            j[z] = iniciosArray[z];
                            z--;
                        }
                        else
                        {
                            jotas.AddLast((double[])j.Clone()); //Para ver las combinaciones que creo
                            var    auxId  = subid;
                            Thread thread = new Thread(() => CrearMDL(e, auxId, (double[])j.Clone(), parametros, generatorMDL));
                            thread.Start();
                            //CrearMDL(e, subid, (double[])j.Clone(), parametros, generatorMDL);
                            z = n - 1;
                            subid++;
                        }
                        if (z >= 0)
                        {
                            j[z] += stepsArray[z];
                            if (z == vectorLogico[z])
                            {
                                j[z] += stepsArray[z];
                            }
                        }
                    }
                }
                else
                {
                    List <Double> valores = new List <double>();
                    CrearMDL(e, 0, valores.ToArray(), parametros, generatorMDL);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.Message);
                throw;
            }
        }