Skip to main content

getIntegralBounds.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function gathers the maximum and minimum bounds for all continuous
% cost term function values.
%
% (struct) -> (struct)
% Computes max and min integral bounds


function inputs = getIntegralBounds(inputs)
[~, continuousAllowedTypes] = generateCostTermStruct("continuous", inputs.toolName);
[~, discreteAllowedTypes] = generateCostTermStruct("discrete", inputs.toolName);

inputs.maxIntegral = [];
inputs.minIntegral = [];
for i = 1:length(inputs.costTerms)
costTerm = inputs.costTerms{i};
if costTerm.isEnabled
if any(ismember(costTerm.type, continuousAllowedTypes)) && ...
~strcmp(costTerm.type, "user_defined")
inputs.maxIntegral = cat(2, inputs.maxIntegral, ...
costTerm.maxAllowableError);
elseif strcmp(costTerm.type, "user_defined")
if strcmp(costTerm.cost_term_type, "continuous")
inputs.maxIntegral = cat(2, inputs.maxIntegral, ...
costTerm.maxAllowableError);
end
elseif any(ismember(costTerm.type, continuousAllowedTypes)) && ...
any(ismember(costTerm.type, discreteAllowedTypes))
throw(MException('', ['Cost term type ' costTerm.type ...
' does not exist for this tool.']))
end
end
end
inputs.minIntegral = zeros(1, length(inputs.maxIntegral));
end