% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the cost function objective for design
% optimization.
%
% (Number, Array of number, Number, struct) -> (Number)
% Returns objective
function objective = calcDesignOptimizationObjective(discrete, ...
continuous, finalTime, inputs)
continuousObjective = sum(continuous) / length(continuous);
if isfield(inputs, "finalTimeRange")
continuousObjective = continuousObjective / finalTime;
end
discreteObjective = sum(discrete) / length(discrete);
if isnan(discreteObjective); discreteObjective = 0; end
objective = continuousObjective + discreteObjective;
end