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

1 visualización (últimos 30 días)
MANISH KUMAR
MANISH KUMAR el 29 de Mzo. de 2017
Respondida: Adam el 29 de Mzo. de 2017
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!

Respuestas (1)

Adam
Adam el 29 de Mzo. de 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

Categorías

Más información sobre Loops and Conditional Statements 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