Beispiel #1
0
        public void TemplatedGetProfileUnitTest()
        {
            SystemState state = new SystemState();
            HSFProfile<int> intProf = new HSFProfile<int>(0, 1);
            intProf.Add(1, 2);
            intProf.Add(2, -1);

            StateVarKey<int> intKey = new StateVarKey<int>("testIntVar");
            state.SetProfile(intKey, intProf);

            HSFProfile<double> doubleProf = new HSFProfile<double>(0, 1);
            doubleProf.Add(1, 2);
            doubleProf.Add(2, -1);

            StateVarKey<double> doubleKey = new StateVarKey<double>("testDoubleVar");
            state.SetProfile(doubleKey, doubleProf);

            HSFProfile<Matrix<double>> matrixProf = new HSFProfile<Matrix<double>>(0, new Matrix<double>(1, 2, 1));
            matrixProf.Add(1, new Matrix<double>(1, 2, 2));
            matrixProf.Add(2, new Matrix<double>(1, 2, -1));

            var matrixKey = new StateVarKey<Matrix<double>>("testMatrixVar");
            state.SetProfile(matrixKey, matrixProf);

            HSFProfile<int> newIntProf = state.GetProfile(intKey);
            HSFProfile<double> newDoubleProf = state.GetProfile(doubleKey);
            HSFProfile<Matrix<double>> newMatrixProf = state.GetProfile(matrixKey);

            Console.WriteLine();
        }
Beispiel #2
0
        /// <summary>
        /// Adds a Matrix Profile value pair to the state with the given key. If no Profile exists, a new Profile is created
        /// with the corresponding key. If a Profile exists with that key, the pair is appended onto the end of the Profile. </summary>
        /// Ensure that the Profile is still time ordered if this is the case.<param name="key"></param>
        /// <param name="pairIn"></param>
        public void AddValue(StateVarKey <Matrix <double> > key, KeyValuePair <double, Matrix <double> > pairIn)
        {
            HSFProfile <Matrix <double> > valueIn  = new HSFProfile <Matrix <double> >(pairIn);
            HSFProfile <Matrix <double> > valueOut = new HSFProfile <Matrix <double> >();

            if (!Mdata.TryGetValue(key, out valueOut)) // If there's no Profile matching that key, insert a new one.
            {
                Mdata.Add(key, valueIn);
            }
            else // Otherwise, add this data point to the existing Profile.
            {
                valueOut.Add(pairIn); //TODO: make sure this is ok. was formally iterator.second.data
            }
        }
        public void TemplatedGetProfileUnitTest()
        {
            SystemState      state   = new SystemState();
            HSFProfile <int> intProf = new HSFProfile <int>(0, 1);

            intProf.Add(1, 2);
            intProf.Add(2, -1);

            StateVarKey <int> intKey = new StateVarKey <int>("testIntVar");

            state.setProfile(intKey, intProf);

            HSFProfile <double> doubleProf = new HSFProfile <double>(0, 1);

            doubleProf.Add(1, 2);
            doubleProf.Add(2, -1);

            StateVarKey <double> doubleKey = new StateVarKey <double>("testDoubleVar");

            state.setProfile(doubleKey, doubleProf);

            HSFProfile <Matrix <double> > matrixProf = new HSFProfile <Matrix <double> >(0, new Matrix <double>(1, 2, 1));

            matrixProf.Add(1, new Matrix <double>(1, 2, 2));
            matrixProf.Add(2, new Matrix <double>(1, 2, -1));

            var matrixKey = new StateVarKey <Matrix <double> >("testMatrixVar");

            state.setProfile(matrixKey, matrixProf);

            HSFProfile <int>              newIntProf    = state.GetProfile(intKey);
            HSFProfile <double>           newDoubleProf = state.GetProfile(doubleKey);
            HSFProfile <Matrix <double> > newMatrixProf = state.GetProfile(matrixKey);

            Console.WriteLine();
        }