Nested loops take time to execute.

Nested loops take time to execute. - I have a calculation with several nested For and While loops, but the execution takes too long - Messaggi

#1 Pubblicato: 15/04/2025 19:43:22
David Daniel Alvarez Galvis

David Daniel Alvarez Galvis

1 apprezzamenti in 9 post.

Gruppo: User

Software Jacobsen V1.sm (100,14 KiB) scaricato 1838 volta(e).

Hi everyone,
I have a calculation with several nested FOR and WHILE loops, but the execution is taking too long. I don’t know what the issue is.
Also, I don’t know how to extract the variables SIGA and SIGT from the IF statements inside the loops.
Thanks in advance for your time and help.
#2 Pubblicato: 16/04/2025 09:28:21
Davide Carpi

Davide Carpi

1.443 apprezzamenti in 2.936 post.

Gruppo: Moderator

Hello,

I've put some trace() "traps" in your code and it seems that there is some logic issue at least in the while(k<=1) level.

2025-04-16 11_21_29-SMath Solver - [Software Jacobsen V1.sm_].png

First issue is that k is never initialized.

Second issue is that the first if() inside that while() sends the algorithm in an endless loop, since k doesn't change up to that point.

2025-04-16 11_21_49-SMath Solver - [Software Jacobsen V1.sm_].png

There might be more problems but I'll start from those.

Modificato 16/04/2025 09:49:28
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
4 utenti hanno apprezzato questo post
Andrey Ivashov 16/04/2025 12:17:18, sergio 16/04/2025 16:08:42, NDTM Amarasekera 18/04/2025 11:04:52, David Daniel Alvarez Galvis 15/05/2025 19:30:46
#3 Pubblicato: 02/05/2025 18:19:15
David Daniel Alvarez Galvis

David Daniel Alvarez Galvis

1 apprezzamenti in 9 post.

Gruppo: User

Hello, you're right. I made some changes that match what you suggested. I've already managed to solve the issues—thank you very much!
  • Nuovi post
  • Nessun nuovo post