Are you sure that the code fro optimize that is posed above is what you intended? Things like
Flatten[m[Transpose]]
Partition[v,n][Transpose]
and so on do not make syntactic sense. So not surprisingly the example as it is posted above (though it may be different in your notebook and possibly a problem with the markup of the code in this forum) does not work and generates a bunch of expected errors....