Call udf some Iterations
Hello to everyone!!
I would love to know if there is someone who knows how to call a udf every some iterations (compiled udf), for example 5, instead of every iteration. In order to not waste computer power, I want to call the function every 'X' iterations and no call every iteration and if a condition is reached then run the function. Thank you very much |
what do you want to do? What you can do is add a counter base on the iteration and put it in an if statement.
|
Quote:
Thank you =) |
so in that case you can add one counter
static int counter = 0.0; if (counter <5) { do nothing for example counter += 1.0; } else if (counter = 5) { do whatever you want; counter = 0.0; } You can do something like this in your execute at the end or adjust macro. |
Quote:
|
when the variable reaches 5 (for example), it will execute something and the variable returns to 0. from iterations 1 to 4 it wont do anything. I do not know how to code to do this only every X iterations, but you can say to do nothing in intervals. Not sure if I made myself clear.
|
Quote:
|
Bruno's answer is probably easier to implement, but I'll put out an alternative option, just in case.
Under Calculation Activities, you can run some scheme code every X iterations or timesteps. If you have an on-demand UDF, you can call it with Code:
(%udf-on-demand "udfname::libudf") |
Quote:
I have the same issue and want to use this method to call the UDF every certain iteration. If I understand correctly, this code needs to be compiled rather than interpret. However, when I interpret, I got "Parse error" In another try, I have successfully compiled the UDF, but cannot load it due to the following error: Code:
Error: The UDF library you are trying to load (libudf) is not compiled for Thanks. |
All times are GMT -4. The time now is 19:33. |