In this paper, a computationally efficient model-based method for determining patient-specific optimal acetabular cup alignment for total hip arthroplasty (THA) is presented. The proposed algorithm minimizes the risk of implant impingement and edge-loading, which are reported as the major causes of hip dislocation following THA. First, by using motion capture data recorded from the patient performing different daily activities, the hip contact force and the relative orientation of the femur and pelvis are calculated by a musculoskeletal model. Then, by defining two quantitative indices, i.e., angular impingement distance and angular edge-loading distance (AED), the risk of impingement and edge-loading are assessed for a wide range of cup alignments. Finally, three optimization criteria are introduced to estimate the optimal cup alignment with a tradeoff between the risk of impingement and edge loading. The results show that patient-specific characteristics such as pelvic tilt could significantly change the optimal cup alignment, especially the value of cup anteversion. Therefore, in some cases, the well-known Lewinnek safe zone may not be optimal, or even safe. Unlike other dynamic model-based methods, in this work, the need for force plate measurements is eliminated by estimating the ground reaction forces and moments, which makes this method more practical and cost-efficient. Furthermore, the low computational complexity due to analytical formulas makes this method suitable for both pre-operative and intra-operative planning.