From 9a148ff5a1114d855381e4e81920d8d1c2e13ef0 Mon Sep 17 00:00:00 2001 From: Craig Warren Date: Fri, 1 Apr 2016 16:54:50 +0100 Subject: [PATCH] Testing new compactness fitness function. --- user_libs/optimisation_taguchi_fitness.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/user_libs/optimisation_taguchi_fitness.py b/user_libs/optimisation_taguchi_fitness.py index cecaa806..dd13e530 100644 --- a/user_libs/optimisation_taguchi_fitness.py +++ b/user_libs/optimisation_taguchi_fitness.py @@ -211,17 +211,20 @@ def compactness(filename, args): thresholdpeak = 1e-3 peaks = [peak for peak in peaks if np.abs(outputdata[peak]) > thresholdpeak] - # Percentage of maximum value to measure compactness of signal - durationthreshold = 2 - # Check if there is a peak/trough smaller than threshold - durationthresholdexist = np.where(np.abs(outputdata[peaks]) < (peak * (durationthreshold / 100)))[0] - if durationthresholdexist.size == 0: - compactness = time[peaks[-1]] - else: - time2threshold = time[peaks[durationthresholdexist[0]]] - compactness = time2threshold - time[min(peaks)] + # Amplitude ratio of the 1st to 3rd peak - hopefully be a measure of a compact envelope + compactness = np.abs(outputdata[peaks[0]]) / np.abs(outputdata[peaks[2]]) + +# # Percentage of maximum value to measure compactness of signal +# durationthreshold = 2 +# # Check if there is a peak/trough smaller than threshold +# durationthresholdexist = np.where(np.abs(outputdata[peaks]) < (peak * (durationthreshold / 100)))[0] +# if durationthresholdexist.size == 0: +# compactness = time[peaks[-1]] +# else: +# time2threshold = time[peaks[durationthresholdexist[0]]] +# compactness = time2threshold - time[min(peaks)] - return (1 / compactness) + return compactness