fsolve not converging fast enough
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I am trying to solve a non-linear system, I won't write it here since its very messy, the point is, that only if I set options with more than 1000 'MaxIter' and more than 12,000 'MaxFunEval' it gets close... not even solving.
I need something that will solve this faster..
this are the options that I currently set (I'm still playing with the algorithm):
% options = optimset('Display', 'iter',...
% 'DiffMinChange', 1e-5,...
% 'DiffMaxChange', 0.5,...
% 'TolX',1e-10,...
% 'TolFun',1.e-5,...
% 'MaxFunEvals',1200,...
% 'MaxIter', 400,...
% 'Algorithm','trust-region-reflective'); %'levenberg-marquardt');
any Ideas or functions that I can use?
thanks
Noa
0 comentarios
Respuestas (2)
John D'Errico
el 27 de Mayo de 2015
So what is new? You want it to run faster. So does everyone. The simple answer is to get a faster computer. Showing us only the options used to call fsolve tells us essentially nothing. For example, tolerances are relative to the specific problem. They may be obscenely tight for all we know.
MAYBE you can look at your code to make it more efficient. This is often the case. So often I see people write obscenely terrible code, then wonder why it runs so slowly, and often plead for help on making a tool like fsolve faster. The problem MAY be in your own code, but we cannot know that, since you have chosen not to even give us a hint what lies within.
So start with the profiling tool. It can help you to see if it may be your code that can be improved. Look at MLINT too. It will give you some hints that can improve your code. And if you claim that there is NO way to improve your code by the slightest amount, I will claim you are probably wrong. And if it is so complex that you can't bother to show us, then it is long and tortuous enough that I am sure it can be improved.
Think of it like this - if you can boost the speed of a single function eval by 30%, then you gain 30% overall.
2 comentarios
John D'Errico
el 27 de Mayo de 2015
Editada: John D'Errico
el 27 de Mayo de 2015
1. So you have no desire to touch the code, and have no idea how the code works. This makes it even more likely that the best way to fix the problem is to improve the objective. Looking for a magic bullet like a faster solver is silly. After all, IF there were lots of faster solvers around, then they would be offered as options.
2. Really ugly code is a PERFECT case for code that should be improved. The fact is, this IS where your problem lies, and the source of the best gains to improve your performance. Odds are most of the time is spent in the objective function, NOT in fsolve. So look at the bottlenecks. Find them. Learn to use the profiler.
3. Irrelevant.
4. YOU DO want it to be faster. And if most of the time is spent in function evaluations, then spend your effort on improving that part.
5. Facts are facts. You want it to run faster. So make an effort to make it run faster. Or accept it for what it is.
So sadly, magic bullets don't exist. Instead, learn what the function does and how to improve it. Learn enough MATLAB that you CAN improve it. This is where the gains will be found. Or just accept that it runs as fast as it does, then get some coffee while you wait. This is what computers are there for: to do things that you don't want to do (or can't do) by pencil and paper. However, not all computations can be done immediately.
I'm sorry if you don't like the answer. It is simplest and best to be truthful, IMHO. This is how you will best solve your problem, like it or not.
Alan Weiss
el 27 de Mayo de 2015
This section, too, might have some advice worth considering.
In general, if your function has high curvature, then solvers can have a tough time. Sometimes the only thing to do is to take a bunch of initial points and try the solver in parallel from all the initial points. Even that is not guaranteed to work quickly. And there is no built-in support for this manoeuver.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Ver también
Categorías
Más información sobre Surrogate Optimization en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!