In the last decade, with the introduction of smart meters to smart grids, demand response programs (DRPs) have been widely adopted to establish a generation and consumption balance. DRPs provide many benefits for efficient grid management. However, these programs are conducive to higher levels of dissatisfaction by changing grid customers' consumption patterns. This paper aims to investigate the effects of DRPs on social welfare (SW). To this end, the paper presents a mathematical model for SW during the implementation of DRPs. In the proposed model, the level of customer satisfaction is assumed the main factor contributing to SW. This mathematical model considers different types of DRPs in terms of their impacts on SW. The paper also seeks to obtain linear and nonlinear models of DRPs and the coefficient of participation (CoP). CoP as an indicator shows the percentage of customers who actively participate in each DRP and plays a significant role in the assessment of the SW level. Moreover, owing to the sparsity and variety of distribution network customers, load patterns are classified into different clusters to take the load types into account. As a matter of fact, this process aims to identify similar patterns and thus, the same level of satisfaction for each separate cluster. The classification process is performed by using a machine learning-based clustering method known as the Affinity Propagation (AP) algorithm. Then, the model calculates the level of SW for the clusters based on the usage of electrical equipment and the time of day when they are turned on. The obtained levels of SW help operators select the best programs for every cluster in terms of customer satisfaction, and achieve the highest performance of DRPs. Lastly, the model is evaluated using real data of a distribution network to ensure the effectiveness and accuracy of the model.