We formulate and study an optimal control problem for traffic regulation via variable speed limit on a single road. Using the well established Lighthill-Whitham-Richards model with Newell-Daganzo flux, we aim at minimizing the quadratic error to a desired outflow for an assigned inflow. We first provide existence results and compute analytically the cost functional variation. Then we formulate an instantaneous policy, depending only on the density at the exit point. Then we compare three strategies: The instantaneous policy; Random exploration of control space; Steepest decent using numerical expression of gradient. We show that the gradient technique is able to achieve a cost within 10% of random exploration minimum, while keeping the computational cost much lower. On the other side, the instantaneous policy is outperformed by the other two.