Global optimization for discrete magnetostatic problems