I'm looking for an algorithm that would be able to determine the optimal combination of two variables, but I'm not sure where to start looking.

For example, if I have 10,000 rows in a database and each row contains price, and square feet is there any algorithm out there that will be able to determine what combination of price and sq ft is optimal.

I know this is vague, but I assume is along the lines of Fuzzy logic and fuzzy sets, but I'm not sure and I'd like to start digging in the right field to see if I can come up with something that solves my problem.

  • 4
    It's a bit hard to understand what is 'optimal' in your case. If you just needed the best price per sq. ft you's just select price, area, area / price as value from table order by value desc limit 1.
    – 9000
    Commented May 30, 2014 at 19:08

2 Answers 2


You might be looking for Pareto efficiency/optimality.

This will allow to select only pairs that are not worse than anything else. From those, you can then pick those that are best for you. The major advantage of this algorithm is that it can be applied for more than two variables.


First, you need to define some sort of evaluation function that can tell you the value of a given combination. For example, are you trying to maximize price per square foot? Square feet per dollar? Something else?

Once you have such an evaluation function, simply calculate the result for each combination of factors in your dataset and then select the combination of parameters that rates highest (or lowest).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.