Prev: Plotting raw spectrogram
Next: rgb2gray not working
From: TS on 19 May 2010 16:43 I am using fmincon for estimating 6 different variables stored in 2 * 3 matrix C. These are actually probability values of 3 elements across 2 different classes. (row -> class no, column -> data instance no) I have only linear inequality constraints i.e. sum across each column of C should be 1(the constraint we have for probability values). So, I should only specify A & b matrices in fmincon. I have defined A & b as 1*2 and 1*3 vectors. But an error is occurring saying A must have 6 column(s). [which is the total no of variables in the matrix(2*3)] To correct this, I have specified A & b as 1*6 vectors but now I am getting another error ??? Error using ==> times Matrix dimensions must agree. Error in ==> fmincon at 759 [X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options_ip.HessFcn, ... Can somebody please give an example on how to use matrix variables with fmincon, given linear inequality constraints in the form of A & b? I had been searching for such demo but couldnt get any. Thanks,
From: Matt J on 19 May 2010 19:18 Don't pose the problem in terms of the matrix C. Pose it instead in terms of the vector x=C(:) In this case your constraints on x are x(1)+x(2)=1 x(3)+x(4)=1 x(5)+x(6)=1 which are expressed in the matrix form A*x=b with A = 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 and b=ones(3,1)
From: TS on 21 May 2010 09:41 Thanks Matt for the solution. But the problem is that this method is feasible if I am optimizing a few variables(stored in the form of vector).. But my real optimization problem involves estimating the probability values of half million variables so I guess specifying A in the way you have mentioned is probably not a good option.. Can someone point out any other way for specifying the linear constraints in case C is a huge matrix of thousands of variables? Thanks a lot, "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <ht1rju$37l$1(a)fred.mathworks.com>... > > > Don't pose the problem in terms of the matrix C. Pose it instead in terms of the vector x=C(:) > > In this case your constraints on x are > > x(1)+x(2)=1 > x(3)+x(4)=1 > x(5)+x(6)=1 > > which are expressed in the matrix form A*x=b with > > A = > > 1 1 0 0 0 0 > 0 0 1 1 0 0 > 0 0 0 0 1 1 > > and > > b=ones(3,1)
From: Marcus M. Edvall on 24 May 2010 13:24 Hi, If you have half a million variables you need to look at TOMLAB. Just create the linear constraints in a sparse matrix and you should be fine. You can get a demo from here as needed: http://tomopt.com/scripts/register.php Best wishes, Marcus http://tomsym.com/ http://tomdyn.com/
From: Bruno Luong on 24 May 2010 13:51 "TS " <tanwistha4u(a)yahoo.com> wrote in message <ht62hj$lp2$1(a)fred.mathworks.com>... > Thanks Matt for the solution. But the problem is that this method is feasible if I am optimizing a few variables(stored in the form of vector).. But my real optimization problem involves estimating the probability values of half million variables so I guess specifying A in the way you have mentioned is probably not a good option.. > > Can someone point out any other way for specifying the linear constraints in case C is a huge matrix of thousands of variables? > > Thanks a lot, SPARSE matrix won't help? Bruno
|
Pages: 1 Prev: Plotting raw spectrogram Next: rgb2gray not working |