do_optim function

Generate the sparse or p-rep allocation to multiple locations.