In this paper, a nonlinear 2D Optimal Control Problem (2DOCP) is considered. The quadratic performance index of a nonlinear cost function is endowed with the state and control functions. In this problem, the dynamic constraint of the system is given by a classical diffusion equation. This article is concerned with a generalization of Lagrangian functions. Besides, a Generalized Lagrangian Jacobi-Gauss-Radau (GLJGR)-collocation method is introduced and applied to solve the aforementioned 2DOCP. Based on initial