Dusty, first of all lets get some correct terminology.
I think that you are trying to create a MAGNETIC field.
An ELECTRO-MAGNETIC field is somewhat different, it is what comes off the antenna of a radio transmitter.
The earth has a magnetic field, which runs from the North (magnetic) pole to the South (magnetic) pole. The earths magnetic poles are not in quite the same places as the geographic poles, which is why magnetic compasses dont work too well in the far north or south.
The magnets you have have two poles (north and south), if the magnet is allowed to swing freely, the north pole of the magnet would point to the north pole of the earth and similarly the south pole of the magnet will point to the south pole of the earth.
This is how a compass works.
So, the magnets have their own magnetic field which you could use to distort the earths magnetic field around your ant farm.
I guess the way to test this is to take the magnets away from the farm and put a compass in the farm then you can see the direction of the earths magnetic field. Now bring the magnets to the farm and make the compass needle point (say) east instead of north. Now see if the ants do anything different!
It is also possible to create a magnetic field by passing an electric current through a coil of wire, you have now made an ELECTROMAGNET, and like the bar magnets it will have a MAGNETIC field with a north pole and a south pole, which may or may not confuse the ants.
The current flowing in the coil of wire must be a direct current such as comes from a battery. Also it is unlikely that the battery will last very long when connected to a few turns of wire.
The model train transformer MAY work, but beware, it may not give out a nice clean direct current but rectified alternating current, fine for driving a model train, but will create a magnetic field which pulses 120 times per second (if you are in USA, 100 times per second in Europe).
DO NOT UNDER ANY CIRCUMSTANCES CONNECT COILS OF WIRE TO A WALL SOCKET.
The likely result will be a big flash and a bang, and you and the ants will be off to that big ant farmin the sky.
I hope this helps.
JimB