The paper describes a centralized Under Frequency Load Shedding (UFLS) method, where load shedding decisions are based on the solution of an optimization problem. The proposed approach anticipates the evolution of the grid frequency trajectory by means of a system dynamic model. Moreover, the method is augmented by the equations derived from the Optimal Power Flow (OPF) problem allowing to constrain asymptotic values of node voltages and line currents. The proposed OPF-based method differs from traditional UFLS methods as it enables the user to compute the minimum amount of load to be shed and, at the same time, provides a feasible grid trajectory. The trajectory of the system frequency due to the contingency, and the subsequent load shedding, is predicted over the entire time horizon by means of a second-order dynamic model. The feasibility and applicability of the proposed method are assessed by means of numerical simulations carried out using a real-time simulator, where the time-domain full-replica model of the IEEE 39-bus system has been implemented. Two contingency scenarios are investigated and the performance of the proposed method is compared against the UFLS strategy recommended by the European Network of Transmission System Operators (ENTSO-E). The metrics used for such a comparison are the amount of energy not served, the frequency variation and the violation of the grid safety constraints.