patch search controller algoritm, patch grid template