Replies: 1 comment
-
The typical C# way to do that is with a Cancellation Token. I think you could execute the minimization as task and have the initiator of the task request cancellation after your time limit expires. However, this would require the minimization routine to check the token periodically (maybe once every iteration or so). You could maybe do this within the objective function by adding the cancellation token as a field to your own concrete implementation of I'm not sure what the overheads involved with cancellation tokens are and if they would be significant for numerical optimization algorithms that run many iterations. Moreover, I'm not sure if the Objective function is the right place to do this. As a user, it might be unexpected for the objective function to be able to timeout the algorithm since that seems to be more the minimizers job. I think with more thought and probably a larger pull request, this same concept could be applied to the minimizer instead. |
Beta Was this translation helpful? Give feedback.
-
I need to abort the optimization after a certain computation time. It would be elegant to be able to support this in the objective function, such as returning a Double.NaN to gracefully stop the optimizer. Since the exit condition ManuallyStopped exists, I was looking for the way how, but couldn't find it.
Beta Was this translation helpful? Give feedback.
All reactions