Skip to content

Instantly share code, notes, and snippets.

@dungpa
Created July 30, 2012 14:14
Show Gist options
  • Save dungpa/3207184 to your computer and use it in GitHub Desktop.
Save dungpa/3207184 to your computer and use it in GitHub Desktop.
Branch and bound technique
// Using branch and bound method to prune unused branches.
member x.divideBB() =
if depth >= numItems then
if abs(totalValues.[0] - totalValues.[1]) < bestDifference then
Array.Copy(totalValues, bestTotalValues, size)
bestDifference <- abs(totalValues.[0] - totalValues.[1])
else ()
elif abs(totalValues.[0] - totalValues.[1]) - totalUnassigned <= bestDifference then
for i in 0..1 do
x.selectBB(i)
x.divideBB() |> ignore
x.deselectBB(i)
else ()
bestDifference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment