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 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