1. A method comprising: by one or more computing devices, accessing a binary decision diagram (BDD) representing a function having 4 variables, variables 1, 2, 3, and 4, wherein the BDD comprises 4 layers, layers 1, 2, 3, and 4, corresponding to the 4 variables, respectively; determining an optimum variable order of the BDD by performing at least 6 and at most 13 iterations of layer swapping, the 13 iterations including at most 19 layer swaps altogether, wherein each of 6 iterations of the at least 6 and at most 13 iterations comprises: determining a first size of the layers 1 and 2 and a first size of the layers 3 and 4; swapping the layers 1 and 2 and the layers 3 and 4 concurrently; determining a second size of the layers 1 and 2 and a second size of the layers 3 and 4; and determining 1 variable order among 4 variable orders obtained during the iteration that yields a smallest size among the 4 variable orders obtained during the iteration.