# Optimizing with two cost functions

Say I have two algorithms to choose from. Both give the same result, but I want to pick the one which has the lowest cost (could be computational or other). For purposes of simplification, assume that both algorithms return a result from 0 to 100. One algorithm, "Algorithm A" is more efficient for all results from 0 to under 50 and the other one, "Algorithm B", is more efficient for all results over 50 to 100. Both are equally efficient at 50. Then my cost or penalty function might look something like this:

Algorithm A: 0 if under 50, else c(x) = 2*(x - 50) if above 50
Algorithm B: 0 if over 50, else c(x) = 1.3*(50 - x) if below 50


Where x is the result of the algorithm and I seek to minimize the cost, c. Given the asymmetrical classification penalty, how would I adjust my prediction of x? Qualitatively, I would want to bias my prediction towards the algorithm with the lower cost function. Example, if my guess is exactly 50, I'd choose algorithm B due to the lower cost function in case I'm wrong. But how do I model this mathematically? I think the answer will depend on the variance or accuracy of how well I can predict x.

• Hi there, would it be ok if you added some more context? For instance, if you have to run the algorithm to know x, how do you hope to choose an algorithm in advance if you don't know x? Are you suggesting that we can approximate x in advance before choosing an algorithm? – Cameron Chandler Jun 11 at 8:07
• @CameronChandler The application of this is to choose one of two capture memory types to use on an automated wafer tester. One type has faster readback under low defect density and the other has faster readback under high defect density. I predict the defect density based on the previous die tested...generally die on a wafer will have similar defect density to its nearest neighbors. I have a linear equation for readback time of both algorithms. Classification simply involves predicting which side of the crossover point a given die lies on. After collecting all defects, I know 'x' exactly. – 486DX2-66 Jun 11 at 15:05