The behaviour of smart obstacles in electromagnetic scattering: mathematical models as optimal control problems