A model for determining an optimal shunt capacitor value at nonsinusoidal busbars combining three basic criteria maximizing the power factor, minimizing the line losses, and maximizing the transmission efficiency is developed. The choice of the capacitor value is constrained by the values that may cause resonance. This model was solved employing the penalty function approach and the golden Section Search algorithm for solving the linear load case. Furthermore nonlinear loads operating under nonsinusoidal conditions were investigated. The model for the nonlinear load is a two variable problem in L (inductor) and C (capacitor). The Direct Search Polytope algorithm is used. The solution of this model yields an optimal shunt LC compensator for the nonlinear lend. However, since there are limitations on the practical values of shunt capacitor, a discretizing approach making use of standard shunt capacitor values is employed to guarantee a solution that can be implemented.