public async Task <ActionResult <Eps> > PostEps(Eps eps)
        {
            _context.Eps.Add(eps);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEps", new { id = eps.EpsCodigo }, eps));
        }
        public IActionResult Paciente()
        {
            int        contador         = 0;
            List <Eps> epss             = new List <Eps>();
            var        query            = "SELECT * FROM EPS;";
            var        connectionString = "Data Source=LAPTOP-R88EAA98\\SQLEXPRESS;Initial Catalog=Laboratorio;User ID=sa;Password=fnsp;Pooling=False";

            using (var connection = new SqlConnection(connectionString))
            {
                var command = new SqlCommand(query, connection);
                connection.Open();
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Eps nuevoEps = new Eps();
                        nuevoEps.ID     = (int)reader[0];
                        nuevoEps.Ciudad = reader[1].ToString();
                        epss.Add(nuevoEps);
                        ViewData["Eps" + contador.ToString()] = reader[1];
                        contador = contador + 1;
                    }
                    ViewBag.epss = epss;
                }
            }
            return(View());
        }
        public async Task <IActionResult> PutEps(int id, Eps eps)
        {
            if (id != eps.EpsCodigo)
            {
                return(BadRequest());
            }

            _context.Entry(eps).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EpsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre")] Eps eps)
        {
            if (id != eps.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(eps);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EpsExists(eps.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(eps));
        }
Esempio n. 5
0
        public async Task <RespuestaAux <Guid> > Editar(Guid id, EpsEditarCommand modeloCommand)
        {
            var result = new RespuestaAux <Guid>();

            try
            {
                var _item = Eps.EditarEps(
                    id: modeloCommand.Id,
                    nombre: modeloCommand.Nombre);


                if (_item.Exitoso == true)
                {
                    _context.Eps.Update(_item.Result);
                    await _context.SaveChangesAsync();

                    result.Result  = _item.Result.Id;
                    result.Exitoso = true;
                }
                else
                {
                    result.Exitoso = _item.Exitoso;
                    result.Mensaje = _item.Mensaje;
                }
            }
            catch (Exception e)
            {
                result.Exitoso = false;
                result.Mensaje = e.Message;
            }

            return(result);
        }
Esempio n. 6
0
        public async Task <RespuestaAux <Guid> > Crear(EpsAgregarCommand modeloCommand)
        {
            var result = new RespuestaAux <Guid>();

            try
            {
                var _item = Eps.AgregarEps(nombre: modeloCommand.Nombre);

                if (_item.Exitoso == true)
                {
                    await _context.AddAsync(_item.Result);

                    await _context.SaveChangesAsync();

                    result.Result  = _item.Result.Id;
                    result.Exitoso = true;
                }
                else
                {
                    result.Exitoso = _item.Exitoso;
                    result.Mensaje = _item.Mensaje;
                }
            }
            catch (Exception e)
            {
                result.Exitoso = false;
                result.Mensaje = e.Message;
            }

            return(result);
        }
Esempio n. 7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Eps eps = db.Tb_Eps.Find(id);

            db.Tb_Eps.Remove(eps);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 8
0
 public ActionResult Edit([Bind(Include = "Eps_Id,Eps_Nom,Eps_Registro")] Eps eps)
 {
     if (ModelState.IsValid)
     {
         db.Entry(eps).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(eps));
 }
Esempio n. 9
0
        public ActionResult Create([Bind(Include = "Eps_Id,Eps_Nom,Eps_Registro")] Eps eps)
        {
            if (ModelState.IsValid)
            {
                db.Tb_Eps.Add(eps);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(eps));
        }
Esempio n. 10
0
        public async Task <IActionResult> Create([Bind("Id,Nombre")] Eps eps)
        {
            if (ModelState.IsValid)
            {
                _context.Add(eps);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(eps));
        }
Esempio n. 11
0
        public async Task <IActionResult> Create([Bind("Id,RegistradoAt,ActualizadoAt,Nombre")] Eps eps)
        {
            if (ModelState.IsValid)
            {
                eps.Id = Guid.NewGuid();
                _context.Add(eps);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(eps));
        }
        /// <summary>
        ///     Returns true if Profitability instances are equal
        /// </summary>
        /// <param name="other">Instance of Profitability to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Profitability other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Roe == other.Roe ||
                     Roe != null &&
                     Roe.Equals(other.Roe)
                     ) &&
                 (
                     Npm == other.Npm ||
                     Npm != null &&
                     Npm.Equals(other.Npm)
                 ) &&
                 (
                     Gpm == other.Gpm ||
                     Gpm != null &&
                     Gpm.Equals(other.Gpm)
                 ) &&
                 (
                     Np == other.Np ||
                     Np != null &&
                     Np.Equals(other.Np)
                 ) &&
                 (
                     Eps == other.Eps ||
                     Eps != null &&
                     Eps.Equals(other.Eps)
                 ) &&
                 (
                     Mbr == other.Mbr ||
                     Mbr != null &&
                     Mbr.Equals(other.Mbr)
                 ) &&
                 (
                     Ts == other.Ts ||
                     Ts != null &&
                     Ts.Equals(other.Ts)
                 ) &&
                 (
                     Cs == other.Cs ||
                     Cs != null &&
                     Cs.Equals(other.Cs)
                 ));
        }
Esempio n. 13
0
        public static EpsDto ProyectarDto(Eps modelo)
        {
            var modeloDto = new EpsDto
            {
                Id            = modelo.Id,
                RegistradoAt  = modelo.RegistradoAt,
                ActualizadoAt = modelo.ActualizadoAt,
                Nombre        = modelo.Nombre
            };

            return(modeloDto);
        }
Esempio n. 14
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Eps eps = db.Tb_Eps.Find(id);

            if (eps == null)
            {
                return(HttpNotFound());
            }
            return(View(eps));
        }
Esempio n. 15
0
        public void TestDSLocalConcurrent()
        {
            const float Eps    = 0.2f;
            string      vwArgs = "--cb_explore_adf --epsilon " + Eps.ToString();
            DecisionServiceLocal <SimpleADFContext> dsLocal = new DecisionServiceLocal <SimpleADFContext>(vwArgs, 1, TimeSpan.MaxValue);
            var context = new SimpleADFContext {
                Id = "Shared", Actions = new int[] { 1, 2, 3 }
            };

            const int     NumThreads         = 16;
            const int     NumEventsPerThread = 25;
            List <Thread> threads            = new List <Thread>(NumThreads);

            int[] targetActionCnts = Enumerable.Repeat <int>(0, NumThreads).ToArray();
            int   idCounter        = 0;

            for (int i = 0; i < NumThreads; i++)
            {
                threads.Add(new Thread(() =>
                {
                    int id = Interlocked.Increment(ref idCounter) - 1;
                    Console.WriteLine("in thread {0}", id);
                    int action;
                    for (int j = 0; j < NumEventsPerThread; j++)
                    {
                        string guid = Guid.NewGuid().ToString();
                        action      = dsLocal.ChooseActionAsync(guid, context, 1).Result;
                        dsLocal.ReportRewardAndComplete((action == 2) ? 1.0f : 0.0f, guid);
                        targetActionCnts[id] += (action == 2) ? 1 : 0;
                    }
                }));
            }
            foreach (Thread t in threads)
            {
                t.Start();
            }
            foreach (Thread t in threads)
            {
                t.Join();
            }

            // Since the model is updated after each datapoint, we expect most exploit predictions
            // (1 - Eps) to be the middle action, but allow fro some slack.
            Console.WriteLine("Sum of target is {0}, total is {1}", targetActionCnts.Sum(), NumThreads * NumEventsPerThread);
            Assert.IsTrue(targetActionCnts.Sum() * 1.0 / (NumThreads * NumEventsPerThread) >= (1 - Eps) * 0.9);
        }
Esempio n. 16
0
        // override object.Equals
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            SubjectLarge s = (SubjectLarge)obj;

            return(base.Equals(obj) &&
                   Rank == s.Rank &&
                   EpsCount == s.EpsCount &&
                   Rating.EqualsExT(s.Rating) &&
                   Collection.EqualsExT(s.Collection) &&
                   Eps.SequenceEqualExT(s.Eps) &&
                   Characters.SequenceEqualExT(s.Characters) &&
                   Staff.SequenceEqualExT(s.Staff) &&
                   Topics.SequenceEqualExT(s.Topics) &&
                   Blogs.SequenceEqualExT(s.Blogs));
        }
 /// <summary>
 ///     Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked            // Overflow is fine, just wrap
     {
         int hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Roe != null)
         {
             hashCode = hashCode * 59 + Roe.GetHashCode();
         }
         if (Npm != null)
         {
             hashCode = hashCode * 59 + Npm.GetHashCode();
         }
         if (Gpm != null)
         {
             hashCode = hashCode * 59 + Gpm.GetHashCode();
         }
         if (Np != null)
         {
             hashCode = hashCode * 59 + Np.GetHashCode();
         }
         if (Eps != null)
         {
             hashCode = hashCode * 59 + Eps.GetHashCode();
         }
         if (Mbr != null)
         {
             hashCode = hashCode * 59 + Mbr.GetHashCode();
         }
         if (Ts != null)
         {
             hashCode = hashCode * 59 + Ts.GetHashCode();
         }
         if (Cs != null)
         {
             hashCode = hashCode * 59 + Cs.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 18
0
        public void TestDSLocalModelLearning()
        {
            const int   NumEvents = 100;
            const float Eps       = 0.2f;
            string      vwArgs    = "--cb_explore_adf --epsilon " + Eps.ToString();
            // Test both generic class and json string typed versions of DS local
            DecisionServiceLocal <SimpleADFContext> dsLocal     = new DecisionServiceLocal <SimpleADFContext>(vwArgs, 1, TimeSpan.MaxValue);
            DecisionServiceLocal <string>           dsLocalJson = new DecisionServiceLocal <string>(vwArgs, 1, TimeSpan.MaxValue);
            var context = new SimpleADFContext {
                Id = "Shared", Actions = new int[] { 1, 2, 3 }
            };

            int action, actionJson;
            int targetActionCnt = 0, targetActionJsonCnt = 0;

            // Generate interactions and reward the model for the middle action only (learning the
            // lowest/highest can be done even with bad featurization, which we want to catch).
            for (int i = 0; i < NumEvents; i++)
            {
                string guid = Guid.NewGuid().ToString();
                // Test generic class type
                action = dsLocal.ChooseActionAsync(guid, context, 1).Result;
                dsLocal.ReportRewardAndComplete((action == 2) ? 1.0f : 0.0f, guid);
                targetActionCnt += (action == 2) ? 1 : 0;

                string contextJson = JsonConvert.SerializeObject(context);
                actionJson = dsLocalJson.ChooseActionAsync(guid, contextJson, 1).Result;
                //TODO: The examples should look identical to VW, so predictions should be identical
                //Assert.IsTrue(action == actionJson);
                dsLocalJson.ReportRewardAndComplete((actionJson == 2) ? 1.0f : 0.0f, guid);
                targetActionJsonCnt += (actionJson == 2) ? 1 : 0;
            }
            // Since the model is updated after each datapoint, we expect most exploit predictions
            // (1 - Eps) to be the middle action, but allow fro some slack.
            Assert.IsTrue(targetActionCnt * 1.0 / NumEvents >= (1 - Eps) * 0.9);
            Assert.IsTrue(targetActionJsonCnt * 1.0 / NumEvents >= (1 - Eps) * 0.9);
        }
Esempio n. 19
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Ts != 0D)
            {
                hash ^= Ts.GetHashCode();
            }
            if (Cf != 0D)
            {
                hash ^= Cf.GetHashCode();
            }
            if (Cr != 0D)
            {
                hash ^= Cr.GetHashCode();
            }
            if (MassFl != 0)
            {
                hash ^= MassFl.GetHashCode();
            }
            if (MassFr != 0)
            {
                hash ^= MassFr.GetHashCode();
            }
            if (MassRl != 0)
            {
                hash ^= MassRl.GetHashCode();
            }
            if (MassRr != 0)
            {
                hash ^= MassRr.GetHashCode();
            }
            if (Eps != 0D)
            {
                hash ^= Eps.GetHashCode();
            }
            hash ^= matrixQ_.GetHashCode();
            hash ^= matrixR_.GetHashCode();
            if (CutoffFreq != 0)
            {
                hash ^= CutoffFreq.GetHashCode();
            }
            if (MeanFilterWindowSize != 0)
            {
                hash ^= MeanFilterWindowSize.GetHashCode();
            }
            if (MaxIteration != 0)
            {
                hash ^= MaxIteration.GetHashCode();
            }
            if (MaxLateralAcceleration != 0D)
            {
                hash ^= MaxLateralAcceleration.GetHashCode();
            }
            if (StandstillAcceleration != 0D)
            {
                hash ^= StandstillAcceleration.GetHashCode();
            }
            if (ThrottleDeadzone != 0D)
            {
                hash ^= ThrottleDeadzone.GetHashCode();
            }
            if (BrakeDeadzone != 0D)
            {
                hash ^= BrakeDeadzone.GetHashCode();
            }
            if (latErrGainScheduler_ != null)
            {
                hash ^= LatErrGainScheduler.GetHashCode();
            }
            if (headingErrGainScheduler_ != null)
            {
                hash ^= HeadingErrGainScheduler.GetHashCode();
            }
            if (steerWeightGainScheduler_ != null)
            {
                hash ^= SteerWeightGainScheduler.GetHashCode();
            }
            if (feedforwardtermGainScheduler_ != null)
            {
                hash ^= FeedforwardtermGainScheduler.GetHashCode();
            }
            if (calibrationTable_ != null)
            {
                hash ^= CalibrationTable.GetHashCode();
            }
            return(hash);
        }
Esempio n. 20
0
        public void TestEps()
        {
            var eps = new Eps();

            TestRoundTripEquality(eps);
        }
Esempio n. 21
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Ts != 0D)
            {
                hash ^= Ts.GetHashCode();
            }
            if (PreviewWindow != 0)
            {
                hash ^= PreviewWindow.GetHashCode();
            }
            if (Cf != 0D)
            {
                hash ^= Cf.GetHashCode();
            }
            if (Cr != 0D)
            {
                hash ^= Cr.GetHashCode();
            }
            if (MassFl != 0)
            {
                hash ^= MassFl.GetHashCode();
            }
            if (MassFr != 0)
            {
                hash ^= MassFr.GetHashCode();
            }
            if (MassRl != 0)
            {
                hash ^= MassRl.GetHashCode();
            }
            if (MassRr != 0)
            {
                hash ^= MassRr.GetHashCode();
            }
            if (Eps != 0D)
            {
                hash ^= Eps.GetHashCode();
            }
            hash ^= matrixQ_.GetHashCode();
            hash ^= reverseMatrixQ_.GetHashCode();
            if (CutoffFreq != 0)
            {
                hash ^= CutoffFreq.GetHashCode();
            }
            if (MeanFilterWindowSize != 0)
            {
                hash ^= MeanFilterWindowSize.GetHashCode();
            }
            if (MaxIteration != 0)
            {
                hash ^= MaxIteration.GetHashCode();
            }
            if (MaxLateralAcceleration != 0D)
            {
                hash ^= MaxLateralAcceleration.GetHashCode();
            }
            if (latErrGainScheduler_ != null)
            {
                hash ^= LatErrGainScheduler.GetHashCode();
            }
            if (headingErrGainScheduler_ != null)
            {
                hash ^= HeadingErrGainScheduler.GetHashCode();
            }
            return(hash);
        }