Example #1
0
        /// <summary>
        /// Implements the mental workload (MWL) formula as defined in the scientific literature
        /// </summary>
        /// <param name="lipValue">The level of information processing</param>
        /// <param name="moValue">The mental occupancy</param>
        /// <param name="tssValue">The task set switches</param>
        /// <param name="frameCount">Number of tasks in the calculation frame</param>
        /// <returns>The calculated MWL-value</returns>
        public static double calculateMentalWorkLoad(double lipValue, double moValue, double tssValue, int frameCount)
        {
            //Console.WriteLine("lip = " + lipValue + " mo = " + moValue + " tss = " + tssValue);
            double mwlValue = 0;
            double normalizedTssValue = 0;

            // Define the bounds as tuples (lower bound, upper bound)
            Tuple<int, int> lipBounds = Tuple.Create(1, 3);
            Tuple<int, int> moBounds = Tuple.Create(0, 1);
            Tuple<int, int> tssBounds = Tuple.Create(0, Math.Max(frameCount - 1, 0));

            // Project all metrics on the [0, 1] interval
            double normalizedLipValue = (lipValue - lipBounds.Item1) / lipBounds.Item2;
            double normalizedMoValue = (moValue - moBounds.Item1) / moBounds.Item2;

            // Avoid NaN values!
            if (tssBounds.Item2 != 0)
            {
                normalizedTssValue = (tssValue - tssBounds.Item1) / tssBounds.Item2;
                Console.WriteLine(normalizedTssValue);
            }

            Vector diagonalVector = new Vector(1.0, 1.0, 1.0);
            Vector mwlVector = new Vector(normalizedLipValue, normalizedMoValue, normalizedTssValue);

            // The distance to the origin (the length of the input vector)
            // For now we use this as MWL value, since the formula appeared to be unuseable
            double distanceToOrigin = mwlVector.length();

            Vector mwlProjDiagonal = mwlVector.orthogonalProjection(diagonalVector);

            Vector zVector = mwlVector - mwlProjDiagonal;

            double distanceToDiagonal = zVector.length();
            mwlValue = distanceToOrigin - (distanceToDiagonal/2);

            return mwlValue;
        }
Example #2
0
        public void orthogonalProjection_NegativeValues()
        {
            vector = new Vector(1.0, 2.0, 3.0);
            vector2 = new Vector(-4.0, -25.0, -1.0);

            double fraction = vector.dotProduct(vector2)/vector2.dotProduct(vector2);
            Vector newVector =  new Vector (fraction*(-4.0), (-25.0) * fraction, (-1.0)* fraction);
            Assert.IsTrue(newVector.Equals(vector.orthogonalProjection(vector2)));
        }
Example #3
0
 public void orthogonalProjection_Self()
 {
     vector = new Vector(1.0, 2.0, 3.0);
     Assert.IsTrue(vector.Equals(vector.orthogonalProjection(vector)));
 }
Example #4
0
        public void orthogonalProjection_AllZero()
        {
            vector = new Vector(0.0, 0.0, 0.0);

            Assert.IsNull(vector.orthogonalProjection(vector));

            Assert.IsNotNull(vector.orthogonalProjection((new Vector(1.0, 1.0, 1.0))));
            Assert.AreEqual(new Vector(0.0, 0.0, 0.0), vector.orthogonalProjection((new Vector(1.0, 1.0, 1.0))));
        }