A bilevel strategy for optimizing control of a simulated moving bed (SMB) process is proposed. In the lower level, repetitive model predictive control (RMPC) is used to regulate product purities; in the upper level, optimal feed/desorbent flow rates and the switching period are determined. Both levels employ a fundamental SMB model reduced to a set of nonlinear discrete-time dynamic equations using the cubic spline collocation method and exact discretization. For RMPC, the SMB model is linearized successively along the operating trajectories seen in the previous switching period. It is assumed that the flow rates can be varied within a switching period and the average product purities over each switching period can be measured albeit with a significant analysis delay. Numerical studies using linear isotherms showed that the proposed strategy is successful at driving the process to the intended optimum and maintaining it there while robustly regulating the product purities despite various uncertainties.