|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
linprog - Optim PackageHi, I would like to say that Octave has been great so far, I am a new user and it's been a very good program. One problem I've had is that I am trying to use the linprog function in the optim package. Now my code is Matlab and it works good there, but in Octave it says I am not using the function right. For one thing I noticed the input arguments are not the same. If someone could fix this and make it more like matlab, I would very much appreciate it -- I tried to mess around with the linprog function but it does not seem to work for me. Adrian The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
Re: linprog - Optim PackageHi,
søn, 20 09 2009 kl. 09:45 -0700, skrev Adrian Burlacu: > Hi, I would like to say that Octave has been great so far, I am a new > user and it's been a very good program. One problem I've had is that I > am trying to use the linprog function in the optim package. Now my > code is Matlab and it works good there, but in Octave it says I am not > using the function right. For one thing I noticed the input arguments > are not the same. > > If someone could fix this and make it more like matlab, I would very > much appreciate it -- I tried to mess around with the linprog function > but it does not seem to work for me. > Adrian I think you need to provide some more details here. What are the differences? How do you think things should work? And forth... In general, the more detailed information you provide, the larger the chance that somebody will help you out. Søren ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
Re: linprog - Optim PackageHi.
On 20/09/2009, Søren Hauberg <soren@...> wrote: > Hi, > > søn, 20 09 2009 kl. 09:45 -0700, skrev Adrian Burlacu: >> Hi, I would like to say that Octave has been great so far, I am a new >> user and it's been a very good program. One problem I've had is that I >> am trying to use the linprog function in the optim package. Now my >> code is Matlab and it works good there, but in Octave it says I am not >> using the function right. For one thing I noticed the input arguments >> are not the same. >> >> If someone could fix this and make it more like matlab, I would very >> much appreciate it -- I tried to mess around with the linprog function >> but it does not seem to work for me. >> Adrian > > I think you need to provide some more details here. What are the > differences? How do you think things should work? And forth... In > general, the more detailed information you provide, the larger the > chance that somebody will help you out. Can you please also test the svn version of linprog? I remember I improved compatilbility there. You can download it from [0] (current version in svn, r6039). Or, if you prefer, you can download the full svn optim package from [1]. If you find incompatibilities with matlab in the svn version of linprog, please attach/write a small test case showing this, i.e.: * linprog function invocation * expected output Cheers, Luca Favatella [0] http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/optim/inst/linprog.m?revision=6039 [1] http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/optim.tar.gz?view=tar ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
divergence.mHi Søren,
I would like to contribute with the divergence function. This function is used to compute divergence of vector field and is not included in Octave's distribution. So, could you please give a suggestion on where to locate the file within the repository? Thanks a lot. Regards, Javier ## Copyright (C) 2009 Javier Enciso <j4r.e4o@...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, see ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function file} {} divergence (@var{X}, @var{Y}, @var{Z}, @var{U}, @var{V}, @var{W}) ## @deftypefnx {Function file} {} divergence (@var{U}, @var{V}, @var{W}) ## @deftypefnx {Function file} {} divergence (@var{X}, @var{Y}, @var{U}, @var{V}) ## @deftypefnx {Function file} {} divergence (@var{U}, @var{V}) ## Compute divergence of vector field. ## ## @code{divergence(X, Y, Z, U, V, W)} computes the divergence of a 3-D vector field ## @var{U}, @var{V}, @var{W} at the points @var{X}, @var{Y}, @var{Z}. Coordinate points ## must preserve the given order and define a 3-dimensional grid. ## ## If @var{X}, @var{Y}, and @var{Z} are omitted, @code{divergence(U,V,W)} assumes ## that the coordinates are given by the expression @code{[X Y Z] = meshgrid(1:n,1:m,1:p)} ## where @code{[m,n,p] = size(U)}. ## ## @code{divergence(X, Y, U, V)} computes the divergence of a 2-D vector field @var{U}, ## @var{V} at the points @var{X}, @var{Y}. Coordinate points must preserve the given order ## and define a 2-dimensional grid. ## ## If @var{X} and @var{Y} are omitted, @code{divergence(U,V)} assumes that the ## coordinate points @var{X} and @var{Y} are given by the expression @code{[X Y] = ## meshgrid(1:n,1:m)} where @code{[m,n] = size(U)}. ## @end deftypefn function [div] = divergence(varargin) if nargin < 2 print_usage(); return elseif nargin == 2 u = varargin{1}; v = varargin{2}; if uvcheck(u,v) == 1 [du dump] = gradient(u); [dump dv] = gradient(v); div = du + dv; return end elseif nargin == 3 u = varargin{1}; v = varargin{2}; w = varargin{3}; if uvwcheck(u,v,w) == 1 [du dump dump] = gradient(u); [dump dv dump] = gradient(v); [dump dump dw] = gradient(w); div = du + dv + dw; return end elseif nargin == 4 x = varargin{1}; y = varargin{2}; u = varargin{3}; v = varargin{4}; if xyuvcheck(x,y,u,v) == 1 [du dump] = gradient(u); [dump dv] = gradient(v); [dx dump] = gradient(x); [dump dy] = gradient(y); div = du./dx + dv./dy; return end elseif nargin == 6 x = varargin{1}; y = varargin{2}; z = varargin{3}; u = varargin{4}; v = varargin{5}; w = varargin{6}; if xyzuvwcheck(x,y,z,u,v,w) == 1 [du dump dump] = gradient(u); [dump dv dump] = gradient(v); [dump dump dw] = gradient(w); [dx dump dump] = gradient(x); [dump dy dump] = gradient(y); [dump dump dz] = gradient(z); div = du./dx + dv./dy + dw./dz; return end else print_usage(); return end function [msg] = uvcheck(u, v) d = zeros(1,2); d(1) = ndims(u); d(2) = ndims(v); if find(d(1,:) ~= 2) error('Matrices must have 2 dimensions'); end d = zeros(2); d(1,:) = size(u); d(2,:) = size(v); if find(d(1,:) == d(2,:) == 0) error('Size of matrices must be equal'); end msg = 1; function [msg] = xyuvcheck(x, y, u, v) d = zeros(1,4); d(1) = ndims(x); d(2) = ndims(y); d(3) = ndims(u); d(4) = ndims(v); if find(d(1,:) ~= 2) error('Matrices must have 2 dimensions'); end d = zeros(4,2); d(1,:) = size(x); d(2,:) = size(y); d(3,:) = size(u); d(4,:) = size(v); for m = 1:3 if find(d(m,:) == d(m+1,:) == 0) error('Size of matrices must be equal'); end end msg = 1; function [msg] = uvwcheck(u, v, w) d = zeros(1, 3); d(1) = ndims(u); d(2) = ndims(v); d(3) = ndims(w); if find(d(1,:) ~= 3) error('Matrices must have 3 dimensions'); end d = zeros(3); d(1,:) = size(u); d(2,:) = size(v); d(3,:) = size(w); for m = 1:2 if find(d(m,:) == d(m+1,:) == 0) error('Size of matrices must be equal'); end end msg = 1; function [msg] = xyzuvwcheck(x, y, z, u, v, w) d = zeros(1,6); d(1) = ndims(x); d(2) = ndims(y); d(3) = ndims(z); d(4) = ndims(u); d(5) = ndims(v); d(6) = ndims(w); if find(d(1,:) ~= 3) error('Matrices must have 3 dimensions'); end d = zeros(6,3); d(1,:) = size(x); d(2,:) = size(y); d(3,:) = size(z); d(4,:) = size(u); d(5,:) = size(v); d(6,:) = size(w); for m = 1:5 if find(d(m,:) == d(m+1,:) == 0) error('Size of matrices must be equal'); end end msg = 1; ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
Re: divergence.mHi,
søn, 20 09 2009 kl. 21:07 +0200, skrev Jaiver Enciso: > I would like to contribute with the divergence function. This function > is used to compute divergence of vector field and is not included in > Octave's distribution. So, could you please give a suggestion on where > to locate the file within the repository? The 'divergence' function appears to be a core Matlab function, so I suppose this function should be part of core Octave. For this to happen, you would, however, need to make the coding style match the one used in Octave. I'll give you a couple of pointers on this below (I'll only point out things once, though, so you'll need to make the changes multible times). Could you change the issues I point out and resend your function to maintainers@... ? The first comment is that you should indent the function bodies. That is, write function A () body; endfunction instead of function A () body; endfunction > if nargin < 2 Please use parentheses, i.e. write if (nargin < 2) > print_usage(); > return You don't need the 'return' statement here. In general, please remove these. It is better if the function only return at one point. Also, please add a space between parentheses and function names, i.e. print_usage (); instead of print_usage(); > [du dump] = gradient(u); Add commas in lists, i.e. write [du, dump] = gradient(u); > end Use 'endif' instead of the generic 'end'. This goes in general. > else > print_usage(); > return > end Do you need this last block? Couldn't you merge this with the first block, such that you only have one call to 'print_usage' ? Also, please end functions with 'endfunction'. > error('Matrices must have 2 dimensions'); Use " around strings instead of ' > msg = 1; It seems like this function always returns 'msg = 1'. So, do you need to return anything in the first place? > error('Size of matrices must be equal'); Can you use the 'size_equal' for comparing sizes? Søren P.S. I hope you don't consider these comments too pedantic, but one of the great parts about the core Octave source code is that all the code is written in practically the same style. ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
|
|
|
Re: linprog - Optim PackageOk, so I am def. using the svn version of linprog. I am attaching my inputs and expected outputs from matlab. So far octave is complaining about not calling the linprog properly(obviously no x0 and option arguments). Here is my invocation as before: x = linprog(f,A,Parab,Aeq,beq,lb,ub,x0,options); I hope this is good. Adrian From: Luca Favatella <slackydeb@...> To: Adrian Burlacu <adrian_2002ca@...> Cc: octave-dev <octave-dev@...> Sent: Sunday, September 20, 2009 7:29:18 PM Subject: Re: [OctDev] linprog - Optim Package Please keep octave-dev cc'ed. I am fully quoting your mail. On 20/09/2009, Adrian Burlacu <adrian_2002ca@...> wrote: > Cool, ok, so it didn't work. > Here is how I try to use it in matlab > x0=[]; > options = optimset('TolFun',1e-8); > ub = vector of inf > lb = vector of 0 and -inf > beq = vector of 0 and 2 > aeq = big matrix of 0 and 1 > Parab = [] > A = [] > f = vector of 0 and -1 "vector" and "big matrix" is not detailed enough, because errors could be in vectors/matrices dimensions (I don't know as you didn't specify). (e.g. row or column vectors? and inputs dimensions are coherent each other?) > and I should get > a vector of values ~0.5 that has length 369 > > Sorry, I don't know how to do a smaller case as I'm new to optimization. > Adrian Sorry, but I can't help you because you didn't provide enough info. Could you please write/attach the full octave log (so I can read your exact commands and the exact error)? (And I remember you to please use svn version of linprog.) Sorry again for being unhelpful so far, but I need more info about the issue and how to reproduce it. And thanks for your patience: your feedback is highly appreciated. Cheers, Luca Favatella The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
Re: linprog - Optim Package[Sorry for replying to the previous email, but I lost your answer
after reading it. However I could re-read it at http://sourceforge.net/mailarchive/forum.php?thread_name=684314.52352.qm%40web110015.mail.gq1.yahoo.com&forum_name=octave-dev (btw, stange email text...) ] On 21/09/2009, Luca Favatella <slackydeb@...> wrote: [...] > On 20/09/2009, Adrian Burlacu <adrian_2002ca@...> wrote: >> Cool, ok, so it didn't work. >> Here is how I try to use it in matlab >> x0=[]; octave-forge linprog is a wrapper aroung glpk. x0 argument is not supported in octave-forge, and I don't think there is something analog in glpk (or I can't find it, patches are welcome). Even in Matlab that argument is used only in particular cases (as far as I understood). However, keeping it at [] disables it anyway (I imagine you used it as a placeholder to input the options argument). >> options = optimset('TolFun',1e-8); Same here. Not supported in octave-forge. There are some tolerance arguments in glpk, but I think it could be very difficult to map the tolerance you want to those of glpk (I mean with the same semantics). Writing tests for this functionality will also be very difficult (again, time/patches/tests welcome). So, instead of using linprog(f,A,Parab,Aeq,beq,lb,ub,x0,options) please use linprog(f,A,Parab,Aeq,beq,lb,ub) (or other signatures you read in "help linprog"). [...] > Could you please write/attach the full octave log (so I can read your > exact commands and the exact error)? > (And I remember you to please use svn version of linprog.) I played with the scenario you emailed (input.mat and output.mat in the mail in the thread I linked above). The results are very interesting: your result (x) and the result of octave-forge linprog are (roughly) the same (168), but: * octave-forge linprog result is exactly 168, while yours is 1.7053e-13 greater (that is worse); to test it: + load input.dat + load output.dat + (f' * x) + 168 # ans = 1.7053e-13 + (f' * linprog(f,A,Parab,Aeq,beq,lb,ub)) + 168 # ans = 0 * elements of x are 0.something in yours, all integers numbers using octave-forge linprog Please test svn version of linprog and feel free to report your feedback. Thanks, Luca Favatella ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
Re: linprog - Optim PackageOn 21/09/2009, Luca Favatella <slackydeb@...> wrote:
[...] > Please test svn version of linprog and feel free to report your feedback. I forgot to tell you that current svn version is needed because otherwise empty "A" and "b" arguments are not accepted unless of the right dimensions (empty matrices are not only 0x0). Cheers, Luca Favatella ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
Re: linprog - Optim PackageCool, thanks for all the help. I will try your suggestions. Adrian From: Luca Favatella <slackydeb@...> To: Adrian Burlacu <adrian_2002ca@...> Cc: octave-dev <octave-dev@...> Sent: Monday, September 21, 2009 12:05:39 PM Subject: Re: [OctDev] linprog - Optim Package On 21/09/2009, Luca Favatella <slackydeb@...> wrote: [...] > Please test svn version of linprog and feel free to report your feedback. I forgot to tell you that current svn version is needed because otherwise empty "A" and "b" arguments are not accepted unless of the right dimensions (empty matrices are not only 0x0). Cheers, Luca Favatella The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
Re: divergence.mSøren Hauberg wrote:
> Hi, > > søn, 20 09 2009 kl. 21:07 +0200, skrev Jaiver Enciso: >> I would like to contribute with the divergence function. This function >> is used to compute divergence of vector field and is not included in >> Octave's distribution. So, could you please give a suggestion on where >> to locate the file within the repository? > > The 'divergence' function appears to be a core Matlab function, so I > suppose this function should be part of core Octave. > > For this to happen, you would, however, need to make the coding style > match the one used in Octave. I'll give you a couple of pointers on this > below (I'll only point out things once, though, so you'll need to make > the changes multible times). Could you change the issues I point out and > resend your function to maintainers@... ? > > The first comment is that you should indent the function bodies. That > is, write > > function A () > body; > endfunction > > instead of > > function A () > body; > endfunction > >> if nargin < 2 > > Please use parentheses, i.e. write > > if (nargin < 2) > >> print_usage(); >> return > > You don't need the 'return' statement here. In general, please remove > these. It is better if the function only return at one point. Also, > please add a space between parentheses and function names, i.e. > > print_usage (); > > instead of > > print_usage(); > >> [du dump] = gradient(u); > > Add commas in lists, i.e. write > > [du, dump] = gradient(u); > >> end > > Use 'endif' instead of the generic 'end'. This goes in general. > >> else >> print_usage(); >> return >> end > > Do you need this last block? Couldn't you merge this with the first > block, such that you only have one call to 'print_usage' ? > > Also, please end functions with 'endfunction'. > >> error('Matrices must have 2 dimensions'); > > Use " around strings instead of ' > >> msg = 1; > > It seems like this function always returns 'msg = 1'. So, do you need to > return anything in the first place? > >> error('Size of matrices must be equal'); > > Can you use the 'size_equal' for comparing sizes? > > Søren > > P.S. I hope you don't consider these comments too pedantic, but one of > the great parts about the core Octave source code is that all the code > is written in practically the same style. Hi Søren, Thanks a lot for your advice on Octave's coding style, I wasn't aware of it and certainly I don't consider your comments as pedantic but constructive ;-). Regards, Javier P.S.: The code is ready and I'm about to sent it to the maintainers of Octave. ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
| Free embeddable forum powered by Nabble | Forum Help |