Is fmincon appropriate for optimizing vector-valued optimization variables (scalar obj. function)?

3 次查看(过去 30 天)
I'm currently attempting to solve the following optimization problem:
subject to:
Where I (eye) is the identity matrix, q_1, q_2 are the optimization variables two-dimensional or greater (dimensionality isn't important, just that they are not scalars). C_1 and C_2 are data matrices. I'm wondering if fmincon is appropriate to use for finding the optimal q1,q2, given they are vector-valued. Below is the code I have currently, in case it is helpful.
%% simulated neural activity
numClusters = 163;
prepActivity = randn(200, 163); % (time, number of neurons)
moveActivity = randn(400, 163); % (time, number of neurons)
Cprep = (1/(size(prepActivity,1)-1)) * (prepActivity' * prepActivity); % cov matrix
Cmove = (1/(size(moveActivity,1)-1)) * (moveActivity' * moveActivity);
% get singular values of Cprep and Cmove in descending order
prepSigmas = svd(Cprep);
moveSigmas = svd(Cmove);
%% setup optimization prob
% dimensionality of Qprep and Qmove
d_prep = 2;
d_move = 2;
% terms needed in cost function
prepSigma = sum(prepSigmas(1:d_prep));
moveSigma = sum(moveSigmas(1:d_move));
% define optimization vars
Qprep = optimvar('Qprep', numClusters, d_prep);
Qmove = optimvar('Qmove', numClusters, d_move);
% cost / objective function
cost = @(Qprep, Qmove) 0.5 * ( trace(Qprep'*(Cprep*Qprep))/prepSigma + ...
trace(Qmove'*(Cmove*Qmove))/moveSigma );
cost = fcn2optimexpr(cost, Qprep, Qmove); % needed to convert cost function to appropriate type
prob = optimproblem('Objective',cost, 'ObjectiveSense', 'maximize'); % maximize
% constraints
cons1 = Qprep' * Qmove == zeros(d_prep,d_move); % orthogonality between subspaces
cons2 = Qprep' * Qprep == eye(d_prep); % subspaces should be orthonormal
cons3 = Qmove' * Qmove == eye(d_move);
prob.Constraints.cons1 = cons1;
prob.Constraints.cons2 = cons2;
prob.Constraints.cons3 = cons3;
% show the optimization problem
show(prob)
%% solve
x0.Qprep = ones(numClusters, d_prep) * 5; % initial conditions
x0.Qmove = ones(numClusters, d_move) * 5;
options = optimoptions(@fmincon,'MaxFunctionEvaluations',200000); % increase iterations
[sol,fval,exitflag,output] = solve(prob,x0,'Options', options); % solve
  3 个评论
Munib Hasnain
Munib Hasnain 2021-1-12
Thanks, Walter. That information is helpful. I haven't checked myself if the function is continuous, but I will do that.
Bruno Luong
Bruno Luong 2021-1-12
All the operations used here are multiplications and additions. Thus there is no reason to worry about continuity, in fact at any derivative order.

请先登录,再进行评论。

采纳的回答

Bruno Luong
Bruno Luong 2021-1-12
Yes fmincon supposes to handle optimization problems on objective function that depends on vector of real values. There is no reason whatsoever to concern about this aspect.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by