Algorithmically determining the best cell phone plan
My family is almost done with our two-year AT&T contract and I’ve been trying to figure out what the best course of action will be when that happens. The problem is, there are way too many variables; from coverage in the four different places we live to limits on minutes, texts, and data transfer, from availability of the phone I want to my parents not feeling a need to buy new phones for themselves, the whole situation is a bit of a mess. Naturally, as a programmer, I decided I needed to lay out all of the variables, preferences, and the like in a standardized format and algorithmically rank our choices.
So, how does it work?
I’m using Google Spreadsheets to lay out the data, and I wrote a quick Google Apps Script to rank the ‘happiness’ level of each criterion for each family member. Each aspect is rated, for each carrier, on a scale of one to ten, and each family member can rank how important each aspect is to them, on the same spectrum (if it matters to them at all).
function happiness(int_rating, int_importance) {
if(typeof(int_rating)Â !=Â "number"Â ||Â typeof(int_importance)Â !=Â "number")Â {
return(0);
}
var rating = parseInt(int_rating),
importance = parseInt(int_importance);
return _prep_num(rating) * _prep_num(importance);
}
function _prep_num(x) {
if(1 <= x <= 5)
return x - 6;
else if(6 <= x <= 10)
return x - 5;
else
return 0;
}​
Once each carrier-criterion-preference happiness level is determined for each family member, a simple sum is calculated for each family member, and the sum of those sums is the result for each carrier.
It’s so simple now: just rank simple single criteria for each carrier, decide how important each criterion is to each person, and voilà ! You have a ranked list of choices. Now this, I can handle.