Abstract In a power grid system, utility is a measure of the satisfaction of users’ electricity consumption; cost is a monetary value of electricity generated by the supplier. The utility and cost functions represent the satisfaction of different users and the supplier. Quadratic utility, logarithmic utility, and quadratic cost functions are widely used in social welfare maximization models of real-time pricing. These functions are not universal; they have to be discussed in detail for individual models. To overcome this problem, a piece-wise linear utility function and a piece-wise linear cost function with general properties are proposed in this paper. By smoothing the piece-wise linear utility and cost functions, a social welfare maximization model can be transformed into a differentiable convex optimization problem. A dual optimization method is used to solve the smoothed model. Through mathematical deduction and numerical simulations, the rationality of the model and the validity of the algorithm are verified as long as the elastic and cost coefficients take appropriate values. Thus, different user types and the supplier can be determined by selecting different elastic and cost coefficients.