Skip to main content

calcDesignOptimizationPathConstraint.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the path constraint for design optimization.
%
% (struct, struct, struct) -> (2D matrix)
% Returns path constraint


function path = calcDesignOptimizationPathConstraint(values, modeledValues, ...
params)
path = [];
for i = 1:length(params.path)
constraintTerm = params.path{i};
if constraintTerm.isEnabled
switch constraintTerm.type
case "root_segment_residual_load"
path = cat(2, path, ...
calcRootSegmentResidualsPathConstraints(...
constraintTerm.load, ...
params.inverseDynamicMomentLabels, ...
modeledValues.inverseDynamicMoments));
case "muscle_model_moment_consistency"
path = cat(2, path, ...
calcMuscleActuatedMomentsPathConstraints(params, ...
modeledValues, constraintTerm.load));
case "torque_model_moment_consistency"
path = cat(2, path, ...
calcTorqueActuatedMomentsPathConstraints(params, ...
modeledValues, values.controlTorques, constraintTerm.load));
case "limit_muscle_activation"
path = cat(2, path, ...
calcMuscleActivationsPathConstraint(params, ...
modeledValues, constraintTerm.muscle));
case "limit_normalized_fiber_length"
path = cat(2, path, ...
calcNormalizedFiberLengthPathConstraint(params, ...
modeledValues, constraintTerm.muscle));
case "external_control_muscle_moment_consistency"
path = cat(2, path, ...
calcMuscleActuatedMomentsWithExternalAidPathConstraints( ...
params, modeledValues, values.externalTorqueControls, ...
constraintTerm.coordinate));
otherwise
throw(MException('', ['Constraint term type ' ...
constraintTerm.type ' does not exist for this tool.']))
end
end
end
path = scaleToBounds(path, params.maxPath, params.minPath);
end