p(d|c) and p(c|a,b) optimization