Add exit() to the language
Summary:
Add an exit() function to the language.
We could also call it error(), fatal(), or fatal_error().
Description:
Currently, we have reject() in the Stan language. Using reject() rejects the current iteration.
We should have matching exit() calls in the Stan language. Using exit() should stop algorithms from continuing. This will indicate that there is something wrong and shouldn't be ignored. As opposed to reject() which will continue onto the next iteration.
- [ ] Decide on what to throw in the C++ when
exit()is used - [ ] If necessary, add a function to call to the math library.
- [ ] Add
exit(...)to the language to match the function signatures ofreject(). - [ ] Update manual with description of behavior of
reject()andexit(). - [ ] Update algorithms to exit with
exit()call.
Reproducible Steps:
Here's an example:
parameters {
real<lower = 0, upper = 1> theta;
}
model {
exit();
}
Current Output:
Currently, this will show that the 100 tries for initialization failed.
Expected Output:
Exit the algorithm.
Current Version:
v2.11.0
I think action is on me to come up with possible exceptions to throw.
I would suggest using std::system_error (introduced in C++11).
http://www.cplusplus.com/reference/system_error/system_error/
It takes a string and an error code. With pull request #2307, this should pass through and stop the samplers.