Using optimization to solve SBM problem