A discrete-time model for optimizing the rail port cycle