numClusters = 163;
prepActivity = randn(200, 163);
moveActivity = randn(400, 163);
Cprep = (1/(size(prepActivity,1)-1)) * (prepActivity' * prepActivity);
Cmove = (1/(size(moveActivity,1)-1)) * (moveActivity' * moveActivity);
prepSigmas = svd(Cprep);
moveSigmas = svd(Cmove);
d_prep = 2;
d_move = 2;
prepSigma = sum(prepSigmas(1:d_prep));
moveSigma = sum(moveSigmas(1:d_move));
Qprep = optimvar('Qprep', numClusters, d_prep);
Qmove = optimvar('Qmove', numClusters, d_move);
cost = @(Qprep, Qmove) 0.5 * ( trace(Qprep'*(Cprep*Qprep))/prepSigma + ...
trace(Qmove'*(Cmove*Qmove))/moveSigma );
cost = fcn2optimexpr(cost, Qprep, Qmove);
prob = optimproblem('Objective',cost, 'ObjectiveSense', 'maximize');
cons1 = Qprep' * Qmove == zeros(d_prep,d_move);
cons2 = Qprep' * Qprep == eye(d_prep);
cons3 = Qmove' * Qmove == eye(d_move);
prob.Constraints.cons1 = cons1;
prob.Constraints.cons2 = cons2;
prob.Constraints.cons3 = cons3;
show(prob)
x0.Qprep = ones(numClusters, d_prep) * 5;
x0.Qmove = ones(numClusters, d_move) * 5;
options = optimoptions(@fmincon,'MaxFunctionEvaluations',200000);
[sol,fval,exitflag,output] = solve(prob,x0,'Options', options);
3 Comments
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/714423-is-fmincon-appropriate-for-optimizing-vector-valued-optimization-variables-scalar-obj-function#comment_1257883
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/714423-is-fmincon-appropriate-for-optimizing-vector-valued-optimization-variables-scalar-obj-function#comment_1257883
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/714423-is-fmincon-appropriate-for-optimizing-vector-valued-optimization-variables-scalar-obj-function#comment_1259773
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/714423-is-fmincon-appropriate-for-optimizing-vector-valued-optimization-variables-scalar-obj-function#comment_1259773
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/714423-is-fmincon-appropriate-for-optimizing-vector-valued-optimization-variables-scalar-obj-function#comment_1259818
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/714423-is-fmincon-appropriate-for-optimizing-vector-valued-optimization-variables-scalar-obj-function#comment_1259818
Sign in to comment.