Atomic sites with multiple substituents are common in minerals, and correct site assignment of substituents in structure refinement is of fundamental importance. Substituents must be assigned to particular sites to fit the observed site scattering and chemical analysis, but the assignments are rarely made with mathematical rigor. We propose a quadratic programming approach to calculating optimal site assignments, thereby providing crystallographers with a mathematically robust starting point for the determination of site occupancies. Our program, OccQP, implements this approach within the widely used Matlab programming environment. User-defined weights may be assigned to the structural formula, site scattering, and bond-valence sums. The program is useful for evaluation of site occupancies in newly refined structures and re-evaluation of previously published structures with ad hoc site assignments.