One of the main challenges in Computer- Supported Collaborative Learning (CSCL) is group formation. Various approaches have been reported in the literature to tackle this problem, but none have offered an optimal solution. In this study a novel binary integer programming formulation was proposed to model the group formation problem and optimally assign each learner to the most appropriate group. In this contribution an online class of 32 learners was divided into two sections. The groups in the first section were formed by means of our suggested method. In the other section a modified version of K-Means clustering algorithm was used to assign participants to appropriate groups. Findings revealed that the suggested model was successful in optimally solving the problem in 8.27 seconds, on average. The results also disclosed that the proposed technique generated better outcomes in theory and in practice.