Monthly Archives: December 2009

Using Airline Miles to Buy Magazines: a Hidden Deeper Lesson

Last month, I received a letter from American Airlines’ Rewards Processing Center saying that I have 4735 miles that are about to expire and asking whether I’d be interested in redeeming them for some magazine subscriptions. These were the choices:

Magazine Issues Miles Needed
Afar 6 600
Architectural Digest 12 800
Barron’s 26 1700
Business Week 50 1600
Cat Fancy 12 500
Cigar Aficionado 6 400
Daily Variety 252 5500
Diabetes Forecast 12 500
ESPN the Magazine 26 500
Ebony and Jet 38 800
Elle 12 400
Entertainment Weekly 55 1300
Essence 12 500
Essence 2yrs 24 800
Fortune 25 1400
Golf Digest 12 700
Golf Magazine 12 700
Golfweek 45 1300
Martha Stewart Living 24 1400
Money 12 800
New York Magazine 46 700
Sports Illustrated 56 1400
SI and Golf Mag 68 1500
Sports Illustrated KIDS 12 1000
The Economist 51 3200
The Wall Street Journal 190 2800
US News & World Report 12 700
Variety 50 5500
Wine Spectator 15 900
Wired 12 400

Wow! 30 different magazines! How could I possibly decide…oh, wait! Maybe I can use some analytical techniques to help me make a better decision…what’s that thing called again…O.R.!!!

First, what do I want to accomplish?

a) Get as many issues of whatever magazine as possible: this is what a dentist’s office or any place with a waiting room might want to do. Note that the WSJ subscription provides 190 issues, but let’s say I only want to consider actual magazines. One possible answer is to subscribe to ESPN the Magazine, Ebony and Jet, Entertainment Weekly, New York Magazine, and Sports Illustrated. That will buy me 221 issues and use 4700 of my 4735 miles. Just out of curiosity, I could have gotten 286 issues if I hadn’t excluded the WSJ.

b) Get as many different subscriptions as possible: This one is easy. Just pick the magazines that require the least number of miles. One solution is Afar, Cat Fancy, Cigar Aficionado, Diabetes Forecast, ESPN the Magazine, Elle, Essence, US News & World Report, and Wired. That’s a total of 9 subscriptions, using 4500 of my 4735 miles (a waste of 235 miles).

c) Get the “best” 9 magazines you can afford: Since I know I can get 9 subscriptions, what are the 9 that make me use the most out of my 4735 miles? Maybe they’ll constitute a better set of 9 than those I found in item (b) above (positive correlation between quality and miles needed?). In this case the answer is to substitute New York Magazine for Essence in the set of 9 found in item (b). This alternative totals 144 issues and wastes only 35 miles.

d) Get the 9 magazines that provide the largest total number of issues: In that case I’d want to go with Cat Fancy, Cigar Aficionado, Diabetes Forecast, ESPN the Magazine, Ebony and Jet, Elle, Essence, New York Magazine and Wired. That’s a total of 176 issues and a waste of 35 miles as well.

For those of you who are thinking “who cares?”, don’t let appearances fool you. Say that I am United Way and 4735 is my budget (in thousands of US$). There are 30 charities (“magazines”) asking me for money (the “miles needed”) and telling me that they will help a certain number of people (the “issues”, in thousands). If I fund the charities in rows 9, 10, 12, 21 and 22 of the above table, I’ll spend US$ 4,700,000 and help 221 thousand people. That’s the best I can do! (if I am not allowed to fund the charity in row 26).

Lots of other problems can be cast into this framework. Another example: NASA is sending a spaceship to Mars. My available miles are the spaceship’s cargo capacity, the magazines are scientific experiments to be conducted in space (each requiring equipment to be loaded into the spaceship (the “miles needed”) and promising a certain (quantifiable) scientific benefit (the “issues”). This a generic resource allocation problem and the mathematical model we have used here is called The 0-1 Knapsack Problem.

Technical Details:

Want to solve your own budget allocation problem? Here’s how you can do it. We have n projects that require funding and a budget B . For each project i = 1,\ldots,n , let m_i be how much money it needs and let p_i be its payoff (e.g. lives saved). Let the binary variable x_i be equal to 1 if we decide to allocate money to project i , and equal to zero otherwise.

The objective is to maximize the payoff \sum_{i=1}^n p_i x_i .

The constraint is to respect the budget: \sum_{i=1}^n m_i x_i \leq B .

This model also allows you to include some useful side constraints. For example: “if I fund project i , then I must also fund project j ” would be written as x_i \leq x_j . And “if I fund project i , then I cannot fund project j “, would become x_i + x_j \leq 1 . I’ve talked about these kinds of logical conditions in another post.

Here’s the AMPL file I used to solve the magazine problem and its variations. Enjoy!

P.S.: Being an Economics major and an amazing cook, my wife requested The Economist and Martha Stewart Living; that’s what her objective function told her to do, I guess.


Filed under Applications, Integer Programming, Knapsack, Modeling

Using a Mathematical Model to Predict the Likelihood of Insurgent Attacks

University of Miami physicist Neil Johnson and his co-authors have found that there is a “generic way in which humans carry out insurgency and terrorism when faced by a large powerful state force, and this is irrespective of background history, motivation, ideology, politics, and location”. Their study is featured as the cover of the December 17, 2009 issue of Nature:

We have found a unified model of modern insurgent wars that shows a fundamental pattern in the apparent chaos of wars,” says Johnson. “In practical terms, our analysis can be used to create and explore scenarios, make predictions, and assess risks for present and future wars.

Here’s a link to the full story that appeared in UM’s E-Veritas publication. This paper will make for some nice holiday reading.

Leave a comment

Filed under Applications, Modeling, War

Let’s Join O.R. Forces to Crack the 17×17 Challenge

I recently came across this post by bit-player, which refers to this post by William Gasarch, on a very interesting feasibility problem: given an m \times n grid, assign one of c colors to each position on the grid so that no rectangle ends up with the same color in all of its vertices (see the original post for applications of this problem). Many results are known for different values of m , n , and c , but the challenge (which comes with a reward of US$289) is to decide whether a feasible solution exists when m=n=17 and c = 4 .

Apparently, some attempts have been made to use Integer Programming (IP) to solve this problem:

SAT-solvers and IP-programs have been used but have not worked— however, I don’t think they were tried that seriously.

By writing this post, I hope to get enough O.R. people excited to brainstorm together in search of a solution. Given this is a feasibility problem, another method of choice here would be Constraint Programming (more on that later).

I decided to begin with the first IP formulation that came to mind. I didn’t expect it to close the deal, but I wanted to see how far it would take me. Here it is: let the binary variable x_{ijt} equal 1 if the cell in row i and column j receives color t . There are two groups of constraints.

Every cell must have a color:

\sum_{t=1}^c x_{ijt} = 1, \enspace \forall \; i,j

Every rectangle can have at most 3 vertices with the same color:

x_{ijt} + x_{i+a,jt} + x_{i,j+b,t} + x_{i+a,j+b,t} \leq 3, \enspace \forall \; i,j,a,b,t


1 \leq i \leq m-1 , 1 \leq j \leq n-1 , 1 \leq a \leq m-i , and 1 \leq b \leq n-j .

The objective function does not matter (in theory), but my limited experiments indicate that it’s better to minimize the sum of all x_{ijt} than it is to maximize it. Gasarch also provides this diagram with a rectangle-free subset of size 74 for a 17 x 17 grid. I then added constraints of the form x_{ij1}=1 for every cell (i,j) with an “R” in the diagram. This may be too restrictive, since it’s not clear to me whether a feasible solution to the 17 x 17 grid must contain that diagram as a subset. If that’s true, the latter constraints help with symmetry breaking and also substantially reduce the problem size. To reduce some of the color symmetry in the problem, I also arbitrarily chose cell (1,1) to contain color 2, i.e. x_{112}=1 . Note that this still allows colors 3 and 4 to be swapped. I could have set x_{123}=1 , but that would mean taking a risk.

Finally, for the 17 x 17 grid, it is suspected that each line and each row will have three colors used four times and one color used five times, hence, I also included the following constraints:

4 \leq \sum_{j=1}^n x_{ijt} \leq 5, \enspace \forall \; i,t

4 \leq \sum_{i=1}^m x_{ijt} \leq 5, \enspace \forall \; j,t

Once again, if my understanding is correct, there’s no formal proof that the above constraints are valid.

Here’s a ZIMPL model that can be used to  generate the .LP files and here’s the 17 x 17 LP. I set CPLEX’s MIP emphasis to 4 (look for hidden feasible solutions) and first ran a 14 x 14 as a warm-up. CPLEX 12.1 finds a feasible solution in under 5 seconds (I substituted 1 for 4 in the color usage constraints above). I stopped the 15 x 15 problem after 12 fruitless hours of search, so 14 x 14 is apparently the largest of the easy instances.

I started the 17 x 17 run last Thursday. The initial IP has 1156 variables and 74,620 constraints. Pre-processing reduces that to 642 variables and 15,775 constraints. After approximately 122 hours and 77,000 nodes on a dual-core machine (3.79 GHz), no solution was found.

Now it’s time for smarter ideas. Here are a few candidates:

1) Try a column-generation approach. It’s easy to find solutions for 8×8 and 9×9 grids, which will appear as sub-grids of a 17×17 solution. So it may be possible to write a set partitioning formulation (with side constraints) that has the 8×8 and 9×9 solutions as variables.

2) Try a meta-heuristic approach (e.g. simulated annealing). This problem is probably one of those for which an almost-feasible solution (like this one) can be very far from a feasible solution.

3) Try constraint programming. I think the main difficulty here will be finding a good variable and value selection heuristic. I started building a Comet model for the problem using the global constraint cardinality; here it is. It still does not include the constraints that fix the color of the rectangle free subset provided by Gasarch, but those are very easy to add (see the code that is commented out).

Let me know what your thoughts and hunches are!


Filed under Challenge, Constraint Programming, Integer Programming, Modeling