Skip to main content

combineCostsIntoVector.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% Combines all tracking and penalization costs into a large vector
%
% (array of number, struct) -> (column vector of number)
% calculates the combined cost for the muscle tendon personalization module


function output = combineCostsIntoVector(costWeight, costs)
output = [ ...
% Minimize joint moment tracking errors
sqrt(costWeight(1)).* costs.momentMatching(:); ...
% Penalize difference of tact from set point
sqrt(costWeight(2)).* costs.activationTimePenalty(:); ...
% Penalize difference of Anonlin from set point
sqrt(costWeight(3)).* costs.activationNonlinearityPenalty(:); ...
% Penalize difference of lmo values from pre-calibrated values
sqrt(costWeight(4)).* costs.optimalFiberLengthPenalty(:);...
% Penalize difference of lts values from pre-calibrated values
sqrt(costWeight(5)).* costs.tendonSlackLengthPenalty(:);...
% Penalize difference of EMGScale from set point
sqrt(costWeight(6)).* costs.emgScalePenalty(:);...
% Penalize change of lMtilda from pre-calibrated values
sqrt(costWeight(7)).* costs.normalizedFiberLengthPenalty(:);...
% Penalize violation of lMtilda similarity between grouped muscles
sqrt(costWeight(8)).* costs.normalizedFiberLengthGroupedSimilarity(:);...
% Penalize violation of EMGScales similarity between grouped muscles
sqrt(costWeight(9)).* costs.emgScaleGroupedSimilarity(:);...
% Penalize violation of tdelay similarity between grouped muscles
sqrt(costWeight(10)).*costs.tdelayGroupedSimilarity(:);...
% Minimize passive force
sqrt(costWeight(11)).*costs.minPassiveForce(:);...
];
end