Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Binary Home Searching
@Inject BinarySearchSolver solver;
...
Function<Double, Affordability> affordabilityFn ...; // our mapping function that takes a number and returns an affordability
Function<Affordability, Boolean> manageableTargetTest = affordability -> affordability.getOrdinal() <= MANAGEABLE.getOrdinal();
double maxManageablePrice = solver.solveForMaxValuePassingTargetTest(
lowerBound,
upperBound,
tolerance, // how close our upper and lower bounds should be to stop searching
affordabilityFn,
manageableTargetTest,
maxSearchIterations);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment