This paper designs an energy optimal management in smart grid infrastructure. As a way of assigning the prioritized optimal energy of the adjacent energy provider from the energy-requesting user, if there is a surplus of energy from the energy provider, the smart grid as being the closest to the user preferentially allocates the optimal energy to the requesting user in order to maximize the user satisfaction.