/*
         * public RinexNavigationParserGps(EphemerisResponse ephResponse)
         * {
         *  foreach (GnssEphemeris eph in ephResponse.ephList)
         *  {
         *      if (eph is GpsEphemeris)
         *      {
         *          this.eph.Add(new EphGps((GpsEphemeris)eph));
         *      }
         *  }
         *  this.iono = new IonoGps(ephResponse.ionoProto);
         * }
         */
        public SatellitePosition getGpsSatPosition(Observations obs, int satID, char satType, double receiverClockError)
        {
            long   unixTime = obs.getRefTime().getMsec();
            double range    = obs.getSatByIDType(satID, satType).getPseudorange(0);

            if (range == 0)
            {
                return(null);
            }

            EphGps eph = findEph(unixTime, satID, satType);

            if (eph.Equals(EphGps.UnhealthyEph))
            {
                return(SatellitePosition.UnhealthySat);
            }

            if (eph != null)
            {
                //			char satType = eph.getSatType();

                SatellitePosition sp = computePositionGps(obs, satID, satType, eph, receiverClockError);
                //			SatellitePosition sp = computePositionGps(unixTime, satType, satID, eph, range, receiverClockError);
                //if(receiverPosition!=null) earthRotationCorrection(receiverPosition, sp);
                return(sp);// new SatellitePosition(eph, unixTime, satID, range);
            }
            return(null);
        }
Beispiel #2
0
 void EnvironmentStep()
 {
     if (stepCount % DecisionPeriod == 0)
     {
         var actionReq = new BrainActionRequest();
         foreach (KeyValuePair <int, RemoteAction> agent in m_RemoteAgents)
         {
             float[] lowerObs = agent.Value.remoteAgent.GetLowerObservations();
             float[] upperObs = agent.Value.remoteAgent.GetUpperObservations();
             var     obs      = new Observations()
             {
             };
             obs.LowerObservations.AddRange(lowerObs);
             obs.UpperObservations.AddRange(upperObs);
             obs.ArucoMarkerID = agent.Value.remoteAgent.m_ArucoMarkerID;
             actionReq.Observations.Add(obs);
         }
         // Send sensor data to remote brain
         brainActionRes = brainServerClient.GetAction(actionReq);
         MakeActions(brainActionRes);
     }
     else if (TakeActionsBetweenDecisions)
     {
         MakeActions(brainActionRes);
     }
     stepCount++;
 }
Beispiel #3
0
        void run_mean_bench()
        {
            var cycles  = Pow2.T12;
            var samples = Pow2.T14;
            var src     = Numeric.force <long, double>(Random.Span <long>(samples, Interval.closed(-2000L, 2000L)));
            var ds      = Observations.Load(src);
            var dst     = 0.0;
            var last    = 0.0;

            var sw1 = stopwatch();

            for (var i = 0; i < cycles; i++)
            {
                last = ds.Mean(ref dst);
            }
            sw1.Stop();

            var sw2 = stopwatch();

            for (var i = 0; i < cycles; i++)
            {
                last = src.Avg();
            }
            sw2.Stop();

            ReportBenchmark("mkl-ssmean", cycles * samples, sw1.Elapsed);
            ReportBenchmark("direct", cycles * samples, sw2.Elapsed);
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(string id, [Bind("ApplicationUserID,CategorieId,dateObservation,rating,Nom,text,typeSuivie")] Observations observations)
        {
            if (id != observations.ApplicationUserID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(observations);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ObservationsExists(observations.ApplicationUserID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategorieId"]       = new SelectList(_context.Categories, "Id", "Id", observations.CategorieId);
            ViewData["ApplicationUserID"] = new SelectList(_context.Users, "Id", "Id", observations.ApplicationUserID);
            return(View(observations));
        }
Beispiel #5
0
        static unsafe Observations <T> ApplyRadixSort <T>(this Observations <T> samples, Observations <T> dst)
            where T : unmanaged
        {
            var dim         = samples.Dim;
            var sampleCount = samples.Count;
            var iStorage    = (int)VslSSMatrixStorage.VSL_SS_MATRIX_STORAGE_ROWS;
            var mformat     = VslSSMatrixStorage.VSL_SS_MATRIX_STORAGE_ROWS;
            var taskPtr     = IntPtr.Zero;

            if (typeof(T) == typeof(float))
            {
                VSL.vslsSSNewTask(ref taskPtr, ref dim, ref sampleCount, ref mformat,
                                  ref MemoryMarshal.Cast <T, float>(samples)[0]).AutoThrow();
            }
            else if (typeof(T) == typeof(double))
            {
                VSL.vsldSSNewTask(ref taskPtr, ref dim, ref sampleCount, ref mformat,
                                  ref MemoryMarshal.Cast <T, double>(samples)[0]).AutoThrow();
            }
            else
            {
                throw Unsupported.define <T>();
            }

            using var handle = VslSSTaskHandle.Wrap <T>(taskPtr);
            handle.Set(VSL_SS_ED_OBSERV_STORAGE, ref iStorage);
            handle.Set(VSL_SS_ED_SORTED_OBSERV, ref dst[0]);
            handle.Set(VSL_SS_ED_SORTED_OBSERV_STORAGE, ref iStorage);
            handle.Compute(VSL_SS_SORTED_OBSERV, VSL_SS_METHOD_RADIX);
            return(dst);
        }
Beispiel #6
0
 static unsafe ref T CalcMean <T>(this Observations <T> samples, ref T dst)
     where T : unmanaged
 {
     using var h2 = VslSSTaskHandle.Create(samples);
     h2.Set(VSL_SS_ED_MEAN, ref dst);
     h2.Compute(Calcs.VSL_SS_MEAN, VSL_SS_METHOD_FAST);
     return(ref dst);
 }
Beispiel #7
0
 static unsafe Observations <T> CalcVariance <T>(this Observations <T> samples, Observations <T> dst)
     where T : unmanaged
 {
     using var h2 = VslSSTaskHandle.Create(samples);
     h2.Set(VSL_SS_ED_2R_MOM, ref dst[0]);
     h2.Compute(Calcs.VSL_SS_2R_MOM, VSL_SS_METHOD_FAST);
     return(dst);
 }
Beispiel #8
0
        public void sumvals()
        {
            var src    = Random.Stream <double>().Take(16000).ToArray();
            var expect = src.Sum().Round(4);
            var actual = Observations.Load(src).Sum()[0].Round(4);

            Claim.require(gmath.within(expect, actual, .01));
        }
Beispiel #9
0
        private void SetObservations()
        {
            var o = new Observation
            {
                Id = 1,
                StartObservationDate = DateTime.Parse("12.03.2014"),
                EndObservationDate   = DateTime.Parse("12.03.2015"),
                PatientId            = 2,
                DiagnosisId          = 3,
                DoctorId             = 2
            };

            Observations.Add(o);

            o = new Observation
            {
                Id = 2,
                StartObservationDate = DateTime.Parse("22.09.2016"),
                EndObservationDate   = DateTime.Parse("12.10.2016"),
                PatientId            = 1,
                DiagnosisId          = 1,
                DoctorId             = 3
            };
            Observations.Add(o);

            o = new Observation
            {
                Id = 4,
                StartObservationDate = DateTime.Parse("01.01.2017"),
                EndObservationDate   = DateTime.Parse("13.01.2017"),
                PatientId            = 1,
                DiagnosisId          = 1,
                DoctorId             = 1
            };
            Observations.Add(o);

            o = new Observation
            {
                Id = 5,
                StartObservationDate = DateTime.Parse("25.09.2018"),
                EndObservationDate   = DateTime.Parse("07.10.2018"),
                PatientId            = 1,
                DiagnosisId          = 3,
                DoctorId             = 2
            };
            Observations.Add(o);

            o = new Observation
            {
                Id = 3,
                StartObservationDate = DateTime.Parse("10.10.2007"),
                EndObservationDate   = DateTime.Parse("12.10.2017"),
                PatientId            = 3,
                DiagnosisId          = 3,
                DoctorId             = 1
            };
            Observations.Add(o);
        }
Beispiel #10
0
 static unsafe Observations <T> CalcExtrema <T>(this Observations <T> samples, Observations <T> dst)
     where T : unmanaged
 {
     using var h2 = VslSSTaskHandle.Create(samples);
     h2.Set(VSL_SS_ED_MIN, ref dst[0]);
     h2.Set(VSL_SS_ED_MAX, ref dst[1]);
     h2.Compute(Calcs.VSL_SS_MAX | Calcs.VSL_SS_MIN, VSL_SS_METHOD_FAST);
     return(dst);
 }
Beispiel #11
0
        public void mean()
        {
            var src       = Random.Span <long>(Pow2.T14, Interval.closed(-2000L, 2000L));
            var expect    = gAlg.avg(src);
            var converted = Numeric.force <long, double>(src);
            var actual    = (long)Observations.Load(converted).Mean()[0];

            Claim.eq(expect, actual);
        }
        public void FilterAndJoin()
        {
            //filter subjects by arms
            if (Arms.Any())
            {
                Subjects = Subjects.FindAll(s => Arms.Select(a => a.Id).Contains(s.StudyArmId)).ToList();
            }

            Debug.WriteLine(Subjects.Count, " AFTER ARMS");

            //filter subjects by studies
            if (Studies.Any())
            {
                Subjects = Subjects.FindAll(subj => Studies.Select(st => st.Id).Contains(subj.StudyId)).ToList();
            }
            Debug.WriteLine(Subjects.Count, " AFTER Studies");

            //filter subjects by subCharacteristics
            if (SubjChars.Any())
            {
                Subjects = Subjects.FindAll(s => SubjChars.Select(sc => sc.SubjectId).Contains(s.Id)).ToList();
            }
            Debug.WriteLine(Subjects.Count, " AFTER SubjChars");

            //filter by visits
            //TODO

            //TODO : WILL RETRIEVE SUBJECTS THAT HAVE SAME UNIQUE IDS ACROSS PROJECTS  (i.e. need to load observations to Mongo with
            //TODO: DB subjectId
            //filter observations for filtered subjects
            Observations = Observations?.FindAll(o => Subjects.Select(s => s.UniqueSubjectId).Contains(o.USubjId));

            //filter subjects by selected observations
            if (Observations.Any() && ObservationsFiltered)
            {
                Subjects = Subjects.FindAll(s => Observations.Select(o => o.USubjId).Contains(s.UniqueSubjectId));
            }
            Debug.WriteLine(Subjects.Count, " AFTER syncing with observations");

            //FILTER SAMPLES BY SELECTED AND FILTERED SAMPLE CHARACTERISTICS
            if (SampleCharacteristics.Any())
            {
                Samples = Samples.FindAll(s => SampleCharacteristics.Select(sc => sc.SampleId).Contains(s.Id)).ToList();
            }

            //TODO: TEMP FILTERING BY COLLECTION STUDY DAY


            //SYNCHRONIZE SAMPLES AND SUBJECTS
            if (Samples.Any())
            {
                Samples  = Samples.FindAll(s => Subjects.Select(sc => sc.Id).Contains(s.SubjectId)).ToList();
                Subjects = Subjects.FindAll(sb => Samples.Select(sp => sp.SubjectId).Contains(sb.Id)).ToList();
            }
        }
Beispiel #13
0
        public ActionResult Create([Bind(Include = "Observation_Types,time_stamp,value")] Observations observations)
        {
            if (ModelState.IsValid)
            {
                db.Observations.Add(observations);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(observations));
        }
Beispiel #14
0
        static public Tuple <double, double> ComputeParas(
            IEnumerable <double> samples
            )
        {
            var meanVar = Observations.GetMeanVar(samples);
            var mean    = meanVar.Item1;
            var var     = meanVar.Item2;

            var p = ((1 - mean) / var - 1 / mean) / Math.Pow(mean, 2);
            var q = p * (1 / mean - 1);

            return(new Tuple <double, double>(p, q));
        }
Beispiel #15
0
        public void minval()
        {
            var samplesize = Pow2.T14;

            var s1Range = Interval.closed(350.0, 1000.0);
            var s1      = Random.Array <double>(samplesize, s1Range);
            var s1Max   = Observations.Load(s1).Max()[0];

            NumericClaims.neq(s1Max, 0.0);

            var zeroCount = s1.Count(x => x == 0);

            Notify($"Found {zeroCount} zeroes");
        }
Beispiel #16
0
 public override void OnEpisodeBegin()
 {
     if (firstDecision)
     {
         firstDecision = false;
         return;
     }
     Debug.Log("episode begin number: " + episodeCount);
     this.latestObservations = new Observations(1, 1, 1, 1, 1, 1, new float[4], new float[4]);
     episodeCount++;
     initGame();     // Find the ball and Reset the position of the ball and paddle and time
     SummonPlayer(); // Change the player
     stopped = false;
 }
Beispiel #17
0
        public async void GetObservationsAsync()
        {
            if (monitoringPressure)
            {
                var retrievedObservations = await observationRepository.GetByPatientAndBloodPressure(PatientId);

                foreach (var o in retrievedObservations)
                {
                    if (Observations.Where(observation => observation.Id == o.Id).ToList().Count() == 0)
                    {
                        Observations.Add(o);
                    }
                }
            }
            if (monitoringCholesterol)
            {
                var retrievedObservations = await observationRepository.GetByPatientAndTotalCholesterol(PatientId);

                foreach (var o in retrievedObservations)
                {
                    if (Observations.Where(observation => observation.Id == o.Id).ToList().Count() == 0)
                    {
                        Observations.Add(o);
                    }
                }
            }
            if (monitoringTobacco)
            {
                var retrievedObservations = await observationRepository.GetByPatientAndTobacco(PatientId);

                foreach (var o in retrievedObservations)
                {
                    if (Observations.Where(observation => observation.Id == o.Id).ToList().Count() == 0)
                    {
                        Observations.Add(o);
                    }
                }
            }
            foreach (var o in Observations)
            {
                foreach (var observer in Observers)
                {
                    observer.OnNext(o);
                }
            }
        }
Beispiel #18
0
        public bool deleteObservation(long id)
        {
            MySql.Data.MySqlClient.MySqlConnection conn;
            string myConnectionString = ConfigurationManager.ConnectionStrings["AzureDB"].ConnectionString;

            conn = new MySql.Data.MySqlClient.MySqlConnection();

            try
            {
                conn.ConnectionString = myConnectionString;
                conn.Open();

                Observations o = new Observations();
                MySql.Data.MySqlClient.MySqlDataReader mySQLReader = null;

                // Get The Observation with that ID (For Deleting)
                String sqlString = "SELECT * FROM observations WHERE id = " + id.ToString();
                MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn);

                mySQLReader = cmd.ExecuteReader();

                if (mySQLReader.Read())
                {
                    mySQLReader.Close();

                    // Delete the Observation with the id that was found
                    sqlString = "DELETE FROM observations WHERE id = " + id.ToString();
                    cmd       = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn);

                    cmd.ExecuteNonQuery();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
        public override async Task InitializeAsync(object navigationData)
        {
            if (Observations == null)
            {
                Observations = new ObservableCollection <Observation>();
            }

            IEnumerable <Observation> observations = await _observationsService.GetObservationsAsync();

            Observations.Clear();
            foreach (Observation observation in observations)
            {
                Observations.Add(observation);
            }

            await base.InitializeAsync(navigationData);
        }
        public SatellitePosition getGpsSatPosition(Observations obs, int satID, char satType, double receiverClockError)
        {
            RinexNavigationParserGalileo rnp = getRNPByTimestamp(unixTime, initialLocation);

            if (rnp != null)
            {
                if (rnp.isTimestampInEpocsRange(unixTime))
                {
                    return(rnp.getGalileoSatPosition(unixTime, range, satID, satType, receiverClockError));
                }
                else
                {
                    return(null);
                }
            }

            return(null);
        }
Beispiel #21
0
        public void radixSort()
        {
            var obs   = Pow2.T10;
            var dim   = Pow2.T08;
            var range = Interval.closed(-20f, 20f);

            var src    = Random.Array <float>(dim * obs, range);
            var sample = Observations.Load(src, dim);
            var sorted = sample.RadixSort();

            for (var i = 0; i < obs; i++)
            {
                var v = sorted.Observation(i);
                for (var j = 0; j < dim - 1; j++)
                {
                    ClaimNumeric.lteq(v[j], v[j + 1]);
                }
            }
        }
Beispiel #22
0
        public void CreateMt2203Generators()
        {
            var gencount   = Pow2.T08;
            var samplesize = Pow2.T16;
            var seeds      = Random.Array <uint>(gencount);
            var streams    = new MklRng[gencount];

            for (var i = 0; i < gencount; i++)
            {
                streams[i] = rng.mt2203(seeds[i], i);
            }

            var bufferF64 = new double[samplesize];
            var bufferU32 = new uint[samplesize];
            var bufferI32 = new int[samplesize];
            var ufRange   = Interval.closed(1.0, 250.0);

            for (var i = 0; i < gencount; i++)
            {
                var stream = streams[i];
                sample.uniform(stream, ufRange, bufferF64);
                Observations.Load(bufferF64, 1).Extrema();
                var max = Observations.Load(bufferF64, 1).Max()[0];
                NumericClaims.lteq(max, ufRange.Right);
                NumericClaims.neq(max, 0);

                sample.bits(stream, bufferU32);

                sample.bernoulli(stream, .40, bufferI32);
                for (var j = 0; j < samplesize; j++)
                {
                    Claim.require(bufferI32[j] == 0 || bufferI32[j] == 1);
                }

                sample.gaussian(stream, .75, .75, bufferF64);
                sample.laplace(stream, .5, .5, bufferF64);
            }

            for (var i = 0; i < gencount; i++)
            {
                streams[i].Dispose();
            }
        }
Beispiel #23
0
    public override void Initialize()
    {
        string strFilePath = @"./data.csv";

        File.WriteAllText(strFilePath, "session id;brick height;paddle speed;ball speed;paddle length;ball size;time;paddle distance;ballHits;ballBounces;amount of bricks;win/lose;type of personality;playerAPM;playerReactionTime;playerPaddleSafety;GEQ - content;GEQ - skillful;GEQ - occupied;GEQ - difficulty;satisfaction"); //COMMENT THIS IF YOU JUST WANT TO APPEND - last 5 are player attributes
        File.AppendAllText(strFilePath, Environment.NewLine);

        round = 0;
        generatePlayerList();
        this.latestObservations = new Observations(1, 1, 1, 1, 1, 1, new float[4], new float[4]);
        paddle             = GameObject.Find("Paddle");
        ball               = GameObject.Find("Ball");
        stopped            = true;
        requestingDecision = false;
        haveParameters     = false;
        RequestDecision();

        Time.timeScale = 10.0f;
    }
        public void Add(PROBLEM input, SOLUTION output)
        {
            foreach (var observer in Observers)
            {
                var observations = new List <Observation>();
                //observer.GetObservations(fact, observations);

                Observations.AddRange(observations);
            }

            var constraints = new List <Constraint <SOLUTION> >();

            // Use observations to form conclusions
            foreach (var observation in Observations)
            {
            }

            Constraints = constraints;
        }
Beispiel #25
0
    public override void CollectObservations()
    {
        // Target and Agent positions
        Observations obs = manager.getObservations();

        //AddVectorObs(obs.position_head);
        //AddVectorObs(obs.position_food);
        AddVectorObs(direction);
        AddVectorObs(Vector2.Distance(obs.position_food, obs.position_head));
        //foreach (Vector2 v in obs.position_tail) {
        //    AddVectorObs(v);
        //}
        //foreach (Vector2 v in obs.position_walls) {
        //    AddVectorObs(v);
        //}
        //foreach (Vector2 v in obs.position_empty) {
        //    AddVectorObs(v);
        //}
    }
Beispiel #26
0
 public Tracker(Patient patient, string type)
 {
     this.Type         = type;
     this.Patient      = patient;
     this.Observations = patient.GetAllObservationsByCodeText(type);
     Observations.Sort((x, y) =>
     {
         if (x.Issued == null || y.Issued == null)
         {
             return(1);
         }
         return(((DateTime)x.Issued).CompareTo((DateTime)y.Issued));
     });
     this.GraphData = new List <decimal>();
     foreach (Observation observation in Observations)
     {
         GraphData.Add((decimal)observation.MeasurementResult.Value);
     }
 }
Beispiel #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="samples"></param>
        /// <returns></returns>
        /// <remarks>
        ///	if X~BetaSpanned(min,max,p,q) then
        ///	 Y=(X-min)/(max-min) ~ BetaSpanned(0,1,p,q)=Beta(p,q)
        ///	accourding to std Beta,
        ///  E(Y)= p/(p+q), D(Y)=a * b / ((a + b) * (a + b) * (a + b + 1))
        ///  So
        ///  (E(X)-min)/(max-min)=p/(p+q), so E(x)=p/(p+q)*span+min
        ///   so E(x)= (aq+bp) / (p+q)
        ///   D(Y)=D(X)/span^2, so D(X)=D(Y)*span^2
        ///
        /// </remarks>
        static public Tuple <double, double> ComputeParas(
            IEnumerable <double> samples
            )
        {
            var min     = samples.Min();
            var max     = samples.Max();
            var span    = max - min;
            var meanVar = Observations.GetMeanVar(samples);
            var mean    = meanVar.Item1;
            var var     = meanVar.Item2;

            var lambda = (mean - min) * (max - mean) / var - 1;



            var p = lambda * (mean - min) / span;
            var q = lambda * (max - min) / span;

            return(new Tuple <double, double>(p, q));
        }
Beispiel #28
0
        private void CreateObsMethod()
        {
            if (Prescriptions == null || Prescriptions.Equals("") || BloodPressure.Equals("0") || Weight.Equals("0"))
            {
                MaterialMessageBox.ShowError("Remplir les champs obligatoire de l'observation (poids, pression sanguine, prescription");
                return;
            }
            Model.Observation obs = new Model.Observation()
            {
                bloodPressure = _bloodPressure,
                comment       = Comment,
                date          = Date,
                pictures      = Pictures.ToArray(),
                prescription  = Prescriptions.Split('\n'),
                weight        = _weight
            };
            int patientId = lastWindow.SelectedPatient.id;

            Observations.CreateObservation(patientId, obs);
            lastWindow.SelectedPatient.observations.Add(obs);
            lastWindow.SelectedObservation = obs;
            CloseWindow();
        }
Beispiel #29
0
        public async Task <IActionResult> Create([Bind("ApplicationUserID,CategorieId,rating,Nom,text,typeSuivie")] Observations observations)
        {
            if (ModelState.IsValid)
            {
                // enregister les info dans categories



                var userId = _userManager.GetUserId(HttpContext.User);
                observations.ApplicationUserID = userId;

                observations.dateObservation = DateTime.Now;
                _context.Add(observations);
                await _context.SaveChangesAsync();

                var listCat = await _context.Observations.ToListAsync();


                return(RedirectToAction("Create", new { IsSuccess = true }));
            }
            ViewData["CategorieId"]       = new SelectList(_context.Categories, "Id", "NomCategorie", observations.CategorieId);
            ViewData["ApplicationUserID"] = new SelectList(_context.Users, "Id", "UserName", observations.ApplicationUserID);
            return(View(observations));
        }
Beispiel #30
0
 public override void AddObservations()
 {
     Observations.Add(Energy, "Energy");
 }