Mar 06 2023 10:02 AM
I have a spreadsheet that is using a circular reference to solve a thermodynamics problem under varying conditions. 99.9% of the time, it converges to the solution relatively quickly. However, for the 0.1% of the time it doesn't converge, it is because there is no solution under those conditions.
What I would like to do is to capture the value of the current iteration, then if it exceeds a certain value, apply a corrective factor to my equations (this works when I manually enter the corrective factor).
I have been able to build an counter that will tell me what iteration it is on then stop when my calculation has converged, however the counter itself is a circular reference so the sheet goes on iterating until my maximum number of iterations. This will slow down my simulation when I'm getting the results for thousands of different conditions. It will iterate 1,000 times even though the calculation converged after 10 or 12 iterations.
What gets me though is that when the calculation doesn't converge, while the sheet is iterating, there is an iteration value displayed in the status bar that looks like this "Iter: 245" and I can watch it updating by steps of 10-20 iterations. If I could just grab that value and use it in my sheet, I think my problem would be solved. I feel like I should be able to do this using a user defined formula or macro.
Thanks,
MK
Feb 21 2024 11:48 PM
Feb 21 2024 11:56 PM
It's not possible to directly access the iteration value displayed in the status bar during circular calculations in Excel. However, there are alternative approaches to achieve your desired functionality:
1. Using Goal Seek:
Excel will automatically adjust the chosen cell within the circular reference loop until the desired outcome in cell C1 is achieved. This effectively mimics the iterative process without displaying the iteration count.
2. VBA Macro:
3. Solver Add-in:
Solver will then find the optimal solution that satisfies your objective and constraints, effectively mimicking the iterative process without displaying the iteration count.
Choosing the best approach:
Remember that using circular references can impact performance and stability. Consider alternative non-circular approaches if feasible for your specific problem
Feb 22 2024 01:38 AM
Thanks for your input, @smylbugti222gmailcom.
They are very useful if you have a single (or few) iteration loops in your worksheet.
In my case I have a large number (100+) of non-similar iteration loops in the same worksheet. I am actually amazed about Excel's capability to handle this smoothly. I am seeking a way to check whether Excel's convergence criteria (set in Settings->Formulas) were met for all iteration loops.
Making individual checks for each iteration loop (or even identifying them all) is not an option in my case.
Ideally I would like to see a VBA property called worksheet.converged (boolean) that would tell me whether the worksheet managed to converge since the last change. Or a similar functionality.
Feb 22 2024 06:55 AM
Depending on how complex your calculations are it may be possible with a recursive Lambda (Limit is about 2,000 iterations which decreases with the number of parameters in the function.).
Feb 22 2024 07:15 AM
Hi,
I think recursive lambda should be enough to handle simple root searching scheme such bi-section root searching.
I use Excel's built-in NORM.DIST function as an example.
e.g Finding x s.t NORM.DIST(x, 0,1, TRUE) = y use bi-section.
Feb 23 2024 07:35 AM - edited Feb 23 2024 07:38 AM
I was not clear on the complexity. It is a workbook with 40+ sheets containing 100+ circular reference circles, most of these spanning many sheets and intermingled and are not alike. (Yes, Excel handles this surprisingly well).
So my issue is not a question of handling a large number of simple iterations in a handful of circles that are feasible to track individually.
(But your solutions may well be sufficient for Matt and others, so thanks anyway :-))