expt: Testing bottom to top approach
This commit is contained in:
		@ -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))
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user