Numerical solution to the electromagnetic scattering by weakly nonlinear objects by using a genetic algorithm