Optimize masses and forces.