It's just a copy and paste issue, the code is fine in the online notebook and it works if evaluate it, that's why I don't understand what's wrong.
If I write and evaluate this code in my online notebook, it prints out the correct result (keep in mind that copy and paste removes some symbols and replaces them with strings like [Transpose]
)
optimize[d_, p_] := Module[{n, m, q, k, A, b, result},
n=Length[d];
m=Dimensions[p][[2]];
vec[m_]:=Flatten[m\[Transpose]];
mat[v_]:=Partition[v,n]\[Transpose];
j[k_]:=ConstantArray[1,k];
q=j[m]; k=vec[p (d\[TensorProduct]q)];
A=ArrayFlatten[{IdentityMatrix[m]\[TensorProduct]j[n]}];
b=j[m]\[TensorProduct]{1,0};
result = mat[LinearProgramming[k,A,b]];
result
];
d={7,5,11,3};
p=({{5,2,5,3,7,1,1,5,2,5,3,7,1,1},{2,8,3,2,7,2,3,2,8,3,2,7,2,3},{3,6,4,5,9,1,1,3,6,4,5,9,1,1},{4,6,2,8,14,8,4,4,6,2,8,14,8,4}});
optimize[d,p]
Exporting it as an API gives the result that I wrote on the first post.