error fmincon with constraints: Aeq must have 3450 column(s).
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
close all; clear all; clc;
load workspace17Rao.mat
n=length(D);
%n=69 %size(D)=69x69
x=zeros(1,n);
h_min=0.639064969481681;
h_max=0.968289685083315
h=linspace(h_min,h_max,50);
%size(h)=1x50
function[c,ceq]= vincoli (x,h,D,n)
for i=1:length(h)
c(i)=h(i)-(x*D*x');
ceq=[];
end
end
%fmincon
fun=@(x) x'*sigma*x %size sigma= 69x69
x_rao=zeros(length(h),n);
x0_rao=zeros(length(h),n);
A_rao=[];
b_rao=[];
Aeq_rao=ones(length(h),n);
beq_rao=ones(1,n);
l_b_rao=zeros(1,n);
u_b_rao=ones(1,n);
nonlcon=@vincoli;
risk_rao = zeros(1,length(h));
risk_rao(1) = var_min;
[x(:,i), risk_rao(i)]=fmincon(fun,x0_rao,A_rao,b_rao,Aeq_rao,beq_rao,l_b_rao,u_b_rao,nonlcon)
0 Commenti
Risposte (1)
Walter Roberson
il 18 Nov 2020
x0_rao=zeros(length(h),n);
That will be unraveled into a vector, so you are telling fmincon that you have 69*50 = 3450 variables.
Aeq_rao=ones(length(h),n);
Linear equality constraints must have one column for each variable, so 3450 columns. The number of rows is the number of constraints.
0 Commenti
Vedere anche
Categorie
Scopri di più su Nonlinear Optimization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!