Combat effectiveness Calculations

Does anyone know how combat effectiveness is calculated? Want to write a program that optimizes squads/echelons.