grain_compile function

Compile Bayesian network.