Partial forward algorithm