how can I accelerate the execution of a function in matlab?

1 visualización (últimos 30 días)
Nour BS
Nour BS el 13 de En. de 2016
Respondida: Image Analyst el 14 de En. de 2016
Hello, I am working on a project that optimize the travelling salesman problem (using the Simulating Annealing algorithm). Actually my problem here is the very large computation time that take the function to show me the optimal solution.. So I wonder if there is any technique can make the matlab code execute faster?
Any help is greatly appreciated...

Respuestas (3)

John D'Errico
John D'Errico el 13 de En. de 2016
Some magic wand that can make it run faster? No. If there was a way to make things run faster, they would already have done it for you.
If you want speed, you need to invest the effort. And we cannot know what you need to do, since there are many ways to speed up code. After all, odds are, from your question, you are a bit of a novice. So your code is probably not that efficient. Just a guess.
You need to learn to use the profiler tool, to see where you can gain, where are the bottlenecks.
There are other things you CAN do, for example, you could use various tools to make your code run in parallel. But that requires the processors to do it, the toolbox to make it work, so a bit of money invested. You could try using a GPU processor. But again, that requires knowledge, it requires money. A person with serious skills in C as well as serious skills in numerical analysis might be able to write more efficient code.
Start with your own code. Learn to make it more efficient. By far, that is your most likely source of gain, and the simplest to achieve, as well as the cheapest solution.

Alan Weiss
Alan Weiss el 14 de En. de 2016
I would say that the way to get better speed on this problem is to avoid using the simulated annealing algorithm. The intlinprog solver is almost certainly faster and more reliable. See the documentation example.
Alan Weiss
MATLAB mathematical toolbox documentation

Image Analyst
Image Analyst el 14 de En. de 2016
Under the "Performance and Large Data Sets" section, there is a video on "Optimizing and Accelerating your MATLAB Code" and one on "Speeding Up MATLAB Applications"

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by