Prev: Rolling structure actuated by spring in Simmechanics
Next: XLSREAD cuts off time fractions of text data
From: Adnan Abdulally on 10 May 2010 15:12 Ok, so i have code roughly as follows form this pseudo code: XYZI = []; parfor i=1:iter %bunch of code to set up linear system I = lsqnonneg(A,b); XYZI = [XYZI;[X Y Z I]]; end the code works, but once in every 20 or so runs, lsqnonneg hangs and takes 10 hours until it complains saying it reached max iterations. When it doesnt hang, it takes roughly 2-3 minutes. I dont want to increase the tolerance because i want to keep it at what its set to because the other 95% of runs finish fast. Is there any way that i can just stop the worker from doing that iteration and have it go on to the next one? My goal is to have it constantly grab the cpu time and if the different form start to present is grater than 5 minutes i want to have that worker stop the iteration and continue with the next. If iter is set to 50, its ok if i only get 48 iterations out of the code. Thanks, Adnan
From: Walter Roberson on 10 May 2010 15:48 Adnan Abdulally wrote: > Ok, so i have code roughly as follows form this pseudo code: > > XYZI = []; > > parfor i=1:iter > %bunch of code to set up linear system > I = lsqnonneg(A,b); > XYZI = [XYZI;[X Y Z I]]; > end > > the code works, but once in every 20 or so runs, lsqnonneg hangs and > takes 10 hours until it complains saying it reached max iterations. When > it doesnt hang, it takes roughly 2-3 minutes. I dont want to increase > the tolerance because i want to keep it at what its set to because the > other 95% of runs finish fast. > > Is there any way that i can just stop the worker from doing that > iteration and have it go on to the next one? Perhaps if you set a timer (which would probably have to be an elapsed time timer rather than a CPU time timer), and in the timer callback, error() to throw an error, and in the parfor loop, try/catch to catch the timeout ? On the other hand, I don't know if it is possible to set a per-worker timer.
From: Gene on 10 May 2010 16:03 "Adnan Abdulally" <adnan.abdulally(a)tsc.com> wrote in message <hs9lq7$8ag$1(a)fred.mathworks.com>... > Ok, so i have code roughly as follows form this pseudo code: > > XYZI = []; > > parfor i=1:iter > %bunch of code to set up linear system > I = lsqnonneg(A,b); > XYZI = [XYZI;[X Y Z I]]; > end > > the code works, but once in every 20 or so runs, lsqnonneg hangs and takes 10 hours until it complains saying it reached max iterations. When it doesnt hang, it takes roughly 2-3 minutes. I dont want to increase the tolerance because i want to keep it at what its set to because the other 95% of runs finish fast. > > Is there any way that i can just stop the worker from doing that iteration and have it go on to the next one? My goal is to have it constantly grab the cpu time and if the different form start to present is grater than 5 minutes i want to have that worker stop the iteration and continue with the next. > > If iter is set to 50, its ok if i only get 48 iterations out of the code. > > Thanks, > > Adnan: I do not think there is a graceful way to stop lsqnonneg based on cpu time, but you can certainly limit the number of (internal) iterations done in any call to it. [X, RESNORM, RESIDUAL, EXITFLAG] = LSQNONNEG(A, b, X0, OPTIONS) use OPTIMSET to specify the MaxIter field in the OPTIONS structure. With recent versions of Matlab you can replace X0 with ~ (if you don't have a reasonable initial estimate). You probably want to test EXITFLAG - if it's zero the MaxIter limit was exceeded and you may want to set I to something to so indicate (e.g. NaN's or zeros) emc
From: Adnan Abdulally on 10 May 2010 16:41 "Gene " <ecliff(a)vt.edu> wrote in message <hs9opq$qqs$1(a)fred.mathworks.com>... > > Adnan: > > I do not think there is a graceful way to stop lsqnonneg based on cpu time, but you can certainly limit the number of (internal) iterations done in any call to it. > > [X, RESNORM, RESIDUAL, EXITFLAG] = LSQNONNEG(A, b, X0, OPTIONS) > > use OPTIMSET to specify the MaxIter field in the OPTIONS structure. With recent versions of Matlab you can replace X0 with ~ (if you don't have a reasonable initial estimate). > > You probably want to test EXITFLAG - if it's zero the MaxIter limit was exceeded and you may want to set I to something to so indicate (e.g. NaN's or zeros) > > emc Gene, I have looked into optimset earlier. Unfortunately the MaxIter value has no effect on lsqnonneg through optimset and there is no way to set the maximum iterations. Even if i know roughly how many iterations it takes, it does me no good.
From: Walter Roberson on 10 May 2010 19:45 Gene wrote: > [X, RESNORM, RESIDUAL, EXITFLAG] = LSQNONNEG(A, b, X0, OPTIONS) > > use OPTIMSET to specify the MaxIter field in the OPTIONS structure. With > recent versions of Matlab you can replace X0 with ~ (if you don't have a > reasonable initial estimate). The documentation, http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/lsqnonneg.html appears to indicate that in order to supply X0, you must call lsqnonneg passing it a "problem", where a "problem" is a structure with various fields, including X0 and options . There does not appear to be any way to create a "problem" without an X0. If, however, one were simply to omit X0 from the call shown above, the call with just A, b, and OPTIONS *would* be a supported syntax. I have checked the documentation for lsqnonneg, and I have checked the documentation describing the use of tilde, http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/bresuxt-1.html#br67dkp-1 and I do not see anything in either that would indicate general support for using ~ to indicate an unknown value when making a call to a function. ~ is supported at function *definition* to indicate an argument that the caller will provide an argument in that position that should be ignored. Gene, would you be able to provide a link to documentation of using ~ the way you describe?
|
Next
|
Last
Pages: 1 2 Prev: Rolling structure actuated by spring in Simmechanics Next: XLSREAD cuts off time fractions of text data |