MATLAB: Optimization with a matrix as x

matrixoptimization

Hi, I am trying to implement an optimization using fmincon,
I have as x a matrix 6×6, I have two questions for you:
– I want the x matrix to have just values [0,1], how can I obtain it? how can I initialize the x?
– I want to put as a constraint that the sum on each row has to be 1
Thank you in advance
I

Best Answer

Since you have integer constraints, fmincon is the wrong tool. If your objective function is linear, you could use intlinprog. Otherwise, you'll probably have to resort to GA in the Global Optimization Toolbox.
To constrain the row sums, you would use linear equality constraint inputs Aeq, beq constructed as follows,
Aeq=kron(ones(1,6), speye(6));
beq=ones(6,1);