Climate change is a major environmental issue facing humanity today, and the International Maritime Organization has accelerated the formulation of greenhouse gas emission policies. This study considers different carbon emission policies to construct an optimization model for container shipping, design an improved Whale Swarm Algorithm to solve related issues, and use the marginal carbon abatement cost method to analyze the deep-seated reasons for the optimization of liner shipping according to different carbon emission policies, thereby revealing the underlying reasons of emission-reduction decisions. The conclusions reveal that both kinds of carbon emission policies will reduce the profits of companies, the average speed of shipping, and carbon emissions. The carbon tax model has the greatest impact on the profits of shipping companies, and carbon cap-and-trade is easier to obtain support from enterprises. Sensitivity analysis shows that the implementation of carbon cap-and-trade or a carbon tax policy is closely and complexly related to the carbon trading price, carbon tax rate, fuel price, and ship size, and there is uncertainty.