Skip to main content
1-Visitor
November 21, 2014
Solved

control iteration

  • November 21, 2014
  • 2 replies
  • 2186 views

Hello All,

My program, for some particular cases, spends too much time on a "genfit" function and finally stops calculation (regression doesn’t converge).

Is there a way to ask the program, that if it couldn't find the answer within a time interval (or limited number of iterations), forget about the particular case and continue to the next case?

Best answer by Werner_E

PAYMAN RAJAI wrote:

Thank you Werner and Fred,

One last question; suppose the program is running for hundred cases for example. Is there a way to understand which case in under processing at the moment?

Yes, there is.

You can use either the trace() command in your program and turn on debug mode or you can use one of the write comands (WRITEPRN, WRITEEXCEL, ....) which writes the iteration number to a file.

Both methods will slow down calculation. In case of just hundred iteration where each one would take a lot of time the second method may have advantages, but you will have to compare yourself.

2 replies

23-Emerald I
November 21, 2014

Since what you posted is clearly an excerpt, we can only guess; have you tried "on error"?

25-Diamond I
November 21, 2014

PAYMAN RAJAI wrote:

Hello All,

My program, for some particular cases, spends too much time on a "genfit" function and finally stops calculation (regression doesn’t converge).

Is there a way to ask the program, that if it couldn't find the answer within a time interval (or limited number of iterations), forget about the particular case and continue to the next case?

Unfortunately you can neither set a time limit nor a limit for the iteration steps. You will have to code a routine like genfit yourself to be able to implement that feature.

But as Fred already has suggested you can use the on error statement to avoid that your complete calculation routine fails without any result at all just because one case throws an error.

payman1-VisitorAuthor
1-Visitor
November 22, 2014

Thank you Werner and Fred,

One last question; suppose the program is running for hundred cases for example. Is there a way to understand which case in under processing at the moment?

Werner_E25-Diamond IAnswer
25-Diamond I
November 22, 2014

PAYMAN RAJAI wrote:

Thank you Werner and Fred,

One last question; suppose the program is running for hundred cases for example. Is there a way to understand which case in under processing at the moment?

Yes, there is.

You can use either the trace() command in your program and turn on debug mode or you can use one of the write comands (WRITEPRN, WRITEEXCEL, ....) which writes the iteration number to a file.

Both methods will slow down calculation. In case of just hundred iteration where each one would take a lot of time the second method may have advantages, but you will have to compare yourself.