Skip to content
Snippets Groups Projects
Commit d36659dc authored by xiyehu2's avatar xiyehu2
Browse files

switched to JV algorithm for path finding.

parent fc6b2954
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ import numpy as np ...@@ -4,6 +4,7 @@ import numpy as np
from scipy.interpolate import interp1d from scipy.interpolate import interp1d
from AWG import * from AWG import *
import cupy as cp import cupy as cp
import scipy.optimize as spopt
class Waveform: class Waveform:
...@@ -318,26 +319,9 @@ def get_rearrange_paths( ...@@ -318,26 +319,9 @@ def get_rearrange_paths(
:param t_idx: indices of tweezer positions in target pattern. :param t_idx: indices of tweezer positions in target pattern.
:returns: 2d numpy array containing moving path trajectories :returns: 2d numpy array containing moving path trajectories
""" """
if len(f_idx) < len(t_idx): cm = abs(np.subtract.outer(f_idx, t_idx))
return np.array([]) row, col = spopt.linear_sum_assignment(cm)
l_ptr = np.searchsorted(f_idx, t_idx[0]) return np.stack([f_idx[row], t_idx]).T
r_ptr = np.searchsorted(f_idx, t_idx[-1], side='right') - 1
n_unpaired = len(t_idx) - len(f_idx[l_ptr:r_ptr+1])
while n_unpaired > 0:
if l_ptr == 0:
r_ptr += n_unpaired
break
if r_ptr == len(f_idx) - 1:
l_ptr -= n_unpaired
break
l_dist = abs(t_idx[0] - f_idx[l_ptr - 1])
r_dist = abs(f_idx[r_ptr + 1] - t_idx[-1])
if l_dist < r_dist:
l_ptr -= 1
else:
r_ptr += 1
n_unpaired -= 1
return np.vstack((f_idx[l_ptr:r_ptr+1], t_idx)).T
def create_moving_array_old(path_table: np.ndarray, paths: np.ndarray) -> np.ndarray: def create_moving_array_old(path_table: np.ndarray, paths: np.ndarray) -> np.ndarray:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment