/// <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; }
public void length_NullInput() { vector = null; vector.length(); }
public void length_ValidInput() { vector = new Vector(-4.0, -25.0, -1.0); double expected = Math.Sqrt(vector.dotProduct(vector)); Assert.AreEqual(expected, vector.length()); vector2 = new Vector(12.0, 15.0, 20.0); expected = Math.Sqrt(vector2.dotProduct(vector2)); Assert.AreEqual(expected, vector2.length()); }
public void length_AllZero() { vector = new Vector(0.0, 0.0, 0.0); Assert.AreEqual(0.0, vector.length()); }