Arm the crews of cargo and fishing ships with effective weapons and trained weapons handlers.
Of course this will never be done, as weapons in "civilian" hands nowadays is sooooo politically incorrect.
Not to mention that there would be an extra expense to the shipping companies (boo-hoo) that they now slough off at the risk to their crew members.
OTH, that solution now would perhaps not be feasible because the PUSSIFIED world has paid millions in ransom to the pirates so that they now can afford superior weaponry compared to what one cargo or fishing ship can afford.
BTW, similar corporate (oil company) greed and public stupidity has led to financing of the Arab wogs with billions if not trillions of "dollars" which helps finance their terrorism.
If the human race was not infected with a blind "need to breed" leading to overpopulation and insatiable energy demand, AND if alternate energy forms had been pursued, the Arab/Muslim countries would still be back rotting with fifth century technology, along with their stupid fifth century religion and culture.