Closed-Loop Artificial Pancreas Systems: Engineering the Algorithms