The answer is so simple.
A) Every American flag ship goes armed.
B) Every time an American vessel or American sailors are attacked, successful or not, we blow up something Somalian. A terrorist training camp, a Somalian vessel, anything that has the remotest connection with the pirates. And this should be done immediately, within 24 hours of an attack.
After a couple of these object lessons ALL pirates will steer clear of our vessels and only attack vessels other nations.
But, do our leaders have the fortitude to do this? No.