Cruise itinerary planning using R, LPSolve

Now that nearly every company collects data about its operations, it’s possible for decisions to be made in a systematic data-informed way, minimizing the use of heuristics. This applies especially to an operations-centric enterprise who’s bottom-line is improved considerably if optimal solutions are found for difficult problems.

Many operations problems can be formulated as a Linear Programming problem, and R has a fantastic package – LPSolve to handle those, even with integer constraints (known as Mixed Integer Linear Programming or MILP). Let me illustrate how LPSolve can solve operations problems with a real example from the Cruise ship business.

How do cruise ship operators decide on the itinerary they should follow? Bahamas alone has about 30 ports. A 3-day cruise has to carefully select from those. What factors would they consider? Here are only a few –

1. Attractiveness of a port to tourists.

2. Profitability for the cruise operator.

3. Number of ports visited.

4.Time required for visiting the attractions in each port.

5. Congestion at the port, how many cruise ships can simultaneously dock?

6. Constraints on Port types (A 7-day cruise must include at least 2, and at most 4 ports with beaches)

Here is how you formulate the problem of maximizing customer satisfaction while maintaining competitive profitability and satisfying all of the other constraints in LPSolve –




Slicing, Selecting from pandas dataframes

I’m exploring Pandas DataFrame capabilities; It makes sense to devote some time in understanding the commonly used capabilities well.

These are the topics covered in this post –

1. Ways to create a dataframe – using a dict, using an ndarray

2. Creating a dataframe with indexes

3. Slicing and selecting rows filtering the data, selecting rows/columns according to criteria

4. Using groupby and apply on dataframes.

All the code is contained in an Ipython Notebook here . It’s a very convenient tool for illustration as it seamlessly combines code, text, plots and even supports latex markup.

Note: The code uses Pandas version 0.12 – the stable version the time of writing.