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

1 回表示 (過去 30 日間)
MANISH KUMAR
MANISH KUMAR 2017 年 3 月 29 日
回答済み: Adam 2017 年 3 月 29 日
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by