Add AP algorithm