Thread Subject: createOptionFeedback inside fsolve in Matlab r2009b slows down code?

Subject: createOptionFeedback inside fsolve in Matlab r2009b slows down code?

From: Giovanni

Date: 5 Sep, 2009 22:24:01

Message: 1 of 3

One of my programs, that runs in about 100 seconds in Matlab r2009a, runs now in about 200 seconds in r2009b. After profiling, I found that the main culprit is the

options = optimset(options);

call inside the optionFeedback = createOptionFeedback(options) function that in turn is called by the fsolve function; according to the profiler the line

optionFeedback = createOptionFeedback(options)

 takes more time than the line

[x,FVAL,JACOB,EXITFLAG,OUTPUT,msgData]=...
                378 trustnleqn(funfcn,x,verbosity,gradflag,options,defaultopt,f,JAC,...
                379 detailedExitMsg,optionFeedback,varargin{:});.

which is the main core of the program. I did not find any mention of this on the help files (tried a search with createOptionFeedback). Did I just miss the mention of it in the help (how to turn it off, I mean :-) )
I would avoid tinkering with the fsolve file itself if there is an "official" way of turning off that sort of nasty line.

Thanks in advance for any reply.

Subject: createOptionFeedback inside fsolve in Matlab r2009b slows down code?

From: Rakesh Kumar

Date: 9 Sep, 2009 14:25:04

Message: 2 of 3

"Giovanni" <pireddag@hotmail.com> wrote in message <h7uoe1$h00$1@fred.mathworks.com>...
> One of my programs, that runs in about 100 seconds in Matlab r2009a, runs now in about 200 seconds in r2009b. After profiling, I found that the main culprit is the
>
> options = optimset(options);
>
> call inside the optionFeedback = createOptionFeedback(options) function that in turn is called by the fsolve function; according to the profiler the line
>
> optionFeedback = createOptionFeedback(options)
>
> takes more time than the line
>
> [x,FVAL,JACOB,EXITFLAG,OUTPUT,msgData]=...
> 378 trustnleqn(funfcn,x,verbosity,gradflag,options,defaultopt,f,JAC,...
> 379 detailedExitMsg,optionFeedback,varargin{:});.
>
> which is the main core of the program. I did not find any mention of this on the help files (tried a search with createOptionFeedback). Did I just miss the mention of it in the help (how to turn it off, I mean :-) )
> I would avoid tinkering with the fsolve file itself if there is an "official" way of turning off that sort of nasty line.
>
> Thanks in advance for any reply.

Hi,
The expense to call 'createOptionFeedback' should be constant (typically less than a fraction of a second) irrespective of the problem size. I am guessing that you are running fsolve in a loop where each problem is relatively cheap so the overhead of calling 'createOptionFeedback' is lot more than actually solving the problem.

If you are calling fsolve in a loop then try to keep the call to optimset (to set your option) outside the loop. You can pass a simple structure to fsolve.

Rakesh

Subject: createOptionFeedback inside fsolve in Matlab r2009b slows down code?

From: Samuel Hurley

Date: 17 Mar, 2010 23:39:19

Message: 3 of 3

"Giovanni" <pireddag@hotmail.com> wrote in message <h7uoe1$h00$1@fred.mathworks.com>...
> One of my programs, that runs in about 100 seconds in Matlab r2009a, runs now in about 200 seconds in r2009b. After profiling, I found that the main culprit is the
>
> options = optimset(options);
>
> call inside the optionFeedback = createOptionFeedback(options) function that in turn is called by the fsolve function; according to the profiler the line
>
> optionFeedback = createOptionFeedback(options)
>
> takes more time than the line
>

Hi Giovanni,

I realize this is a bit of a late reply, but I also had this problem. I tracked it down to the fact that levmar is repeatedly calling optimset(options), in order to check that the options you supplied to the algorithm are valid. If you edit the file createOptionFeedback.m and comment out line 19 (in r2009b), it will save a _ton_ of computation time!

My particular problem went from a 15 minute running time to about 2-3 minutes. If you don't want to mess with the builtin matlab code, you can save createOptionFeedback.m in the same path as your program, and it will override the built in function.

Best of luck!
-Sam Hurley
Grad Student,
University of Wisconsin

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
lsqnonlin Samuel Hurley 17 Mar, 2010 19:44:27
optimization Samuel Hurley 17 Mar, 2010 19:44:27
levenburg marqu... Samuel Hurley 17 Mar, 2010 19:44:27
code efficiency Giovanni 5 Sep, 2009 18:29:03
rssFeed for this Thread

Contact us at files@mathworks.com