How to minimize my log_det function in convex programming

If M is small enough, you could you use brute force evaluation of the objective function for all possible values of p.

Otherwise, perhaps use a general purpose mixed integer nonlinear solver and recognize/accept that you might not get the global optimum, or try posting at https://www.or-exchange.org/ or http://scicomp.stackexchange.com/ .