Created
July 30, 2012 14:14
-
-
Save dungpa/3207184 to your computer and use it in GitHub Desktop.
Branch and bound technique
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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