With on-board sensors such as camera, radar, and Lidar, connected and automated vehicles (CAVs) can sense the surrounding environment and be driven autonomously and safely by themselves without colliding into other objects on the road. CAVs are also able to communicate with each other and roadside infrastructure via vehicle-to-vehicle and vehicle-to-infrastructure communications, respectively, sharing information on the vehicles’ states, signal phase and timing (SPaT) information, enabling CAVs to make decisions in a collaborative manner. As a typical scenario, ramp control attracts wide attention due to the concerns of safety and mobility in the merging area. In particular, if the line-of-the-sight is blocked (because of grade separation), then neither mainline vehicles nor on-ramp vehicles may well adapt their own dynamics to perform smoothed merging maneuvers. This may lead to speed fluctuations or even shockwave propagating upstream traffic along the corridor, thus potentially increasing the traffic delays and excessive energy consumption. In this project, the research team proposed a hierarchical ramp merging system that not only allowed microscopic cooperative maneuvers for connected and automated electric vehicles on the ramp to merge into mainline traffic flow, but also had controllability of ramp inflow rate, which enabled macroscopic traffic flow control. A centralized optimal control-based approach was proposed to both smooth the merging flow and improve the system-wide mobility of the network. Linear quadratic trackers in both finite horizon and receding horizon forms were developed to solve the optimization problem in terms of path planning and sequence determination, and a microscopic electric vehicle (EV) energy consumption model was applied to estimate the energy consumption. The simulation results confirmed that under the regulated inflow rate, the proposed system was able to avoid potential traffic congestion and improve the mobility (in terms of average speed) as much as 115%, compared to the conventional ramp metering and the ramp without any control approach. Interestingly, for EVs (connected and automated EVs in this study), the improved mobility may not necessarily result in the reduction of energy consumption. The “sweet spot” of average speed ranges from 27–34 mph for the EV models in this study.