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

1 visualizzazione (ultimi 30 giorni)
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!

Risposte (1)

Adam
Adam il 29 Mar 2017
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

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by