diff --git a/code/lib/lmdk_sel.py b/code/lib/lmdk_sel.py index eb2071a..3420005 100644 --- a/code/lib/lmdk_sel.py +++ b/code/lib/lmdk_sel.py @@ -269,6 +269,41 @@ def get_opts_from_bottom(seq, lmdks): return opts +def get_opts_from_bottom_h(seq, lmdks): + # Create histogram + hist, h = get_hist(seq, lmdks) + # Keep track of points + hist_cur = np.array([h]*len(hist)) + while np.sum(hist_cur) > len(seq): + hist_cur[-1] -= 1 + # The options to be returned + hist_opts = [] + # Keep removing points until the minimum is reached + while np.sum(hist_cur) > np.sum(hist): + # Track the minimum (best) evaluation + diff_min = float('inf') + # The candidate option + hist_cand = np.copy(hist_cur) + # Check every possibility + for i, h_i in enumerate(hist_cur): + # Can we remove one more point? + if h_i - 1 >= hist[i]: + hist_tmp = np.copy(hist_cur) + hist_tmp[i] -= 1 + # Find difference from original + # diff_cur = get_norm(hist, hist_tmp) # Euclidean + diff_cur = get_emd(hist, hist_tmp) # Wasserstein + # Remember if it is the best that you've seen + if diff_cur < diff_min: + diff_min = diff_cur + hist_cand = np.copy(hist_tmp) + # Update current histogram + hist_cur = np.copy(hist_cand) + # Add current best to options + hist_opts.append(hist_cand) + # Return options + return hist_opts + def get_non_opts_from_bottom(seq, lmdks): # Evaluate the original eval_orig = eval_seq(get_rel_dists(seq, [], lmdks)) diff --git a/rslt/lmdk_sel_cmp/lmdk_sel_cmp-emd_bottom.pdf b/rslt/lmdk_sel_cmp/lmdk_sel_cmp-emd_bottom.pdf new file mode 100644 index 0000000..be40ef3 Binary files /dev/null and b/rslt/lmdk_sel_cmp/lmdk_sel_cmp-emd_bottom.pdf differ diff --git a/rslt/lmdk_sel_cmp/lmdk_sel_cmp-norm_bottom.pdf b/rslt/lmdk_sel_cmp/lmdk_sel_cmp-norm_bottom.pdf new file mode 100644 index 0000000..1be7eec Binary files /dev/null and b/rslt/lmdk_sel_cmp/lmdk_sel_cmp-norm_bottom.pdf differ