From: Susan on 10 Jun 2010 19:23 Hil I'm using x=linprog(f,A,b) where x and f are vectors but would also like to set up restrictions on X and F where X and F contain all the rows a=1:58000 in the dataset such that sum( X(1:a,1)) <= some number and sum(X(1:a,2)) <= some number etc... Can someone explain how I would go about setting this problem up? Thanks!! Susan
From: Matt J on 10 Jun 2010 20:27 "Susan " <snoozy2222(a)yahoo.ca> wrote in message <hurs5a$amc$1(a)fred.mathworks.com>... > Hil > I'm using x=linprog(f,A,b) where x and f are vectors but would also like to set up restrictions on X and F where X and F contain all the rows a=1:58000 in the dataset such that > sum( X(1:a,1)) <= some number and > sum(X(1:a,2)) <= some number ======== Aren't these just further linear constraints? Just append rows to A and b to account for them.
From: Susan on 11 Jun 2010 13:55 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hurvt7$afu$1(a)fred.mathworks.com>... > "Susan " <snoozy2222(a)yahoo.ca> wrote in message <hurs5a$amc$1(a)fred.mathworks.com>... > > Hil > > I'm using x=linprog(f,A,b) where x and f are vectors but would also like to set up restrictions on X and F where X and F contain all the rows a=1:58000 in the dataset such that > > sum( X(1:a,1)) <= some number and > > sum(X(1:a,2)) <= some number > ======== > > Aren't these just further linear constraints? Just append rows to A and b to account for them. They are linear constraints to sum each column but I don't know how to set the code up to capture columns as all the examples show f, b and x as row vectors. For my problem to work F and X are matrices with several thousand lines of code. The linprog command is working perfectly to capture the linear restrictions within each line of data. I don't know how to set up a restriction along each column too, so that no one column can contain more than a specified total.
From: Matt J on 11 Jun 2010 15:28 "Susan " <snoozy2222(a)yahoo.ca> wrote in message <huttaa$a3d$1(a)fred.mathworks.com>... > > They are linear constraints to sum each column but I don't know how to set the code up to capture columns as all the examples show f, b and x as row vectors. For my problem to work F and X are matrices with several thousand lines of code. The linprog command is working perfectly to capture the linear restrictions within each line of data. I don't know how to set up a restriction along each column too, so that no one column can contain more than a specified total. ================ You probably need to use kron() So, for example, if X is an MxN matrix and x=X(:), then Br=eye(M)*X*ones(1,N).'; % row-wise sum Bc= ones(1,M)*X*eye(N).'; %column-wise sum are the row-wise sum and column-wise sum respectively, they are related to x as follows Br(:)=kron(ones(1,N),eye(M)) * x Bc(:)=kron(eye(N), ones(1,M)) * x Then you would build A and b as b=[Br(:),Bc(:)]; A=[kron(ones(1,N),eye(M)) ; kron(eye(N), ones(1,M))];
From: Matt J on 11 Jun 2010 15:33 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <huu2o4$8if$1(a)fred.mathworks.com>... > You probably need to use kron() > > So, for example, if X is an MxN matrix and x=X(:), then > > Br=eye(M)*X*ones(1,N).'; % row-wise sum > Bc= ones(1,M)*X*eye(N).'; %column-wise sum > > are the row-wise sum and column-wise sum respectively, they are related to x as follows > > Br(:)=kron(ones(1,N),eye(M)) * x > Bc(:)=kron(eye(N), ones(1,M)) * x ========= In case the above was unfamiliar to you, the more general relationship is as follows. If Y=P*X*Q.' ; then Y(:)=kron(Q,P)*X(:) ;
|
Next
|
Last
Pages: 1 2 Prev: how to shift and rotate a matrix - nubee Next: Get figures into open office in linux? |