We solve a central problem in the liner shipping industry called the liner shipping fleet repositioning problem (LSFRP). The LSFRP poses a large financial burden on liner shipping firms. During repositioning, vessels are moved between routes in a liner shipping network. Liner carriers wish to reposition vessels as cheaply as possible without disrupting cargo flows. The LSFRP is characterized by chains of interacting activities with a multicommodity flow over paths defined by the activities chosen. Despite its industrial importance, the LSFRP has received little attention in the literature. We introduce a novel mathematical model and a simulated annealing algorithm for the LSFRP with cargo flows that makes use of a carefully constructed graph; we evaluate these approaches using real-world data from our industrial collaborator. Additionally, we compare the performance of our approach against an actual repositioning scenario, one of many undertaken by our industrial collaborator in 2011. Our simulated annealing algorithm is able to increase the profit from $18.1 to $31.8 million using only a few minutes of CPU time. This shows that our algorithm could be used in a decision support system to solve the LSFRP.