Q. How to get the iteration number at which the problem has been converged?

1 次查看(过去 30 天)
I am running a certain code for 100 iterations, using for loop and the fitness is stored in ‘Best Expected Profit’.
The problem converges after a few iterations.
I want to get the number of iteration at which the problem has been converged.
MaxIt=100; % Maximum Number of Iterations
for it=1:MaxIt
[code for the problem]
end
Best Expected Profit
For example in this graph, the problem has been converged in 19th iteration.
How do I get this number from the code?
Please help.
Thanks in anticipation!

回答(1 个)

Adam
Adam 2017-3-29
Just add in an
if bestExpectedProfit == 100
break
end
and then it will be the iteration you want after the loop. If convergence is based on a tolerance rather than exactly 100 then change condition this accordingly

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by